home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1997 May / Pcwk0597.iso / sybase / starbuck / hpp.z / WOBJECT.HPP < prev    next >
C/C++ Source or Header  |  1996-10-18  |  4KB  |  132 lines

  1. /* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  2.    %     Copyright (C) 1994, by WATCOM International Inc.  All rights    %
  3.    %     reserved.  No part of this software may be reproduced or        %
  4.    %     used in any form or by any means - graphic, electronic or       %
  5.    %     mechanical, including photocopying, recording, taping or        %
  6.    %     information storage and retrieval systems - except with the     %
  7.    %     written permission of WATCOM International Inc.                 %
  8.    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  9. */
  10.  
  11. /*************************************************************************
  12.  *
  13.  * WObject -- Base WClass object
  14.  *
  15.  *************************************************************************/
  16.  
  17. #ifndef _WOBJECT_HPP_INCLUDED
  18. #define _WOBJECT_HPP_INCLUDED
  19.  
  20. #ifndef _WNO_PRAGMA_PUSH
  21. #pragma pack(push,8);
  22. #pragma enum int;
  23. #endif
  24.  
  25. #ifndef _WDEF_HPP_INCLUDED
  26. #  include "wdef.hpp"
  27. #endif
  28.  
  29. #if defined( _DEBUG ) && defined( new )
  30. #   define _REINCLUDE_WNEW
  31. #   undef new
  32. #   undef delete
  33. #endif
  34.  
  35. // Random signature values
  36. #define WOBJECT_VALID_FLAG              3235818270
  37. #define WOBJECT_DELETED_FLAG            3735928559
  38.  
  39. class WCMCLASS WObject {
  40.     WDeclareRoot( WObject );
  41.     
  42.     public:
  43.  
  44.         /**********************************************************
  45.          * Constructors and Destructors
  46.          *********************************************************/
  47.  
  48.         WObject();
  49.  
  50.         virtual ~WObject();
  51.  
  52.         /**********************************************************
  53.          * Properties
  54.          *********************************************************/
  55.  
  56.         // VerificationFlag
  57.  
  58.         WULong GetVerificationFlag();
  59.  
  60.         /**********************************************************
  61.          * Others
  62.          *********************************************************/
  63.  
  64.         // GetInterface
  65.         //
  66.         //    If the object supports an interface, return it.  The
  67.         //    caller must cast the return value to the correct type.
  68.  
  69.         virtual void *GetInterface( const WChar *iface ) const;
  70.  
  71.         /**********************************************************
  72.          * Operators
  73.          *********************************************************/
  74.  
  75.         int operator==( const WObject & obj ) const
  76.             { return( CompareToSelf( obj ) == 0 ); }
  77.         int operator!=( const WObject & obj ) const
  78.             { return( CompareToSelf( obj ) != 0 ); }
  79.         int operator<=( const WObject & obj ) const
  80.             { return( CompareToSelf( obj ) <= 0 ); }
  81.         int operator<( const WObject & obj ) const
  82.             { return( CompareToSelf( obj ) < 0 ); }
  83.         int operator>=( const WObject & obj ) const
  84.             { return( CompareToSelf( obj ) >= 0 ); }
  85.         int operator>( const WObject & obj ) const
  86.             { return( CompareToSelf( obj ) > 0 ); }
  87.  
  88.         int CompareToSelf( const WObject & obj ) const;
  89.  
  90.         //
  91.         // Memory allocation/deallocation.  This ensures that all
  92.         // new/delete calls are performed in the correct free list.
  93.         //
  94.  
  95.         void *operator new( size_t s );
  96.         void *operator new( size_t s, const WChar *funcName,
  97.                             const WChar *fileName, WULong line );
  98.  
  99.         void *operator new( size_t, void * );
  100.  
  101.         void *operator new []( size_t );
  102.         void *operator new []( size_t, const WChar *funcName,
  103.                                const WChar *fileName, WULong line );
  104.  
  105.         void *operator new []( size_t, void * );
  106.  
  107.         void operator delete( void *p );
  108.         void operator delete []( void *p );
  109.  
  110.         /**********************************************************
  111.          * Data members
  112.          *********************************************************/
  113.  
  114.     private:
  115.  
  116.         WULong          _verificationFlag;
  117. };
  118.  
  119. // Re-include to redefine new & delete
  120.  
  121. #ifdef _REINCLUDE_WNEW
  122. #   include "wnew.hpp"
  123. #   undef _REINCLUDE_WNEW
  124. #endif
  125.  
  126. #ifndef _WNO_PRAGMA_PUSH
  127. #pragma enum pop;
  128. #pragma pack(pop);
  129. #endif
  130.  
  131. #endif // _WOBJECT_HPP_INCLUDED
  132.