home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 1997 May
/
Pcwk0597.iso
/
sybase
/
starbuck
/
hpp.z
/
WOLESOBJ.HPP
< prev
next >
Wrap
C/C++ Source or Header
|
1996-12-05
|
8KB
|
232 lines
/* %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Copyright (C) 1994, by WATCOM International Inc. All rights %
% reserved. No part of this software may be reproduced or %
% used in any form or by any means - graphic, electronic or %
% mechanical, including photocopying, recording, taping or %
% information storage and retrieval systems - except with the %
% written permission of WATCOM International Inc. %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
*/
/*************************************************************************
*
* WOleServerObject -- Ole Server Object class
*
*
* Events:
*
* QueryInterface -- QueryInterface event
*
*************************************************************************/
#ifndef _WOLESOBJ_HPP_INCLUDED
#define _WOLESOBJ_HPP_INCLUDED
#ifndef _WNO_PRAGMA_PUSH
#pragma pack(push,8);
#pragma enum int;
#endif
#ifndef _WOLETYPE_HPP_INCLUDED
# include "woletype.hpp"
#endif
#ifndef _WSTRING_HPP_INCLUDED
# include "wstring.hpp"
#endif
// forward class declarations
class WCMCLASS WApplication;
class WCMCLASS WOleClassManager;
class WCMCLASS WOleServerObject;
class WCMCLASS WOleServerObjectListEntry;
class WCMCLASS WOleServerObjectRegistryData;
class WCMCLASS WOleServerObject_IUnk;
class WCMCLASS wllist_header;
class WCMCLASS WOleInterfaceFamily;
typedef WOleServerObject * WCMDEF (*pfnOleSvrCreateInst)( WPIUnknown pUnkOuter );
typedef WBool WCMDEF (*pfnOleSvrIsEqualClassID)( const WCLSID & clsid );
struct WOleServerObjectRegistryDataBlock {
WChar *_progID;
WChar *_viProgID;
WChar *_appFullName;
WChar *_appShortName;
WBool _insertable;
WBool _isOleControl;
WInt _versionMajor;
WInt _versionMinor;
};
class WCMCLASS WOleServerObjectRegistryData {
public:
WOleServerObjectRegistryData( const WCLSID & clsid, WOleServerObjectRegistryDataBlock * );
~WOleServerObjectRegistryData( void );
// Self Registration
WBool Register( WApplication *application );
WBool Unregister( void );
WCLSID _classID;
WOleServerObjectRegistryDataBlock *_registryDataBlock;
WOleServerObjectRegistryData *next;
static WOleServerObjectRegistryData *Head;
};
// QueryInterface event data structure
struct WQueryInterfaceEventData : public WEventData {
WCLSID wclsid;
WPIUnknown pIUnknown;
};
// the following is definitions of WOleServerObject
class WCMCLASS WOleServerObject : public WEventGenerator {
WDeclareSubclass( WOleServerObject, WEventGenerator );
friend class WOleServerObject_IUnk;
public:
/**********************************************************
* Constructors and Destructors
*********************************************************/
WOleServerObject();
virtual ~WOleServerObject();
WBool Create( WOleClassManager * );
WBool Destroy( void );
public:
/**************************************************************
* Properties
**************************************************************/
// Prog ID
WString GetProgID( void ) const;
// Version Independent Prog ID
WString GetVersionIndependentProgID( void ) const;
// Version Major
WInt GetVersionMajor( void ) const;
// Version Minor
WInt GetVersionMinor( void ) const;
// Application Full Name
WString GetApplicationFullName( void ) const;
// Application Short Name ( 15 chars max )
WString GetApplicationShortName( void ) const;
// IsInsertable
WBool GetIsInsertable( void ) const;
// IsOleControl
WBool GetIsOleControl( void ) const;
// IUknown interface
WPIUnknown GetIUnknown( WBool addRef=TRUE ) const;
/**************************************************************
* Static Methods
**************************************************************/
// Self Registration
static WBool Register( WApplication *application );
static WBool Unregister( void );
/**************************************************************
* Methods
**************************************************************/
// Add an Interface Family
WBool AddInterfaceFamily( WOleInterfaceFamily *interfaceFamily );
// Specify RegistryData
WBool SetRegistryData( WOleServerObjectRegistryData * );
WOleServerObjectRegistryData *GetRegistryData( void ) const;
// Reference counting
WULong AddRef( void );
WULong Release( void );
// Get the servers WCLSID
virtual WCLSID OleClassID( void );
/**************************************************************
* Internal Methods
**************************************************************/
WBool SetUnkOuter( WPIUnknown pUnkOuter );
protected:
WBool QueryInterfaceFamilies( const WCLSID & clsid, void **iface );
/**********************************************************
* Data Members
*********************************************************/
protected:
WULong _refCount;
WPIUnknown _pUnkOuter;
WOleServerObject_IUnk *_iunknown;
wllist_header *_ifamilyList;
WOleClassManager *_classManager;
WOleServerObjectRegistryData *_registryData;
};
class WCMCLASS WOleServerObjectListEntry {
public:
WOleServerObjectListEntry( pfnOleSvrCreateInst pfn, const WCLSID & clsid );
~WOleServerObjectListEntry( void );
pfnOleSvrCreateInst fnCreateInst;
WCLSID classID;
WOleServerObjectListEntry *next;
static WOleServerObjectListEntry *Head;
};
#define WOleDeclareServerObjectClassID() \
public: \
static WCLSID _oleClassID; \
virtual WCLSID OleClassID( void ) { return( _oleClassID ); };
#define WOleDefineServerObjectClassID( c, c_id ) \
WCLSID c::_oleClassID = c_id;
#define WOleDeclareServerObject( c, c_id ) \
WOleDeclareServerObjectClassID(); \
protected: \
WOleServerObjectListEntry *_serverObjectListEntry; \
public: \
static WOleServerObject *CreateInstance( WPIUnknown pUnkOuter );
#define WOleDefineServerObject( c, c_id, rdb ) \
WOleDefineServerObjectClassID( c, c_id ); \
static WOleServerObjectRegistryData _WOleSvrRegistryData( c_id, &rdb );\
static WOleServerObjectListEntry _WOleSvrListEntry( (pfnOleSvrCreateInst)c::CreateInstance, c_id );\
static WOleServerObject * \
c::CreateInstance( WPIUnknown pUnkOuter ) { \
c *obj = new c(); \
if( obj ) { \
obj->SetUnkOuter( pUnkOuter ); \
obj->SetRegistryData( &_WOleSvrRegistryData ); \
} \
return( obj ); \
}
#ifndef _WNO_PRAGMA_PUSH
#pragma enum pop;
#pragma pack(pop);
#endif
#endif // _WOLESOBJ_HPP_INCLUDED