VR-Engage  2.2
Loading...
Searching...
No Matches
makVre::DtProjectileFactory Class Reference

Detailed Description

This class provides a factory for creating DtProjectile objects based on a type string. By default, the factory contains a single entry for the base DtProjectile class, but additional projectile types can be registered using the addCreatorFcn method.

#include <projectileFactory.h>

Public Member Functions

 DtProjectileFactory ()
 
 DtProjectileFactory (const DtProjectileFactory &orig)
 
const DtProjectileFactoryoperator= (const DtProjectileFactory &orig)
 
virtual ~DtProjectileFactory ()
 
virtual void addCreatorFcn (const std::string &type, DtProjectileCreatorFcn fcn)
 
virtual DtProjectilecreateProjectile (const char *type, const DtString &name, DtReaderWriterRegistry *const parentRegistry=NULL)
 

Protected Attributes

std::map< std::string, DtProjectileCreatorFcnmyProjectileCreatorMap
 

Constructor & Destructor Documentation

◆ DtProjectileFactory() [1/2]

makVre::DtProjectileFactory::DtProjectileFactory ( )

Default constructor.

Creates a new projectile factory with no registered projectile types.

Referenced by DtProjectileFactory(), and operator=().

◆ DtProjectileFactory() [2/2]

makVre::DtProjectileFactory::DtProjectileFactory ( const DtProjectileFactory & orig)

Copy constructor.

Parameters
origThe source factory to copy from

Creates a new projectile factory as a copy of the provided original, copying all registered projectile types.

References DtProjectileFactory().

◆ ~DtProjectileFactory()

virtual makVre::DtProjectileFactory::~DtProjectileFactory ( )
virtual

Virtual destructor.

Cleans up resources used by the factory.

Member Function Documentation

◆ operator=()

const DtProjectileFactory & makVre::DtProjectileFactory::operator= ( const DtProjectileFactory & orig)

Assignment operator.

Parameters
origThe source factory to copy from
Returns
Reference to this factory after assignment

Assigns the contents of the provided factory to this one, copying all registered projectile types.

References DtProjectileFactory().

◆ addCreatorFcn()

virtual void makVre::DtProjectileFactory::addCreatorFcn ( const std::string & type,
DtProjectileCreatorFcn fcn )
virtual

Registers a projectile creation function with the factory.

Parameters
typeThe string identifier for this projectile type
fcnFunction pointer to the creator function for this type

Adds a creator function to the factory for a specific projectile type. When createProjectile is called with this type string, the registered function will be used to create the projectile instance.

◆ createProjectile()

virtual DtProjectile * makVre::DtProjectileFactory::createProjectile ( const char * type,
const DtString & name,
DtReaderWriterRegistry *const parentRegistry = NULL )
virtual

Creates a projectile instance of the specified type.

Parameters
typeThe string identifier for the projectile type to create
nameThe name to assign to the new projectile
parentRegistryParent registry for reader/writer functionality (optional)
Returns
Pointer to the newly created projectile instance

Creates and returns a new instance of a DtProjectile object of the specified type. The type must have been previously registered with addCreatorFcn.

Member Data Documentation

◆ myProjectileCreatorMap

std::map<std::string, DtProjectileCreatorFcn> makVre::DtProjectileFactory::myProjectileCreatorMap
protected

Map of projectile types to their creator functions.

Stores the mapping between projectile type strings and their corresponding creator functions. When createProjectile is called, the type string is used to look up the appropriate creator function in this map.


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