![]() |
VR-Forces Developer's Guide
|
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 parent registry pointer defined into order to work with this factory.

Classes | |
| struct | DtRwFunctions |
Public Types | |
| typedef DtReaderWriter *(* | DtRWCreatorFcn )(const DtString &name, DtReaderWriterRegistry *parentRegistry) |
| typedef void(* | DtRWCopyFcn )(const DtReaderWriter *source, DtReaderWriter *dest) |
| typedef int(* | DtRwGetSizeFcn )(const DtReaderWriter *source) |
| typedef bool(* | DtRwCompareFcn )(const DtReaderWriter *lhs, const DtReaderWriter *rhs) |
| typedef char *(* | DtRwEncodeFcn )(const DtReaderWriter *source, char *) |
| typedef const char *(* | DtRwDecodeFcn )(DtReaderWriter *source, const char *) |
| typedef std::map< DtString, DtRwFunctions > | DtRwFunctionMap |
Public Member Functions | |
| DtReaderWriterFactory (bool registerDefaults=true) | |
| virtual const std::set < DtString > & | xmlTypes () const |
| virtual DtString | mapXmlToRwType (const DtString &xmlType) const |
| virtual DtString | mapRwToXmlType (const DtString &rwType) const |
| virtual DtReaderWriter * | createItem (const DtString &type, const DtString &name, DtReaderWriterRegistry *parentRegistry) const |
| virtual bool | copyReaderWriter (const DtReaderWriter *sourceRw, DtReaderWriter *destRw) const |
| virtual bool | compareReaderWriter (const DtReaderWriter *sourceRw, const DtReaderWriter *destRw) const |
| virtual DtReaderWriter * | cloneReaderWriter (const DtString &name, const DtReaderWriter *sourceRw, DtReaderWriterRegistry *parentRegistry) const |
| void | addDefaultRwCreators () |
| template<typename T_RWType > | |
| void | registerType (const DtString &rwTypeString) |
| template<typename T_RWType > | |
| void | registerNumericType (const DtString &rwTypeString) |
| template<typename T_RWType > | |
| void | registerTypeWithoutSerialization (const DtString &rwTypeString) |
| const DtRwFunctionMap & | functionMap () const |
| bool | typeRegistered (const DtString &rwTypeString) const |
| virtual int | getSize (const DtReaderWriter *) const |
| virtual char * | encode (const DtReaderWriter *, char *) const |
| virtual const char * | decode (DtReaderWriter *, const char *) |
Protected Types | |
| typedef std::map< DtString, DtString > | StringMap |
Protected Member Functions | |
| virtual void | mapRwToXml (const DtString &rwType, const DtString &xmlType) |
Static Protected Member Functions | |
| template<typename T_RWType > | |
| static DtReaderWriter * | createRWType (const DtString &name, DtReaderWriterRegistry *parentRegistry) |
| template<typename T_RWType > | |
| static void | copyRwType (const DtReaderWriter *sourceRw, DtReaderWriter *destRw) |
| template<typename T_RWType > | |
| static void | copyNumericRwType (const DtReaderWriter *sourceRw, DtReaderWriter *destRw) |
| template<typename T_RWType > | |
| static bool | compareRwType (const DtReaderWriter *sourceRw, const DtReaderWriter *destRw) |
| template<typename T_RWType > | |
| static int | getRwSize (const DtReaderWriter *sourceRw) |
| template<typename T_RWType > | |
| static char * | encodeRwType (const DtReaderWriter *sourceRw, char *buf) |
| template<typename T_RWType > | |
| static const char * | decodeRwType (DtReaderWriter *sourceRw, const char *buf) |
Protected Attributes | |
| DtRwFunctionMap | myRwFunctionMap |
| StringMap | myRwToXmlType |
| StringMap | myXmlToRwType |
| std::set< DtString > | myXmlTypes |
| typedef DtReaderWriter*(* DtReaderWriterFactory::DtRWCreatorFcn)(const DtString &name, DtReaderWriterRegistry *parentRegistry) |
| typedef void(* DtReaderWriterFactory::DtRWCopyFcn)(const DtReaderWriter *source, DtReaderWriter *dest) |
| typedef int(* DtReaderWriterFactory::DtRwGetSizeFcn)(const DtReaderWriter *source) |
| typedef bool(* DtReaderWriterFactory::DtRwCompareFcn)(const DtReaderWriter *lhs, const DtReaderWriter *rhs) |
| typedef char*(* DtReaderWriterFactory::DtRwEncodeFcn)(const DtReaderWriter *source, char *) |
| typedef const char*(* DtReaderWriterFactory::DtRwDecodeFcn)(DtReaderWriter *source, const char *) |
| typedef std::map<DtString, DtRwFunctions> DtReaderWriterFactory::DtRwFunctionMap |
|
protected |
| DtReaderWriterFactory::DtReaderWriterFactory | ( | bool | registerDefaults = true | ) |
|
virtual |
Returns all the xml types.
Maps the xml type to reader/writer type.
Maps the reader/writer type to xml type.
|
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.
Referenced by DtVrfXmlUtils::CreateRwObject(), and DtVariableParameterReaderWriter< _Container >::createRwStructure().
|
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 |
Uses the operator== method on the RW objects to check for equality.
Referenced by DtUiTableWidgetItem::data().
|
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)
Referenced by makVrf::DtStatePropertiesStateComponentData::copyOnlPublishedStateProperties(), and DtVariableParameterReaderWriter< _Container >::DtVariableParameterReaderWriter().
| void DtReaderWriterFactory::addDefaultRwCreators | ( | ) |
Non-virtual since it is called by the constructor. Registers all the default VRF RW object types with the factory.
| 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.
| void DtReaderWriterFactory::registerNumericType | ( | const DtString & | rwTypeString | ) |
Registers a new RW numeric 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.
Numeric types will allow integers/reals to be assigned to each other whereas the struct register above will not
| void DtReaderWriterFactory::registerTypeWithoutSerialization | ( | const DtString & | rwTypeString | ) |
Registers type without buffer serialization.
| const DtRwFunctionMap& DtReaderWriterFactory::functionMap | ( | ) | const |
Returns true if the specific type is registered.
|
virtual |
|
virtual |
Encodes the variable bindings into the supplied buffer.
|
virtual |
Decodes the variable bindings from the specified buffer.
|
protectedvirtual |
Maps rw to xml type. If xml type already exists mapping is ignored.
|
staticprotected |
Templated utility function that acts as a creator for the specified reader writer type.
|
staticprotected |
Templated utility function that copies values from one RW to another.
|
staticprotected |
Templated utility function that copies numeric values from one RW to another.
|
staticprotected |
Templated utility function that copies values from one RW to another.
|
staticprotected |
Templated utility function that gets the size of the reader/writer item.
|
staticprotected |
Templated utility function that encodes the reader/writer item.
|
staticprotected |
Templated utility function that decodes the reader/writer item.
|
protected |
|
protected |
|
protected |
|
protected |