home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 February: Tool Chest / Apple Developer CD Series Tool Chest February 1996 (Apple Computer)(1996).iso / Sample Code / AOCE Sample Code / PowerTalk Access Modules / Sample SMSAM / SampleSMSAM Source / BuildingBlocks / HandleObject.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-07-28  |  1.8 KB  |  83 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        HandleObject.h
  3.  
  4.     Copyright:    © 1991-1994 by Apple Computer, Inc.
  5.                 All rights reserved.
  6.  
  7.     Part of the AOCE Sample SMSAM Package.  Consult the license
  8.     which came with this software for your specific legal rights.
  9.  
  10. */
  11.  
  12.  
  13.  
  14. #ifndef __HANDLEOBJECT__
  15. #define __HANDLEOBJECT__
  16.  
  17. #ifndef __MEMORY__
  18. #include <Memory.h>
  19. #endif
  20.  
  21. #if THINK_CPLUS
  22. // #error ha ha ha
  23. #endif
  24.  
  25. #if !defined ( THINK_CPLUS ) && !defined ( __SC__ )
  26. #define    ENABLE_HANDLE_OBJECTS
  27. #endif
  28.  
  29. #pragma push
  30. #pragma segment HandleObject
  31.  
  32. class ostream;
  33.  
  34. /***********************************|****************************************/
  35.  
  36. class THandleObject
  37. #if defined ( ENABLE_HANDLE_OBJECTS )
  38. : public HandleObject
  39. #endif
  40. {
  41. public:        THandleObject ();
  42.             THandleObject ( Boolean lockedness );
  43.     virtual ~THandleObject ();
  44.  
  45.     virtual    ostream&                operator >> ( ostream& ) const;
  46.  
  47. protected:    THandleObject ( const THandleObject& );
  48.             THandleObject&             operator = ( const THandleObject& );
  49.             SignedByte                 GetState();
  50.             void                     Lock();
  51.             SignedByte                 LockHigh();
  52.             void                     MoveHigh();
  53.             void                     SetState(SignedByte flags);
  54.             void                     Unlock();
  55.  
  56. #if defined ( ENABLE_HANDLE_OBJECTS )
  57. public:        void**                    operator new ( unsigned int );
  58.             void                    operator delete ( void** );
  59. #endif
  60.  
  61. #if defined ( debug )
  62. public:        Boolean                    IsValidObject ( Boolean mustReturn = false ) const;
  63.             static Boolean            IsAHandleObject ( Handle h );
  64. #endif
  65.  
  66. #if defined ( debug )
  67. private:    OSType                    fTag;
  68. #endif
  69. };
  70.  
  71. /***********************************|****************************************/
  72.  
  73. const OSType kHandleObjectTag = 'HTAG';
  74. extern ostream& operator << ( ostream& s, const THandleObject* o );
  75. inline ostream& operator << ( ostream& s, const THandleObject& o ) { return o >> s; }
  76.  
  77. /***********************************|****************************************/
  78.  
  79. #pragma pop
  80.  
  81. #endif    // __HANDLEOBJECT__
  82.  
  83.