home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1997 May / Pcwk0597.iso / sybase / starbuck / hpp.z / WBASECL.HPP < prev    next >
C/C++ Source or Header  |  1996-10-18  |  3KB  |  100 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. #ifndef _WBASECL_HPP_INCLUDED
  12. #define _WBASECL_HPP_INCLUDED
  13.  
  14. #ifndef _WNO_PRAGMA_PUSH
  15. #pragma pack(push,8);
  16. #pragma enum int;
  17. #endif
  18.  
  19. #ifndef _WCHAR_HPP_INCLUDED
  20. #include "wchar.hpp"
  21. #endif
  22.  
  23. typedef unsigned long WClassID;
  24.  
  25. #define WDeclareName(c) \
  26.     public: \
  27.         virtual const WChar* GetClassName() const;
  28.  
  29. #define WDefineName(c) \
  30.         virtual const WChar* c::GetClassName() const { return WTEXT( #c ); }
  31.  
  32.  
  33.  
  34. #define WDeclareCommon(c) \
  35.     public:\
  36.         static WClassID ClassID(); \
  37.         virtual WClassID GetClassID() const; \
  38.         virtual WBool IsInstanceOf( WClassID id ) const; \
  39.         virtual WBool IsInstanceOf( const WChar *classname ) const;
  40.            
  41. #define WDefineCommon(c) \
  42.         static WClassID c::ClassID() \
  43.            { static WClassID id = 0; \
  44.              extern WClassID WEXPORT WGetClassID( const WChar *name );\
  45.              if( !id ) id = WGetClassID( WTEXT( #c ) );\
  46.              return( id ); }\
  47.         virtual WClassID c::GetClassID() const { return c::ClassID(); }\
  48.         virtual WBool c::IsInstanceOf( WClassID id ) const \
  49.            { return( id == c::ClassID() ); } \
  50.         virtual WBool c::IsInstanceOf( const WChar *classname ) const \
  51.            { extern WClassID WEXPORT WGetClassID( const WChar *name );\
  52.              return IsInstanceOf( WGetClassID( classname ) ); }
  53.  
  54.  
  55.  
  56. #define WDeclareSubclass(c,p) \
  57.         \
  58.         WDeclareName(c) \
  59.         WDeclareCommon(c) \
  60.     public:\
  61.         virtual WBool IsDerivedFrom( WClassID id ) const; \
  62.         virtual WBool IsDerivedFrom( const WChar *classname ) const;
  63.  
  64. #define WDefineSubclass(c,p) \
  65.         \
  66.         WDefineName(c) \
  67.         WDefineCommon(c) \
  68.         virtual WBool c::IsDerivedFrom( WClassID id ) const \
  69.            { return (WBool)( ( id == c::ClassID() ) ? 1 : p::IsDerivedFrom( id ) ); } \
  70.         virtual WBool c::IsDerivedFrom( const WChar *classname ) const \
  71.            { extern WClassID WEXPORT WGetClassID( const WChar *name );\
  72.              return IsDerivedFrom( WGetClassID( classname ) ); } 
  73.  
  74.  
  75. #define WDeclareRoot(c) \
  76.         \
  77.         WDeclareName(c)\
  78.         WDeclareCommon(c) \
  79.     public:\
  80.         virtual WBool IsDerivedFrom( WClassID ) const;\
  81.         virtual WBool IsDerivedFrom( const WChar *classname ) const;
  82.  
  83. #define WDefineRoot(c) \
  84.         \
  85.         WDefineName(c)\
  86.         WDefineCommon(c) \
  87.         virtual WBool c::IsDerivedFrom( WClassID id ) const \
  88.            { return (WBool)( id == c::ClassID() ); } \
  89.         virtual WBool c::IsDerivedFrom( const WChar *classname ) const \
  90.            { extern WClassID WEXPORT WGetClassID( const WChar *name );\
  91.              return IsDerivedFrom( WGetClassID( classname ) ); } 
  92.  
  93.  
  94. #ifndef _WNO_PRAGMA_PUSH
  95. #pragma enum pop;
  96. #pragma pack(pop);
  97. #endif
  98.  
  99. #endif // _WCLASS_HPP_INCLUDED
  100.