Factory Class Template Reference

Inheritance diagram for Factory:

FactoryBase IFactory IBase


Public Methods

 Factory (const char *classID)
oa::oaUInt4 createInstance (IBase *reserved, const Guid &interfaceID, void **ptr)
 ~Factory ()

Detailed Description

template<class T>
class Factory< T >

This class extends the FactoryBase class to add an implementation of the createInstance() function of the IFactory interface. This template class is intended to be used as the factory for most implementations of OpenAccess plug-ins. The template parameter T is the implementation class that this factory is responsible for creating. The constructor value classID is the name of the plug-in. For example, a plug-in called "SamplePlug" may have an implementation class as follows:

	class SamplePlug : public PlugInBase {
	  public:
								SamplePlug();
								~SamplePlug();
		// ISampleInterface functions:
		.
		.
		.
		
	  private:
		static Factory	factory;
		.
		.
		.
	}
	

with a line in the .cpp file as follows:

	Factory		SamplePlug::factory("SamplePlug");
	

Note that the class name and the Plug-in name do not have to be the same as they do in this example.


Constructor & Destructor Documentation

template<class T>
Factory< T >::Factory const char *    classID
 

This is the constructor for the Factory class.

Parameters:
classID This is the name of the plug-in. It should match the root name of the .plg file that is installed with the plug-in.

template<class T>
Factory< T >::~Factory  
 


Member Function Documentation

template<class T>
uint32 Factory< T >::createInstance IBase *    reserved,
const Guid &    interfaceID,
void **    ptr
[virtual]
 

This function creates an instance of the T class and sets the ptr argument to the interface specified by the interfaceID argument. Note that the factory increments the reference count of the object prior to returning from this call.

Parameters:
reserved This parameter is reserved and should be set to NULL. It is used in advanced plug-in implementations to create an aggregated instance of a plug-in. (See class Agg and the oaVCSample).
interfaceID This is the id of the interface being requested from the new plug-in instance. If the plug-in doesn't implement this interface, the newly created instance will be destroyed, ptr will be set to NULL, and createInstance() will return IBase::cNoInterface.
*ptr This parameter will be set to the pointer value of the requested interface. It is obtained from class "T" by calling queryInterface() on the newly created object.

Implements IFactory.


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

Return to top of page