VR-Forces 4.0.4 Class Documentation
Classes | Public Types | Public Member Functions | Static Protected Member Functions | Protected Attributes
DtReaderWriterFactory Class Reference

Factory for creating ReaderWriter objects dynamically based on a type string. More...

List of all members.

Classes

struct  DtRwFunctions

Public Types

typedef DtReaderWriter *(* DtRWCreatorFcn )(const DtString &name, DtReaderWriterRegistry *parentRegistry)
typedef void(* DtRWCopyFcn )(const DtReaderWriter *source, DtReaderWriter *dest)
typedef std::map< DtString,
DtRwFunctions
DtRwFunctionMap

Public Member Functions

 DtReaderWriterFactory ()
virtual DtReaderWritercreateItem (const DtString &type, const DtString &name, DtReaderWriterRegistry *parentRegistry) const
 Creates a new RW type based on the type string provided, with the specified name and parent registry.
virtual bool copyReaderWriter (const DtReaderWriter *sourceRw, DtReaderWriter *destRw) const
 Uses the operator= method on the RW objects to assign sourceRw to destRw.
virtual DtReaderWritercloneReaderWriter (const DtString &name, const DtReaderWriter *sourceRw, DtReaderWriterRegistry *parentRegistry) const
 Creates a clone of the RW object to create a clone of the specified object.
void addDefaultRwCreators ()
 Non-virtual since it is called by the constructor.
template<typename T_RWType >
void registerType (const DtString &rwTypeString)
 Registers a new RW type with the factory.
const DtRwFunctionMapfunctionMap () const
bool typeRegistered (const DtString &rwTypeString) const
 Returns true if the specific type is registered.

Static Protected Member Functions

template<typename T_RWType >
static DtReaderWritercreateRWType (const DtString &name, DtReaderWriterRegistry *parentRegistry)
 Templated utility function that acts as a creator for the specified reader writer type.
template<typename T_RWType >
static void copyRwType (const DtReaderWriter *sourceRw, DtReaderWriter *destRw)
 Templated utility function that copies values from one RW to another.

Protected Attributes

DtRwFunctionMap myRwFunctionMap

Detailed Description

Factory for creating ReaderWriter objects dynamically based on a type string.

This factory also handles copying between two RW object of the same type when only pointers to the base DtReaderWriter class is passed in. This factory works somewhat differently from most other factories in VRF. Some templated methods are defined that are used in place of the more traditional create() and clone() methods. To register a new RW subclass with the factory, call registerType(). RW objects must have a valid operator= and constructor which takes a name and partent registery pointer defined into order to work with this factory.


Member Typedef Documentation

typedef void(* DtReaderWriterFactory::DtRWCopyFcn)(const DtReaderWriter *source, DtReaderWriter *dest)

Constructor & Destructor Documentation


Member Function Documentation

virtual DtReaderWriter* DtReaderWriterFactory::createItem ( const DtString type,
const DtString name,
DtReaderWriterRegistry parentRegistry 
) const [virtual]

Creates a new RW type based on the type string provided, with the specified name and parent registry.

Returns a pointer to this new object. The factory does not do any memory management for this new objects.

virtual bool DtReaderWriterFactory::copyReaderWriter ( const DtReaderWriter sourceRw,
DtReaderWriter destRw 
) const [virtual]

Uses the operator= method on the RW objects to assign sourceRw to destRw.

The objects are first casted to their actual RW object classes based on the readerWriterType() string that is returned from each. Both objects must return the same readerWriterType().

virtual DtReaderWriter* DtReaderWriterFactory::cloneReaderWriter ( const DtString name,
const DtReaderWriter sourceRw,
DtReaderWriterRegistry parentRegistry 
) const [virtual]

Creates a clone of the RW object to create a clone of the specified object.

The object will first be cast to its actual type, based on the readerWriterType() returned by the object. Uses the constructor and operator= of the object. (Does not use the copy constructor)

Non-virtual since it is called by the constructor.

Registers all the default VRF RW object types with the factory.

template<typename T_RWType >
void DtReaderWriterFactory::registerType ( const DtString rwTypeString)

Registers a new RW type with the factory.

This is a templated method, and must be called with the form: registerType<DtRwInt>(DtRwIntType); The basic RW type strings are defined in rwTypes.h.

bool DtReaderWriterFactory::typeRegistered ( const DtString rwTypeString) const

Returns true if the specific type is registered.

template<typename T_RWType >
static DtReaderWriter* DtReaderWriterFactory::createRWType ( const DtString name,
DtReaderWriterRegistry parentRegistry 
) [static, protected]

Templated utility function that acts as a creator for the specified reader writer type.

template<typename T_RWType >
static void DtReaderWriterFactory::copyRwType ( const DtReaderWriter sourceRw,
DtReaderWriter destRw 
) [static, protected]

Templated utility function that copies values from one RW to another.


Member Data Documentation


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

Document ID: Generated on Fri Jun 29 16:33:32 EDT 2012 from SVN revision 116588
Copyright © 2005-2012 VT MÄK Inc. All Rights Reserved (www.mak.com)