home *** CD-ROM | disk | FTP | other *** search
/ Power GUI Programming with VisualAge C++ / powergui.iso / trialva / ibmcppw / include / imetatyp.hpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-02-22  |  5.8 KB  |  183 lines

  1. #ifndef _IMETATYP_
  2. #define _IMETATYP_
  3. /*******************************************************************************
  4. * FILE NAME: imetatyp.hpp                                                      *
  5. *                                                                              *
  6. * DESCRIPTION:                                                                 *
  7. *   Declaration of the classes:                                                *
  8. *     IMetaTypeInfo                                                            *
  9. *                                                                              *
  10. * COPYRIGHT:                                                                   *
  11. *   IBM Open Class Library                                                     *
  12. *   (C) Copyright International Business Machines Corporation 1992, 1996       *
  13. *   Licensed Material - Program-Property of IBM - All Rights Reserved.         *
  14. *   US Government Users Restricted Rights - Use, duplication, or disclosure    *
  15. *   restricted by GSA ADP Schedule Contract with IBM Corp.                     *
  16. *                                                                              *
  17. *   Portions or this component are based on work originating from Taligent.    *
  18. *   (C) Copyright Taligent, Inc. 1996 - All rights reserved.                   *
  19. *                                                                              *
  20. *******************************************************************************/
  21. #include <ibase.hpp>
  22. #include <istring.hpp>
  23.  
  24. class IBaseStream;
  25. class IMetaType;
  26.  
  27. #ifdef IC_LIBRARYUSEONLY
  28. class ITypeInternal;
  29. #endif
  30.  
  31.  
  32. #pragma pack(4)
  33.  
  34. class IMetaTypeInfo {
  35. public:
  36. const char
  37.  *name            ( ) const;
  38.  
  39. int
  40.   operator==      ( const IMetaTypeInfo& typeInfo ) const,
  41.   operator!=      ( const IMetaTypeInfo& typeInfo ) const;
  42.  
  43. #ifdef IC_LIBRARYUSEONLY
  44. public:
  45. virtual
  46.  ~IMetaTypeInfo   ( );
  47.  
  48. protected:
  49.   IMetaTypeInfo   ( );
  50.   IMetaTypeInfo   ( const IMetaTypeInfo& typeInfo );
  51. IMetaTypeInfo
  52.  &operator=       ( const IMetaTypeInfo& typeInfo );
  53.  
  54. private:
  55. const char
  56.  *theName;
  57. ITypeInternal
  58.  *fInternal;
  59.  
  60. friend class IMetaType;
  61. friend class ITypeHelper;
  62. friend class ITypeInternal;
  63.   IMetaTypeInfo   ( const char* adoptedName );
  64. ITypeInternal
  65.  *GetTypeInternal ( ) const;
  66. void
  67.   SetTypeInternal ( ITypeInternal* typeInternal );
  68. #endif
  69. };
  70.  
  71. #ifndef IC_LIBRARYUSEONLY
  72.  
  73. #define staticTypeInfo(AType) (*((const IMetaTypeInfo*)0))
  74. template <class AType> const IMetaTypeInfo& dynamicTypeInfo(const AType& obj);
  75.  
  76. #endif 
  77.  
  78. class ITypeHelper;
  79. class ITypeInstaller {
  80. public:
  81.   ITypeInstaller  ( const char* className,
  82.                     const IMetaTypeInfo* (*tgbFunction)(ITypeHelper*) );
  83. };
  84.  
  85. class IMetaType
  86. {
  87. public:
  88.   IMetaType       ( const IMetaTypeInfo& typeInfo );
  89.   IMetaType       ( const IMetaType&         type );
  90.   IMetaType       ( );
  91. virtual
  92.  ~IMetaType       ( );
  93.  
  94. IMetaType
  95.  &operator =      ( const IMetaType& type );
  96. IBoolean
  97.   operator ==     ( const IMetaType& type ) const;
  98. IBoolean
  99.   operator !=     ( const IMetaType& type ) const;
  100. IBaseStream
  101.  &operator >>=    ( IBaseStream& baseStream ) const,
  102.  &operator <<=    ( IBaseStream& baseStream );
  103.  
  104. void
  105.   name            ( IString& ) const;    // why non-const
  106. const IMetaTypeInfo
  107.  &typeInfo        ( ) const;
  108.  
  109. #ifdef IC_LIBRARYUSEONLY
  110.  
  111.   IMetaType       ( const char* theClassName);
  112.  
  113. friend class ITypeHelper;
  114.  
  115. protected:
  116.  
  117. ITypeInternal
  118.  *GetTypeInternal ( ) const;
  119.  
  120. private:
  121. ITypeInternal
  122.  *fInternalObject;
  123.  
  124.   // This stuff is an expansion of the type-information-on-the-side macros...
  125.   // and is equivalent to saying, TypeExtensionDeclarationsMacro(IMetaType)
  126. public:
  127.   static const  IMetaTypeInfo*    gTypeInfo;
  128.   virtual const IMetaTypeInfo*    TGV() const;
  129.   static const  IMetaTypeInfo*    TGB(ITypeHelper* helper);
  130.   static void*                    TGD(const void* other);
  131.   virtual void*                   TGC(IBoolean returnThis) const;
  132.   static IString                  TGCls();
  133.   static ITypeInstaller           gInstaller;
  134. #endif  // IC_LIBRARYUSEONLY
  135.  
  136. };
  137.  
  138. // ====================== M E T A D A T A   I N T E R F A C E ======================
  139. //
  140. // Here's the API template interface exported by this header...
  141. //
  142. template <class AType> AType* copy(const AType& sourceRef);
  143. template <class AType> AType* copyPointer(const AType* sourcePtr);
  144. template <class AType> void flatten(const AType* userObjectToFlatten, IBaseStream& theStream);
  145. template <class AType> void resurrect(AType*& theResult, IBaseStream& theStream);
  146. template <class AType> void createNewObject(AType*& theResult, const IMetaType& theType);
  147. template <class AType, class BType> void dynamicCastTo(AType*& target, BType* object);
  148.  
  149. #ifndef IC_LIBRARYUSEONLY
  150.  
  151. // You must use one of the following macros to get special
  152. // handling of your class by the Taligent type system...
  153. //
  154. #define TypeExtensionDeclarationsMacro(aname)
  155. #define TypeExtensionMacro(aname)
  156. #define TypeExtensionDeclarationsMacro_Abstract(aname)
  157. #define TypeExtensionMacro_Abstract(aname)
  158. #define TypeExtensionTemplateDeclarationsMacro(_tclass,_ptype)
  159. #define TypeExtensionTemplateMacro(_tclass,_ptype)
  160. #define TypeExtensionTemplateDeclarationsMacro_Abstract(_tclass,_ptype)
  161. #define TypeExtensionTemplateMacro_Abstract(_tclass,_ptype)
  162. #define TypeExtensionTemplatePairDeclarationsMacro(_tclass,_ptypeK,_ptypeV)
  163. #define TypeExtensionTemplatePairMacro(_tclass,_ptypeK,_ptypeV)
  164. #define TypeExtensionTemplatePairDeclarationsMacro_Abstract(_tclass,_ptypeK,_ptypeV)
  165. #define TypeExtensionTemplatePairMacro_Abstract(_tclass,_ptypeK,_ptypeV)
  166.  
  167. #else 
  168.  
  169. // This is the implementation internals for this header.
  170. //
  171. #include <imetaimp.hpp>
  172.  
  173. #endif // IC_LIBRARYUSEONLY
  174.  
  175.  
  176. #pragma pack()
  177.  
  178.  
  179. #pragma pack(4)
  180.  
  181.  
  182. #endif
  183.