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

A model definition Interaction any number of named parameters, and also can be used to store cached data. More...

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

List of all members.

Classes

class  SerializableParameterMap

Public Types

typedef std::map< std::string,
std::string > 
ParameterMap

Public Member Functions

 DtModelDefinition (const std::string &modelName="")
 CTOR.
 DtModelDefinition (const DtModelDefinition &copy)
 CCTOR.
 DtModelDefinition (const std::string &modelName, const DtModelDefinition &copy)
 Create a copy but with a new name.
 ~DtModelDefinition ()
 DTOR.
DtModelDefinitionoperator= (const DtModelDefinition &)
 Assignment operator.
virtual void getRecord (makArchives::DtModelDefinitionRecord &rec)
 Fill out a record with the current info.
virtual void setFromRecord (const makArchives::DtModelDefinitionRecord &rec)
 Populate from a record.
DT_DECLARE_serialize_FUNCTIONS
DT_DECLARE_PORTABLE_serialize_FUNCTIONS
void 
clearCache ()
 Declare serialize functions Call via serialize(Archive ar, unsigned int version); Where Archive can be any of : xml_oarchive,xml_iarchive,binary_oarchive, portable_binary_oarchive, binary_iarchive, portable_binary_iarchive,text_oarchive, or text_iarchive example: fstream fo("test.xml",std;:ios_base::out); xml_oarchive os(fo); DtModelDefinition aDef; aDef.serialize(os,0);.
DtVirtualBaseClassfindCachedData (const std::string &name)
 Lookup cached data.
void setCachedData (const std::string &name, DtVirtualBaseClass *data)
 Adds a data member to the cache.
void deleteCachedData (const std::string &name)
 Helper function for deleting cache.
void setParameter (const std::string &parameterName, const std::string &parameterValue)
 Set a parameter's value, if the parameter does not exist a new parameter will be created.
bool clearParameter (const std::string &parameterName)
 Completely remove a parameter.
const std::string & parameter (const std::string &parameterName) const
 Helper function for getting a parameter, not that if the parameter is not found an empty string is returned which is does not indicate if the parameter is found or is simply not set.
const std::string * findParameter (const std::string &parameterName) const
 Find a parameter.
std::string * findParameter (const std::string &parameterName)
 Find a parameter The parameter name is NOT case sensitive, ie Param == PARAM == param.
const ParameterMapparameters () const
 Get the parameters.
const std::string & name () const
 Get the model name.
const std::string & schema () const
 Get the schema string.
void setSchema (const std::string &schemaStr)
 Set the schema string.
void setPersistent (bool persistent)
 Set that the model definition is persistent aka it is saved to disk.
bool persistent () const
 Is this a persistent definition (aka does it exist on disk).
bool modified () const
 Has this definition been modified (after it was loaded from disk).
void setModified (bool)

Static Public Attributes

static const std::string theEmptyString

Protected Types

typedef boost::unordered_map
< std::string,
DtVirtualBaseClass * > 
CacheMap

Protected Member Functions

template<typename Archive >
void _serialize (Archive &ar, unsigned int version)

Static Protected Member Functions

static std::string cleanName (const std::string &name)
 Add a keyword.

Protected Attributes

std::string myName
std::string mySchema
SerializableParameterMap myParameters
CacheMap myRuntimeCache
 std::set<std::string> myKeywords;
bool myPersistentFlag
bool myModifiedFlag

Detailed Description

A model definition Interaction any number of named parameters, and also can be used to store cached data.

The model definition will own all of it's cached data


Member Typedef Documentation

typedef std::map<std::string,std::string> makVrv::DtModelDefinition::ParameterMap
typedef boost::unordered_map<std::string,DtVirtualBaseClass*> makVrv::DtModelDefinition::CacheMap [protected]

Constructor & Destructor Documentation

makVrv::DtModelDefinition::DtModelDefinition ( const std::string &  modelName = "")

CTOR.

Warning:
, it is invalid to create a model without a name. A default CTOR is required for storage in a map. The DtModelDefinitionManager will throw exceptions if a model has no name.

CCTOR.

