home *** CD-ROM | disk | FTP | other *** search
/ Nebula 1995 August / NEBULA.mdf / Apps / DevTools / ClassBuilder / Source / Terminator.m < prev    next >
Encoding:
Text File  |  1993-01-25  |  1.3 KB  |  69 lines

  1. #pragma .h  #import <objc/Object.h> 
  2. #pragma .h  #import "Glyph.h"
  3. #import "Terminator.h"
  4. #import <appkit/Application.h>
  5. /**
  6.  ** Terminators are often called "sentinels"
  7.  ** in CS literature.  They are used stop off
  8.  ** the is, than, and ancestor pointers in
  9.  ** a glyph. They generally function a
  10.  ** the basis of recursive calls on a 
  11.  ** TTree.  There really is only one
  12.  ** Terminator, returned by the new message.
  13.  ** If we could get doesNotUnderstand: to
  14.  ** work with factory objects, 
  15.  ** then this class could be all
  16.  ** class methods.
  17.  **/ 
  18.  
  19. static id _soleInstanceOfTerminator = nil ;
  20.  
  21. @implementation Terminator: Object
  22. }
  23.  
  24. + new ;
  25. { if(!_soleInstanceOfTerminator)
  26.     _soleInstanceOfTerminator = [super new] ;
  27.   return _soleInstanceOfTerminator ;
  28. }
  29.  
  30. - doesNotRecognize: (SEL)aSelector ;
  31. { // if I don't recognize something,
  32.   // I just return
  33.   return self ;
  34. }
  35.  
  36. - enlist: (Glyph *) aGlyt ;
  37. { // I will terminate this Glist
  38.   aGlyt->then = (Glyph *) self ;
  39.   return aGlyt ;
  40. }
  41.  
  42. -hitTest: (NXPoint *) aPnt ;
  43. { return nil ;
  44. }
  45.  
  46. - (char *) iam ;
  47. // remove: debugging purposes only
  48. { return "Term" ;
  49. }
  50.  
  51. - (BOOL) isTerminator ;
  52. { return YES ;
  53. }
  54.  
  55. - (BOOL) precedes: (Glyph *) aGlyph ;
  56. { // Terminators cannot precede anything
  57.   return NO ;
  58. }
  59.  
  60.  
  61. - test: (int) anInt ;
  62. { // remove when you are satisfied...
  63.   [NXApp printf: "T%d\n", anInt] ;
  64.   return self ;
  65. }
  66.  
  67.  
  68. @end