|
VR-Engage
2.2
|
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 DtProjectileFactory & | operator= (const DtProjectileFactory &orig) |
| virtual | ~DtProjectileFactory () |
| virtual void | addCreatorFcn (const std::string &type, DtProjectileCreatorFcn fcn) |
| virtual DtProjectile * | createProjectile (const char *type, const DtString &name, DtReaderWriterRegistry *const parentRegistry=NULL) |
Protected Attributes | |
| std::map< std::string, DtProjectileCreatorFcn > | myProjectileCreatorMap |
| makVre::DtProjectileFactory::DtProjectileFactory | ( | ) |
Default constructor.
Creates a new projectile factory with no registered projectile types.
Referenced by DtProjectileFactory(), and operator=().
| makVre::DtProjectileFactory::DtProjectileFactory | ( | const DtProjectileFactory & | orig | ) |
Copy constructor.
| orig | The source factory to copy from |
Creates a new projectile factory as a copy of the provided original, copying all registered projectile types.
References DtProjectileFactory().
|
virtual |
Virtual destructor.
Cleans up resources used by the factory.
| const DtProjectileFactory & makVre::DtProjectileFactory::operator= | ( | const DtProjectileFactory & | orig | ) |
Assignment operator.
| orig | The source factory to copy from |
Assigns the contents of the provided factory to this one, copying all registered projectile types.
References DtProjectileFactory().
|
virtual |
Registers a projectile creation function with the factory.
| type | The string identifier for this projectile type |
| fcn | Function 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.
|
virtual |
Creates a projectile instance of the specified type.
| type | The string identifier for the projectile type to create |
| name | The name to assign to the new projectile |
| parentRegistry | Parent registry for reader/writer functionality (optional) |
Creates and returns a new instance of a DtProjectile object of the specified type. The type must have been previously registered with addCreatorFcn.
|
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.