25 #ifndef FCM_PLUGIN_INTERFACE_H_
26 #define FCM_PLUGIN_INTERFACE_H_
28 #include "FCMPreConfig.h"
54 } FCMClassInterfaceInfo;
56 typedef FCMClassInterfaceInfo* PFCMClassInterfaceInfo;
65 IFCMUnknown* p = *((IFCMUnknown**)((
FCM::S_Int64)pv + dw));
67 hRes = p->QueryInterface(riid, ppvObject);
77 class FCMPluginModule;
79 typedef IFCMClassFactory* (*FactorCreatorProc)(FCMPluginModule *) ;
86 _FCM_CREATORARGFUNC* innerObjectFunc;
90 typedef FCMInterfaceMap* (*InterfaceMapGetProc)() ;
95 FactorCreatorProc pFactoryCreator;
96 InterfaceMapGetProc pGetInterfaceTable;
149 this->m_Ptr=pObj.
m_Ptr;
171 template <
typename Q>
177 assignPtrWithQIOwnership(this->m_Ptr,p);
196 template <
typename Q>
202 assignPtrWithQIOwnership(this->m_Ptr,pObj.
m_Ptr);
224 assert(this->m_Ptr != 0);
225 return (this->m_Ptr);
233 assert(this->m_Ptr == 0);
242 operator bool()
const
244 return (this->m_Ptr!=0);
257 return (this->m_Ptr != p);
270 return (this->m_Ptr == p);
283 assignPtrWithOwnership(this->m_Ptr,p);
295 if(this->m_Ptr != pObj.
m_Ptr)
297 assignPtrWithOwnership(this->m_Ptr,pObj.
m_Ptr);
311 template <
typename Q>
316 assignPtrWithQIOwnership(this->m_Ptr,pObj.
m_Ptr);
329 template <
typename Q>
334 assignPtrWithQIOwnership(this->m_Ptr,p);
371 template <
typename Q>
374 if( (pArg==0) && (0==this->m_Ptr))
376 if( (pArg==0) || (0==this->m_Ptr))
379 PIFCMUnknown unkThis=0;
380 this->m_Ptr->QueryInterface(IFCMUnknown::GetIID(),(
FCM::PPVoid)&unkThis);
382 PIFCMUnknown unkArg=0;
383 pArg->QueryInterface(IFCMUnknown::GetIID(),(
FCM::PPVoid)&unkArg);
390 return (unkThis == unkArg);
396 void assignPtrWithOwnership ( T*& pDest,T* pSource)
405 void assignPtrWithQIOwnership ( T*& pDest,PIFCMUnknown pSource)
410 pSource->QueryInterface(T::GetIID(),(
PPVoid)&pDest);
437 return this->m_Ptr->operator[](index);
445 class FCMPluginModule
450 FLCMClassMap m_ClassMap;
455 ClassNode* m_firstNode;
463 m_LiveObjectCounter=0;
465 virtual ~FCMPluginModule()
473 return ++m_LiveObjectCounter;
477 assert(m_LiveObjectCounter>0);
478 return --m_LiveObjectCounter;
483 AutoPtr<IFCMUnknown> pCallocUnk;
485 m_pCalloc=pCallocUnk;
489 FCM::Result getClassInfo(FCM::PIFCMCalloc pCalloc,FCM::PFCMClassInterfaceInfo* ppClassInfo)
494 for( FCMPluginModule::ClassNode* pNode = m_firstNode; pNode != 0; pNode = pNode->next )
496 FCMInterfaceMap* pIntfIndex = pNode->m_ClassMap.pGetInterfaceTable();
497 for(; pIntfIndex && (pIntfIndex->iid !=
FCMIID_NULL); ++pIntfIndex){
498 if(pIntfIndex->iid == IID_IFCMUnknown )
503 PFCMClassInterfaceInfo arrClsIntfinfo = *ppClassInfo = (FCMClassInterfaceInfo *) pCalloc->Alloc((
sizeof(FCMClassInterfaceInfo)*(pairCount+2)));
513 arrClsIntfinfo[pairCount+1].classVersion = 0;
514 arrClsIntfinfo[pairCount+1].interfaceID =
FCMIID_NULL;
517 for( FCMPluginModule::ClassNode* pNode = m_firstNode; pNode != 0; pNode = pNode->next )
519 FCMInterfaceMap* pIntfIndex = pNode->m_ClassMap.pGetInterfaceTable();
520 for(; pIntfIndex && (pIntfIndex->iid !=
FCMIID_NULL); ++pIntfIndex)
522 if(pIntfIndex->iid == IID_IFCMUnknown )
524 arrClsIntfinfo[pairCount+1].classID = pNode->m_ClassMap.clsid;
525 arrClsIntfinfo[pairCount+1].classVersion =pNode->m_ClassMap.classVersion;
526 arrClsIntfinfo[pairCount+1].interfaceID = pIntfIndex->iid;
541 for( FCMPluginModule::ClassNode* pNode = m_firstNode; pNode != 0; pNode = pNode->next )
543 if( pNode->m_ClassMap.clsid == clsid) {
544 PIFCMClassFactory pf = pNode->m_ClassMap.pFactoryCreator(
this);
545 res= pf->QueryInterface(iid,pAny);
554 return m_LiveObjectCounter;
561 ClassNode* current=m_firstNode;
566 current= current->next;
567 m_pCalloc->
Free(prev);
576 void addClassEntry (
FCMCLSID clsid, FactorCreatorProc pFactoryCreator, InterfaceMapGetProc pGetInterfaceTable,
FCM::U_Int32 classVersion)
581 ClassNode* newnode = (ClassNode*)m_pCalloc->
Alloc(
sizeof(ClassNode));
585 newnode->m_ClassMap.clsid = clsid;
586 newnode->m_ClassMap.pFactoryCreator = pFactoryCreator;
587 newnode->m_ClassMap.pGetInterfaceTable = pGetInterfaceTable;
588 newnode->m_ClassMap.classVersion = classVersion;
596 ClassNode* current=m_firstNode;
601 current= current->next;
603 prev->next = newnode;
630 template<
typename IntfImpl>
635 PIFCMCallback m_pPIFCMCallback;
636 PIFCMUnknown m_pUnknownOuter;
637 FCMPluginModule *m_pModule;
640 FCMObject(FCMPluginModule *pModule)
647 m_pModule->incrementAliveCount();
651 m_pModule->decrementAliveCount();
654 void FCMInit(PIFCMCallback pIFCMCallback,PIFCMUnknown pUnknownOuter)
656 m_pPIFCMCallback=pIFCMCallback;
665 m_pUnknownOuter = pUnknownOuter;
669 virtual PIFCMCallback GetCallback()
671 return m_pPIFCMCallback;
674 virtual FCMPluginModule * GetPluginModule()
688 return QueryInterface(pInterfaceID,ppvObj);
694 return m_pUnknownOuter->QueryInterface(pInterfaceID,ppvObj);
699 return m_pUnknownOuter->AddRef();
703 return m_pUnknownOuter->Release();
708 FCMInterfaceMap* pIntfMap = IntfImpl::GetInterfaceMap();
712 if(pInterfaceID == pIntfMap->iid && ppvObj )
716 if (pInterfaceID == IID_IFCMUnknown) {
723 (
reinterpret_cast<IFCMUnknown *
>(*ppvObj))->AddRef();
729 res = pIntfMap->innerObjectFunc((
FCM::PVoid)
this,pInterfaceID,ppvObj,pIntfMap->offset);
745 assert(mRefCount > 0);
757 class IntfImpl_Traits
760 static FCM::Result CreateInstance(FCMPluginModule *pModule,PIFCMCallback pCallback,PIFCMUnknown pUnkOuter,T*& out)
763 out =
new T(pModule);
764 out->FCMInit(pCallback,pUnkOuter);
792 if (pUnkOuter && (iid != IID_IFCMUnknown))
795 FCMObject<T>* pNewObject =0;
796 res= IntfImpl_Traits<FCMObject<T> >::CreateInstance(GetPluginModule(),pCallback,pUnkOuter,pNewObject);
800 res=pNewObject->MainQueryInterface(iid,pAny);
810 static PIFCMClassFactory GetFactory( FCMPluginModule *pModule)
813 FCMObject<FCMClassFactory<T> >* pFact =0;
814 FCM::Result res = IntfImpl_Traits<FCMObject<FCMClassFactory<T> > >::CreateInstance(pModule,0,0,pFact);
821 virtual FCMPluginModule * GetPluginModule()=0;
960 #include "FCMPostConfig.h"
962 #endif // FCM_PLUGIN_INTERFACE_H_
void Reset()
Resets the pointer after calling Release.
Definition: FCMPluginInterface.h:343
This file contains definitions for various data types.
This file contains interface for IFCMClassFactory. IFCMClassFactory enables a class of objects to be ...
FCM::Result(* PluginGetClassInfoProc)(PIFCMCalloc pCalloc, PFCMClassInterfaceInfo *ppClassInfo)
Defines the type of a function used by FCM framework to know various classes implemented by the plug-...
Definition: FCMPluginInterface.h:849
unsigned _int32 U_Int32
Type to define an unsigned 32-bit value.
Definition: FCMTypes.h:81
bool IsSameUnknown(Q *pArg)
Returns true if the underlying IFCMUnknown pointer this object is same as that of the argument...
Definition: FCMPluginInterface.h:372
The definitions contained in this namespace define a framework called Flash Component Model (FCM)...
Definition: IGroup.h:36
#define FCM_VERSION
Complete version of the framework.
Definition: FCMMacros.h:78
FCM::Result(* PluginShutdownProc)()
Defines the function called by FCM framework to notify the plug-in that the plug-in will be unloaded ...
Definition: FCMPluginInterface.h:918
void Detach()
Detaches the pointer without calling Release.
Definition: FCMPluginInterface.h:352
T ** operator&()
The address operator that returns the address of pointer held by this object.
Definition: FCMPluginInterface.h:231
bool operator!=(T *p) const
The != comparison operator.
Definition: FCMPluginInterface.h:255
const FCMIID FCMIID_NULL
Represents an invalid Interface Identifier (IID).
Definition: FCMTypes.h:392
void ** PPVoid
Type to define a pointer to pointer to void.
Definition: FCMTypes.h:154
virtual FCM::PVoid _FCMCALL Alloc(FCM::U_Int32 cb)=0
Allocates memory of the size requested by the parameter cb.
#define FCM_FAILURE_CODE(x)
Returns True if x is not success code, else False.
Definition: FCMErrors.h:52
#define FCM_GENERAL_ERROR
General error code.
Definition: FCMErrors.h:76
A class implementing the AutoPtr.
Definition: FCMPluginInterface.h:420
Defines the interface that represents the NoAggregationUnknown.
Definition: IFCMNoAggregationUnknown.h:68
PIFCMUnknown operator[](FCM::U_Int32 index)
The array index operator to access the object at a particular index.
Definition: FCMPluginInterface.h:435
#define FCM_ADDREF(intPtr)
If intPtr exists, increment its reference count.
Definition: FCMMacros.h:185
T * operator->() const
The member access operator to get the pointer held by this object.
Definition: FCMPluginInterface.h:222
Defines the interface that represents the ClassFactory.
Definition: IFCMClassFactory.h:67
AutoPtr(T *p)
Constructs an AutoPtr object.
Definition: FCMPluginInterface.h:131
AutoPtr(const AutoPtr< T > &pObj)
Copy constructor for AutoPtr
Definition: FCMPluginInterface.h:147
This defines smart pointer to manage AddRef and Release calls to FCM objects. In AutoPtr ...
Definition: FCMPluginInterface.h:111
AutoPtr(Q *p)
Constructs an AutoPtr object from a pointer to Q, where both T and Q have to be interfaces deriv...
Definition: FCMPluginInterface.h:172
#define INTERFACE_ENTRY(ifx)
Add an interface.
Definition: FCMMacros.h:267
#define FCM_SUCCESS_CODE(x)
Returns True if x is success code, else False.
Definition: FCMErrors.h:44
void operator=(T *p)
The overloaded assignment operator to assign a pointer.
Definition: FCMPluginInterface.h:279
U_Int32 Result
Type to define a result. This is usually the return type for most APIs.
Definition: FCMTypes.h:126
This file contains interface for IFCMPluginDictionary. The IFCMPluginDictionary interface provides a ...
Represents a 128 bit or 16-byte GUID (Globally Unique IDentifier) value.
Definition: FCMTypes.h:189
FCM::Result(* PluginGetClassObjectProc)(PIFCMUnknown pUnkOuter, ConstRefFCMCLSID clsid, ConstRefFCMIID iid, FCM::PPVoid pAny)
Defines the function called by FCM framework to get the factory objects for the classes implemented b...
Definition: FCMPluginInterface.h:879
#define END_INTERFACE_MAP
Format to end the interface map.
Definition: FCMMacros.h:295
FCM::Result InitDone()
This function is used by the framework and should not be called by clients.
Definition: FCMPluginInterface.h:622
FCMGUID FCMCLSID
Represents the class ID type.
Definition: FCMTypes.h:322
This file contains interface for IFCMCalloc. The IFCMCalloc interface provides a mechanism for alloca...
This file contains interface for IFCMNoAggregationUnknown and needed to support "Aggregation". This interface is used by FCM internally. It is not meant to be used by external clients.
#define FCM_CLS_NOT_DEFINED
Error code is returned if class is not defined.
Definition: FCMErrors.h:85
This file contains all the public IDs used in FCM.
Every class that implements an interface should be derived from this class.
Definition: FCMPluginInterface.h:615
FCM::U_Int32(* PluginCanUnloadNowProc)(void)
Defines the function called by FCM framework to check if the plug-in can be unloaded. This function returns the number of live object instances from by this plug-in. Just before the shutdown, all the instances should be deleted and zero should be returned.
Definition: FCMPluginInterface.h:908
#define FCM_NO_AGGREGATION
Error code is returned if the interface is not found in case of aggregation.
Definition: FCMErrors.h:158
Defines the interface that represents the IUnknown object.
Definition: IFCMUnknown.h:69
const FCMCLSID FCMCLSID_NULL
Represents an invalid class Identifier (CLSID).
Definition: FCMTypes.h:399
FCM::Result(* PluginBootProc)(PIFCMCallback pCallback)
Defines the type of a function that will be called immediately after the DLL/framework load...
Definition: FCMPluginInterface.h:833
AutoPtr(const AutoPtr< Q > &pObj)
Constructs an AutoPtr object from an AutoPtr object, where both T and Q are interfaces deri...
Definition: FCMPluginInterface.h:197
#define FCM_MEM_NOT_AVAILABLE
Error code is returned if memory is not available.
Definition: FCMErrors.h:93
This file contains all the errors used in FCM.
#define _FCM_SIMPLEMAPENTRY
This macro makes debugging asserts easier.
Definition: FCMMacros.h:105
#define BEGIN_INTERFACE_MAP(impl, implVersion)
Format to begin Interface map.
Definition: FCMMacros.h:237
bool operator==(T *p) const
The == comparison operator.
Definition: FCMPluginInterface.h:268
T * m_Ptr
Definition: FCMPluginInterface.h:116
This file contains the macros used in FCM.
This file contains interface for IFCMList. List of pointer to IFCMUnknown objects.
FCMGUID FCMIID
Represents the interface ID type.
Definition: FCMTypes.h:315
#define FCM_SUCCESS
Success code.
Definition: FCMErrors.h:68
#define FCM_RELEASE(intPtr)
If intPtr exists, decrement its reference count.
Definition: FCMMacros.h:193
This file contains interface for IFCMCallback. The IFCMCallback interface is a glue for the objects c...
#define FCM_NO_INTERFACE
Error code is returned if interface is not available.
Definition: FCMErrors.h:101
virtual void _FCMCALL Free(FCM::PVoid pv)=0
Deallocates the memory pointed by the param pv.
void Attach(T *p)
Attaches the pointer without calling AddRef.
Definition: FCMPluginInterface.h:360
void * PVoid
Type to define a void pointer.
Definition: FCMTypes.h:147
signed _int64 S_Int64
Type to define a signed 64-bit value.
Definition: FCMTypes.h:102
const FCM::SRVCID SRVCID_Core_Memory
Defines the universally-unique ID for the memory service.
Definition: FCMPublicIDs.h:74
FCM::Result(* PluginRegisterProc)(PIFCMPluginDictionary pPluginDict)
Defines the function called by FCM framework to register the plug-in. The plug-in has to add the deta...
Definition: FCMPluginInterface.h:894