VR-Forces 4.1.1 Class Documentation
List of all members | Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes
makVrv::DtModelInstanceFactory Class Reference

Model Instance. More...

Inheritance diagram for makVrv::DtModelInstanceFactory:
Inheritance graph
[legend]

Public Types

typedef std::list< std::string > CreatorClassList

Public Member Functions

virtual ~DtModelInstanceFactory ()
 DTOR.
DtModelInstancecreateModelInstance (const std::string &objectClassName, DtModelDefinition &definition, bool ignoreDefinitionHint=false, const std::string &modelInstanceClassOverride="")
 Create a model instance.
bool isClassRegistered (const std::string &objectClass) const
 Check to see if an object class has been registered.
void registerSceneObjectClass (const std::string &objectClass, const CreatorClassList &classes)
 Register an object class and a list of creator classes.
void registerModelInstanceCreator (const std::string &modelInstanceClassName, DtModelInstanceCreator *)
 Register a model instance creator.
const CreatorClassListsceneObjectClassCreators (const std::string &objectClass)
 Get a list of the model instance creator classes for an object class.
void addObjectClassCreatorToFront (const std::string &objectClass, const std::string &newCreatorClass)
 Register a new creator class with the object Class to the front of the list.
void addObjectClassCreatorToBack (const std::string &objectClass, const std::string &newCreatorClass)
 Register a new creator class with the object Class to the back of the list.
- Public Member Functions inherited from makVrv::DtVirtualBaseClass
 DtVirtualBaseClass ()
 Do nothing constructor.
virtual ~DtVirtualBaseClass ()
 Virtual do nothing destructor.

Static Public Member Functions

static DtModelInstanceFactoryinstance (DtDe &de)
 Get the instance for this factory.
static std::string modelInstanceHintParameterName ()
 Get the string for getting the model instance hind parameter name.

Protected Types

typedef std::map< std::string,
DtModelInstanceCreator * > 
CreatorMap
typedef std::map< std::string,
CreatorClassList
ObjectClassMap

Protected Member Functions

 DtModelInstanceFactory (DtDe &de)
 CTOR.
virtual CreatorClassList modelDefinitionHints (const DtModelDefinition &modelInstance)
 Get the model definition hints from the model instance.
virtual DtModelInstancecreateAndRealize (const std::string &modelInstanceClassName, DtModelDefinition &modelDefinition)
 Create and realize a model definition.

Protected Attributes

DtDemyDe
bool myEnableDebugModelInstanceFallback
std::string myDebugModelInstanceClass
CreatorMap myCreators
ObjectClassMap myObjectCreatorMap

Detailed Description

Model Instance.

Member Typedef Documentation

typedef std::list<std::string> makVrv::DtModelInstanceFactory::CreatorClassList
typedef std::map<std::string,DtModelInstanceCreator*> makVrv::DtModelInstanceFactory::CreatorMap
protected
typedef std::map<std::string,CreatorClassList> makVrv::DtModelInstanceFactory::ObjectClassMap
protected

Constructor & Destructor Documentation

virtual makVrv::DtModelInstanceFactory::~DtModelInstanceFactory ( )
virtual

DTOR.

makVrv::DtModelInstanceFactory::DtModelInstanceFactory ( DtDe de)
protected

CTOR.

Member Function Documentation

static DtModelInstanceFactory& makVrv::DtModelInstanceFactory::instance ( DtDe de)
static

Get the instance for this factory.

Creates this factory if one doesn't exist (lazy creation).

static std::string makVrv::DtModelInstanceFactory::modelInstanceHintParameterName ( )
static

Get the string for getting the model instance hind parameter name.

DtModelInstance* makVrv::DtModelInstanceFactory::createModelInstance ( const std::string &  objectClassName,
DtModelDefinition definition,
bool  ignoreDefinitionHint = false,
const std::string &  modelInstanceClassOverride = "" 
)

Create a model instance.

The creation process is complicated with multiple levels of specification. The typical construction of a model instance is solely dependent on the objectClass. Each objectClass is written to support one or more specific model instance classes. For each Model Instance class that the Object Class supports the type should be registered with this class using the registerSceneObjectClass function. When creating a model instance for a particular object class the CreatorClassList is iterated (front to back) and each classes is attempted to be created using the provided definition. Model definitions are free to also provide hints for object construction. A hint is simply a parameter of type 'ModelInstanceHint' with a value that is an Model Instance class name. Only hints that are also in the registered CreatorClassList for an object class are tried. If ignoreDefinitionHint is set to true, all hints in the model definition are completely ignored. Alternatively modelInstanceClassOverride can be set to a particular ModelInstanceClass name and as long as the model instance can realize the definition the 'DtModelInstance' instance will be returned regardless of whether the class is in the registered CreatorClassList for the objectClass. By default all valid model instance classes will be tried until one is found that can realize the definition. However as this is not always helpful in debugging it is possible to disable this functionality and on the first failure to realize a special debug model instance class is returned.

Parameters
Input
objectClassNameis the name of the type of object creating the model instance.
definitionis a Valid ModelDefinition to be realized by the ModelInstance.
ignoreDefinitionHintcontrols whether the model definition hint should be listened too.
modelInstanceClassOverrridis an optional parameter for setting the class name to be created.
bool makVrv::DtModelInstanceFactory::isClassRegistered ( const std::string &  objectClass) const

Check to see if an object class has been registered.

void makVrv::DtModelInstanceFactory::registerSceneObjectClass ( const std::string &  objectClass,
const CreatorClassList classes 
)

Register an object class and a list of creator classes.

void makVrv::DtModelInstanceFactory::registerModelInstanceCreator ( const std::string &  modelInstanceClassName,
DtModelInstanceCreator  
)

Register a model instance creator.

const CreatorClassList& makVrv::DtModelInstanceFactory::sceneObjectClassCreators ( const std::string &  objectClass)

Get a list of the model instance creator classes for an object class.

void makVrv::DtModelInstanceFactory::addObjectClassCreatorToFront ( const std::string &  objectClass,
const std::string &  newCreatorClass 
)

Register a new creator class with the object Class to the front of the list.

This means that the creator class will have top priority over other creators for the object class.

void makVrv::DtModelInstanceFactory::addObjectClassCreatorToBack ( const std::string &  objectClass,
const std::string &  newCreatorClass 
)

Register a new creator class with the object Class to the back of the list.

This means that the creator class will have bottom priority under other creators for the object class.

virtual CreatorClassList makVrv::DtModelInstanceFactory::modelDefinitionHints ( const DtModelDefinition modelInstance)
protectedvirtual

Get the model definition hints from the model instance.

virtual DtModelInstance* makVrv::DtModelInstanceFactory::createAndRealize ( const std::string &  modelInstanceClassName,
DtModelDefinition modelDefinition 
)
protectedvirtual

Create and realize a model definition.

If the model instance class is unable to realize a model definition the model instance class instance is deallocated and a NULL pointer is returned.

Return values
0Unable to create a model instance class name based upon the model definition.

Member Data Documentation

DtDe& makVrv::DtModelInstanceFactory::myDe
protected
bool makVrv::DtModelInstanceFactory::myEnableDebugModelInstanceFallback
protected
std::string makVrv::DtModelInstanceFactory::myDebugModelInstanceClass
protected
CreatorMap makVrv::DtModelInstanceFactory::myCreators
protected
ObjectClassMap makVrv::DtModelInstanceFactory::myObjectCreatorMap
protected

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

Document ID: Generated on Mon Apr 8 19:24:01 EDT 2013 from SVN revision 125877
Copyright © 2005-2013 VT MÄK. All Rights Reserved (www.mak.com)