home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 October / Chip_1997-10_cd.bin / tema / sybase / powerj / hpp.z / WOLESOBJ.HPP < prev    next >
C/C++ Source or Header  |  1997-01-21  |  8KB  |  232 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.  * WOleServerObject -- Ole Server Object class
  14.  *
  15.  *
  16.  *   Events:
  17.  *
  18.  *      QueryInterface          -- QueryInterface event
  19.  *
  20.  *************************************************************************/
  21.  
  22. #ifndef _WOLESOBJ_HPP_INCLUDED
  23. #define _WOLESOBJ_HPP_INCLUDED
  24.  
  25. #ifndef _WNO_PRAGMA_PUSH
  26. #pragma pack(push,8);
  27. #pragma enum int;
  28. #endif
  29.  
  30. #ifndef _WOLETYPE_HPP_INCLUDED
  31. #   include "woletype.hpp"
  32. #endif
  33. #ifndef _WSTRING_HPP_INCLUDED
  34. #   include "wstring.hpp"
  35. #endif
  36.  
  37. #define OPTIMA_COMPONENT_KEY_STR        "OptimaOleComponent"
  38.  
  39. // forward class declarations
  40. class WCMCLASS WApplication;
  41. class WCMCLASS WOleClassManager;
  42. class WCMCLASS WOleServerObject;
  43. class WCMCLASS WOleServerObjectListEntry;
  44. class WCMCLASS WOleServerObjectRegistryData;
  45. class WCMCLASS WOleServerObject_IUnk;
  46. class WCMCLASS wllist_header;
  47. class WCMCLASS WOleInterfaceFamily;
  48.  
  49. typedef WOleServerObject * WCMDEF (*pfnOleSvrCreateInst)( WPIUnknown pUnkOuter );
  50. typedef WBool WCMDEF (*pfnOleSvrIsEqualClassID)( const WCLSID & clsid );
  51.  
  52. struct WOleServerObjectRegistryDataBlock {
  53.     WChar *_progID;
  54.     WChar *_viProgID;
  55.     WChar *_appFullName;
  56.     WChar *_appShortName;
  57.     WBool _insertable;
  58.     WBool _isOleControl;
  59.     WInt  _versionMajor;
  60.     WInt  _versionMinor;
  61. };
  62.  
  63. class WCMCLASS WOleServerObjectRegistryData {
  64.     public:
  65.         WOleServerObjectRegistryData( const WCLSID & clsid, WOleServerObjectRegistryDataBlock * );
  66.         ~WOleServerObjectRegistryData( void );
  67.  
  68.         // Self Registration
  69.         WBool Register( WApplication *application );
  70.         WBool Unregister( WApplication *application );
  71.  
  72.         WCLSID                             _classID;
  73.         WOleServerObjectRegistryDataBlock *_registryDataBlock;
  74.  
  75.         WOleServerObjectRegistryData        *next;
  76. };
  77.  
  78. // QueryInterface event data structure
  79. struct WQueryInterfaceEventData : public WEventData {
  80.     WCLSID      wclsid;
  81.     WPIUnknown  pIUnknown;
  82. };
  83.  
  84. // the following is definitions of WOleServerObject
  85.  
  86. class WCMCLASS WOleServerObject : public WEventGenerator {
  87.     WDeclareSubclass( WOleServerObject, WEventGenerator );
  88.  
  89.     friend class WOleServerObject_IUnk;
  90.  
  91.     public:
  92.  
  93.         /**********************************************************
  94.          * Constructors and Destructors
  95.          *********************************************************/
  96.  
  97.         WOleServerObject();
  98.         virtual ~WOleServerObject();
  99.  
  100.         WBool Create( WOleClassManager * );
  101.         WBool Destroy( void );
  102.  
  103.     public:
  104.  
  105.         /**************************************************************
  106.          * Properties
  107.          **************************************************************/
  108.  
  109.         // Prog ID
  110.         WString GetProgID( void ) const;
  111.  
  112.         // Version Independent Prog ID
  113.         WString GetVersionIndependentProgID( void ) const;
  114.  
  115.         // Version Major
  116.         WInt GetVersionMajor( void ) const;
  117.  
  118.         // Version Minor
  119.         WInt GetVersionMinor( void ) const;
  120.  
  121.         // Application Full Name
  122.         WString GetApplicationFullName( void ) const;
  123.  
  124.         // Application Short Name ( 15 chars max )
  125.         WString GetApplicationShortName( void ) const;
  126.  
  127.         // IsInsertable
  128.         WBool GetIsInsertable( void ) const;
  129.  
  130.         // IsOleControl
  131.         WBool GetIsOleControl( void ) const;
  132.  
  133.         // IUknown interface
  134.         WPIUnknown GetIUnknown( WBool addRef=TRUE ) const;
  135.  
  136.         /**************************************************************
  137.          * Static Methods
  138.          **************************************************************/
  139.  
  140.         // Self Registration
  141.         static WBool Register( WApplication *application );
  142.         static WBool Unregister( WApplication *application );
  143.  
  144.         /**************************************************************
  145.          * Methods
  146.          **************************************************************/
  147.  
  148.         // Add an Interface Family
  149.         WBool AddInterfaceFamily( WOleInterfaceFamily *interfaceFamily );
  150.  
  151.         // Specify RegistryData
  152.         WBool SetRegistryData( WOleServerObjectRegistryData * );
  153.         WOleServerObjectRegistryData *GetRegistryData( void ) const;
  154.  
  155.         // Reference counting
  156.         WULong AddRef( void );
  157.         WULong Release( void );
  158.  
  159.         // Get the servers WCLSID
  160.         virtual WCLSID OleClassID( void );
  161.  
  162.         /**************************************************************
  163.          * Internal Methods
  164.          **************************************************************/
  165.  
  166.         WBool SetUnkOuter( WPIUnknown pUnkOuter );
  167.  
  168.     protected:
  169.  
  170.         WBool QueryInterfaceFamilies( const WCLSID & clsid, void **iface );
  171.  
  172.     /**********************************************************
  173.      * Data Members
  174.      *********************************************************/
  175.     
  176.     protected:
  177.         WULong                          _refCount;
  178.         WPIUnknown                      _pUnkOuter;
  179.         WOleServerObject_IUnk           *_iunknown;
  180.         wllist_header                   *_ifamilyList;
  181.         WOleClassManager                *_classManager;
  182.         WOleServerObjectRegistryData    *_registryData;
  183.  
  184. };
  185.  
  186. class WCMCLASS WOleServerObjectListEntry {
  187.     public:
  188.         WOleServerObjectListEntry( pfnOleSvrCreateInst pfn, const WCLSID & clsid );
  189.         ~WOleServerObjectListEntry( void );
  190.  
  191.         pfnOleSvrCreateInst             fnCreateInst;
  192.         WCLSID                          classID;
  193.         WOleServerObjectListEntry       *next;
  194. };
  195.  
  196. #define WOleDeclareServerObjectClassID()                                \
  197.     public:                                                             \
  198.         static WCLSID _oleClassID;                                      \
  199.         virtual WCLSID OleClassID( void ) { return( _oleClassID ); };
  200.  
  201. #define WOleDefineServerObjectClassID( c, c_id )                        \
  202.     WCLSID c::_oleClassID = c_id;
  203.  
  204. #define WOleDeclareServerObject( c, c_id )                              \
  205.     WOleDeclareServerObjectClassID();                                   \
  206.     protected:                                                          \
  207.         WOleServerObjectListEntry *_serverObjectListEntry;              \
  208.     public:                                                             \
  209.         static WOleServerObject *CreateInstance( WPIUnknown pUnkOuter );
  210.  
  211. #define WOleDefineServerObject( c, c_id, rdb )                          \
  212.     WOleDefineServerObjectClassID( c, c_id );                           \
  213.     static WOleServerObjectRegistryData _WOleSvrRegistryData( c_id, &rdb );\
  214.     static WOleServerObjectListEntry _WOleSvrListEntry( (pfnOleSvrCreateInst)c::CreateInstance, c_id );\
  215.     static WOleServerObject *                                           \
  216.     c::CreateInstance( WPIUnknown pUnkOuter ) {                         \
  217.         c *obj = new c();                                               \
  218.         if( obj ) {                                                     \
  219.             obj->SetUnkOuter( pUnkOuter );                              \
  220.             obj->SetRegistryData( &_WOleSvrRegistryData );              \
  221.         }                                                               \
  222.         return( obj );                                                  \
  223.     }
  224.  
  225. #ifndef _WNO_PRAGMA_PUSH
  226. #pragma enum pop;
  227. #pragma pack(pop);
  228. #endif
  229.  
  230. #endif // _WOLESOBJ_HPP_INCLUDED
  231.  
  232.