makVrv::DtModelDefinition::DtModelDefinition ( const std::string &  modelName,
const DtModelDefinition copy 
)

Create a copy but with a new name.

DTOR.


Member Function Documentation

DtModelDefinition& makVrv::DtModelDefinition::operator= ( const DtModelDefinition )

Assignment operator.

Warning:
The internal cache is not copied and is retained.

Fill out a record with the current info.

Populate from a record.

Declare serialize functions Call via serialize(Archive ar, unsigned int version); Where Archive can be any of : xml_oarchive,xml_iarchive,binary_oarchive, portable_binary_oarchive, binary_iarchive, portable_binary_iarchive,text_oarchive, or text_iarchive example: fstream fo("test.xml",std;:ios_base::out); xml_oarchive os(fo); DtModelDefinition aDef; aDef.serialize(os,0);.

Clear the definition's cache. All cache data is deleted. This function is dangerous to call if there are Model Instance classes using the current cached data.

Lookup cached data.

The name is case sensitive.

Return values:
0if no data is cached.
void makVrv::DtModelDefinition::setCachedData ( const std::string &  name,
DtVirtualBaseClass data 
)

Adds a data member to the cache.

If an existing data pointer is stored with that name it is deleted. The name is case sensitive. To delete cached data, pass a null pointer.

void makVrv::DtModelDefinition::deleteCachedData ( const std::string &  name) [inline]

Helper function for deleting cache.

void makVrv::DtModelDefinition::setParameter ( const std::string &  parameterName,
const std::string &  parameterValue 
)

Set a parameter's value, if the parameter does not exist a new parameter will be created.

The parameter name is NOT case sensitive, ie Param == PARAM == param. Setting a parameter to a null string does NOT remove the parameter all together i.e. calls to findParameter will return a valid pointer.

bool makVrv::DtModelDefinition::clearParameter ( const std::string &  parameterName)

Completely remove a parameter.

Calls to findParameter will return a null pointer. The parameter name is NOT case sensitive, ie Param == PARAM == param.

Returns:
if the paramter was removed.
const std::string& makVrv::DtModelDefinition::parameter ( const std::string &  parameterName) const

Helper function for getting a parameter, not that if the parameter is not found an empty string is returned which is does not indicate if the parameter is found or is simply not set.

The parameter name is NOT case sensitive, ie Param == PARAM == param.

const std::string* makVrv::DtModelDefinition::findParameter ( const std::string &  parameterName) const

Find a parameter.

The parameter name is NOT case sensitive, ie Param == PARAM == param.

Warning:
The data pointer should not be held on to and should be treated as a temporary reference (aka a local copy should be made before any other calls to the Model Definition).
Return values:
0if the parameter is not found.
std::string* makVrv::DtModelDefinition::findParameter ( const std::string &  parameterName)

Find a parameter The parameter name is NOT case sensitive, ie Param == PARAM == param.

Return values:
0if the parameter is not found.

Get the parameters.

const std::string& makVrv::DtModelDefinition::name ( ) const

Get the model name.

const std::string& makVrv::DtModelDefinition::schema ( ) const

Get the schema string.

void makVrv::DtModelDefinition::setSchema ( const std::string &  schemaStr)

Set the schema string.

Set that the model definition is persistent aka it is saved to disk.

Is this a persistent definition (aka does it exist on disk).

Has this definition been modified (after it was loaded from disk).

static std::string makVrv::DtModelDefinition::cleanName ( const std::string &  name) [static, protected]

Add a keyword.

Remove a keyword. Get the keywords. Check to see if the model definition has any of the supplied keywords. For best performance sort the keywords (from most frequent to less frequent) and for keywords with the same frequency shortest to longest.

template<typename Archive >
void makVrv::DtModelDefinition::_serialize ( Archive &  ar,
unsigned int  version 
) [inline, protected]

References DT_SERIALIZE_MEMBER.


Member Data Documentation

const std::string makVrv::DtModelDefinition::theEmptyString [static]
std::string makVrv::DtModelDefinition::myName [protected]
std::string makVrv::DtModelDefinition::mySchema [protected]

std::set<std::string> myKeywords;

Do not serialize these members:


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)