InterfaceAccess Class Template Reference


Static Public Methods

void getInterface (T *object, IBase *&base)

Detailed Description

template<class T>
class InterfaceAccess< T >

This class is used by a regular class to expose an underlying plug-in implementation. As an example, the oaLib class derives much of its functionality from an instance of a DM plug-in that defines the library system in use for that library. ILib is one of the interfaces that a DM system plug-in must implement to be used by the OpenAccess DM package. The InterfaceAccess class provides a "back door" to gain direct access to the interfaces, such as ILib, of an associated plug-in. To accomplish this, a full specialization of InterfaceAccess must be defined with the regular class as the template parameter. The getInterface() function must then be implemented (preferably not inlined, and in a cpp file) to return the IBase interface of the associated plug-in. Continuing the example above, for oaLib, the following is defined in a special header file, which must be explicitly included by code wishing direct access to the plug-in.

In file oaLibInterfaceAccess.h:

		template<>
		class InterfaceAccess<oa::oaLib> {
		public:
			static void             getInterface(oa::oaLib  *object,
												IBase      *&base);
		};
    

And, the getInterface() function is defined in oaLib.cpp:

        void
        InterfaceAccess<oa::oaLib>::getInterface(oa::oaLib  *object,
                                                 IBase      *&base)
        {
            base = oa::oaLibData::get(object)->getDMILink()->iLib;
            base->addRef();
        }
    


Member Function Documentation

template<class T>
static void InterfaceAccess< T >::getInterface T *    object,
IBase *&    base
[inline, static]
 

This function should be implemented for the specialization described above to extract the IBase pointer of the associated plug-in. To use it, callers can include the following code (based on the previous example):

		SPtr<IBase>	base;

		InterfaceAccess<oaLib>::getInterface(lib, base);
		SQPtr<IDMSystemCaps>    caps(base);
	

In this example, lib is an open library, base is a smart pointer to take the (reference counted) IBase interface pointer, and IDMSystemCaps is the interface of interest (see SQPtr<> for usage information). caps now contains a pointer to the required interface and can be accessed directly.

Parameters:
object A pointer to the object that holds the plug-in.
base This pointer will be set to the IBase pointer of the associated plug-in. Note that the reference count of this plug-in is incremented in this function prior to returning.


The documentation for this class was generated from the following files:

Return to top of page