VR-Forces 4.1.1 Class Documentation
List of all members | 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]

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)
- Public Member Functions inherited from makVrv::DtKeywordMixin
 DtKeywordMixin ()
 CTOR.
virtual ~DtKeywordMixin ()
 DTOR.
virtual void addKeyword (const std::string &keyword)
 Add a keyword.
virtual void removeKeyword (const std::string &keyword)
 Remove a keyword.
virtual void clearKeywords ()
 Clear the keywords.
virtual const std::set
< std::string > & 
keywords () const
 Get the keywords.
virtual bool findKeywords (const std::set< std::string > &) const
 Check to see if the class 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.
virtual bool findKeyword (const std::string &word) const
 Check to see if a single keyword is in the set.

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
- Protected Attributes inherited from makVrv::DtKeywordMixin
std::set< std::string > myKeywords

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.
makVrv::DtModelDefinition::DtModelDefinition ( const DtModelDefinition copy)

CCTOR.

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

Create a copy but with a new name.

makVrv::DtModelDefinition::~DtModelDefinition ( )

DTOR.

Member Function Documentation

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

Assignment operator.

Warning
The internal cache is not copied and is retained.
virtual void makVrv::DtModelDefinition::getRecord ( makArchives::DtModelDefinitionRecord rec)
virtual

Fill out a record with the current info.

virtual void makVrv::DtModelDefinition::setFromRecord ( const makArchives::DtModelDefinitionRecord rec)
virtual

Populate from a record.

DT_DECLARE_serialize_FUNCTIONS DT_DECLARE_PORTABLE_serialize_FUNCTIONS void makVrv::DtModelDefinition::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);.

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.

DtVirtualBaseClass* makVrv::DtModelDefinition::findCachedData ( const std::string &  name)

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.
const ParameterMap& makVrv::DtModelDefinition::parameters ( ) const

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.

void makVrv::DtModelDefinition::setPersistent ( bool  persistent)

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

bool makVrv::DtModelDefinition::persistent ( ) const

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

bool makVrv::DtModelDefinition::modified ( ) const

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

void makVrv::DtModelDefinition::setModified ( bool  )
static std::string makVrv::DtModelDefinition::cleanName ( const std::string &  name)
staticprotected

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 
)
inlineprotected

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
SerializableParameterMap makVrv::DtModelDefinition::myParameters
protected
CacheMap makVrv::DtModelDefinition::myRuntimeCache
protected

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

Do not serialize these members:

bool makVrv::DtModelDefinition::myPersistentFlag
protected
bool makVrv::DtModelDefinition::myModifiedFlag
protected

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

Document ID: Generated on Mon Apr 8 19:24:01 EDT 2013 from SVN revision 125877
Copyright © 2005-2013 VT MÄK. All Rights Reserved (www.mak.com)