VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
List of all members | Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Private Member Functions | Friends
makVrv::DtModelDefinitionManager Class Reference

The model definition manager is responsible to managing all of the model definitions the IG knows about. It will save and load definitions to/from files.

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

Public Types

typedef std::map< std::string,
DtModelDefinition > 
DefinitionMap
 

Public Member Functions

virtual ~DtModelDefinitionManager ()
 
virtual void loadDefinitions ()
 
virtual bool skipDefaultDefinitions ()
 
virtual void saveDefinitions ()
 
virtual void saveAllDefinitions ()
 
virtual void saveDefinitions (const std::string &)
 
virtual void addDefinition (const DtModelDefinition &definition, bool autoSave=true)
 
virtual void destroyDefinition (const DtModelDefinition &def)
 
const DtModelDefinition * findDefinition (const std::string &modelName) const
 
DtModelDefinition * findDefinitionNonConst (const std::string &modelName)
 
const DefinitionMap & definitions () const
 
DefinitionMap & definitions ()
 
void renameDefinition (const std::string &oldModelName, const std::string &newModelName)
 
const std::string & modelFilename () const
 
void setModelFilename (const std::string &extension)
 
bool modelInstancingEnabled () const
 
void setModelInstancingEnabled (bool enabled)
 
void clearModelInstancingCache ()
 
void clear ()
 
virtual void merge (const DtModelDefinitionManager &)
 
virtual bool loadModelDefinitions (const std::string &filename, bool merge=true)
 
virtual bool loadModelDefinition (const std::string &filename)
 
virtual bool exportToFile (const std::vector< std::string > &defs, const std::string &filename) const
 
virtual bool schemaInUse (const std::string &) const
 
virtual bool schemaInUse (const std::string &, std::vector< std::string > &) const
 
virtual void backup ()
 
virtual bool mergeModelDefinitions (const std::string &fileOrDirName)
 
virtual bool modifiedSinceStartup ()
 
virtual void addToModifiedDefinitionsMap (DtModelDefinition modelDefinition)
 
virtual void addToAddedDefinitionsMap (DtModelDefinition modelDefinition)
 
virtual void addToDeletedDefinitionsMap (DtModelDefinition modelDefinition)
 
virtual void resetModifiedFlags ()
 
virtual int getNumOfDefinitionsExcludeTerrain ()
 
const DtSettingsBackup * settingsBackup () const
 
DtSettingsBackup * settingsBackup ()
 
virtual DtModelDefinitionManager & operator= (const DtModelDefinitionManager &)
 
void setAutoSave (bool b)
 
bool autoSave () const
 
virtual void removeNonPersistentItems ()
 
DtModelDefinitionLease acquireLease (const std::string &modelName, const DtModelLoadParams &modelLoadParams)
 
void releaseLease (const std::string &modelName)
 
boost::recursive_mutex & modelDefinitionLoadingMutex (const std::string &filename, DtModelDefinition &definition)
 
int activeLeaseCount ()
 
int pendingDestroyCount ()
 

Static Public Member Functions

static bool getFloatParameterValueFromDefinition (const std::string &paramName, const DtModelDefinition &definition, float &result)
 
static bool getVectorParameterValueFromDefinition (const std::string &paramName, const DtModelDefinition &definition, float(&result)[3])
 
static bool getColorParameterValueFromDefinition (const std::string &paramName, const DtModelDefinition &definition, float(&result)[4])
 

Protected Types

typedef std::map< std::string,
std::shared_ptr
< boost::recursive_mutex > > 
ModelLoadingMutexMap
 

Protected Member Functions

 DtModelDefinitionManager (DtDe &)
 
 DtModelDefinitionManager (const DtModelDefinitionManager &)
 
virtual std::string normalizeModelKey (const std::string &modelKey) const
 
void slot_preTick (DtDe &de)
 
boost::recursive_mutex & modelLoadingMutex (const std::string &filename)
 
template<typename Archive >
void serialize (Archive &ar, unsigned int version)
 

Protected Attributes

DtDe & myDe
 
DefinitionMap myDefinitions
 
std::string myModelFileName
 
std::string myModelFileExtension
 
bool myAutoSave
 
DtSignalConnectionManager myConnectionManager
 
bool myModelInstancingFlag
 
DtModelDefinitionManagerSignaler & mySignaler
 
DtModelDefinitionManagerBackup * myBackup
 
int myStartupNumOfDefinition
 
DefinitionMap myModifiedDefinitions
 
DefinitionMap myAddedDefinitions
 
DefinitionMap myDeletedDefinitions
 
boost::mutex myLeaseMutex
 
std::map< std::string, int > myLeaseCounts
 
std::set< std::string > myPendingDestroyNames
 
std::vector< std::string > myReadyToDestroyNames
 
boost::mutex myModelLoadingMutexMapMutex
 
ModelLoadingMutexMap myModelLoadingMutexByFilename
 

Private Member Functions

bool loadModelDefinitionsFromXML (const std::string &filename, bool shouldMerge)
 
bool loadModelDefinitionsFromBinary (const std::string &filename, bool shouldMerge)
 

Friends

class DtModelDefinitionManagerCreator
 
class DtModelDefinitionManagerBackup
 
class boost::serialization::access
 

Member Typedef Documentation

typedef std::map<std::string, std::shared_ptr<boost::recursive_mutex> > makVrv::DtModelDefinitionManager::ModelLoadingMutexMap
protected

Constructor & Destructor Documentation

virtual makVrv::DtModelDefinitionManager::~DtModelDefinitionManager ( )
virtual

DTOR.

makVrv::DtModelDefinitionManager::DtModelDefinitionManager ( DtDe &  )
protected

CTOR.

makVrv::DtModelDefinitionManager::DtModelDefinitionManager ( const DtModelDefinitionManager &  )
protected

Member Function Documentation

static bool makVrv::DtModelDefinitionManager::getFloatParameterValueFromDefinition ( const std::string &  paramName,
const DtModelDefinition &  definition,
float &  result 
)
static

Utility function for reading a float for the specified attribute, by name, from the provided model definition. This function returns true if the float parameter value was successfully retrieved from the provided model definition. False otherwise.

static bool makVrv::DtModelDefinitionManager::getVectorParameterValueFromDefinition ( const std::string &  paramName,
const DtModelDefinition &  definition,
float(&)  result[3] 
)
static

Utility function for reading a Vec3 for the specified attribute, by name, from the provided model definition. This function returns true if the Vec3 parameter value was successfully retrieved from the provided model definition. False otherwise.

static bool makVrv::DtModelDefinitionManager::getColorParameterValueFromDefinition ( const std::string &  paramName,
const DtModelDefinition &  definition,
float(&)  result[4] 
)
static

Utility function for reading a Vec4 for the specified attribute, by name, from the provided model definition. This function returns true if the Vec4 parameter value was successfully retrieved from the provided model definition. False otherwise.

virtual void makVrv::DtModelDefinitionManager::loadDefinitions ( )
virtual

Load all the models in a given directory.

virtual bool makVrv::DtModelDefinitionManager::skipDefaultDefinitions ( )
virtual

Should we skip the default model definitions for example, if –noAppDataModelDefs is on the command line.

virtual void makVrv::DtModelDefinitionManager::saveDefinitions ( )
virtual

Save all of the model definitions to a directory.

virtual void makVrv::DtModelDefinitionManager::saveAllDefinitions ( )
virtual

Saves out all model definitions to each of of their perspective file locations.

virtual void makVrv::DtModelDefinitionManager::saveDefinitions ( const std::string &  )
virtual

Run through all files in directory and assign the matching definitions to each file.

virtual void makVrv::DtModelDefinitionManager::addDefinition ( const DtModelDefinition &  definition,
bool  autoSave = true 
)
virtual

Add a model definition. The definition itself will only be copied. If autoSave is true and myAutoSave is true, saves out definitions to file.

Exceptions
DtInvalidInputif the definition's name is empty.
virtual void makVrv::DtModelDefinitionManager::destroyDefinition ( const DtModelDefinition &  def)
virtual

Remove and destroy a definition. If the definition is currently leased by a background thread, the destruction is deferred until all leases are released.

Warning
Any pointers to the model definition will be invalid after the definition is actually destroyed.
const DtModelDefinition* makVrv::DtModelDefinitionManager::findDefinition ( const std::string &  modelName) const

Find a a model definition.

Warning
The pointer returned should never be deleted, or cached.
Return values
0If no definition with the input name is found.
DtModelDefinition* makVrv::DtModelDefinitionManager::findDefinitionNonConst ( const std::string &  modelName)

Typically, we don't modify model definitions stored in our map. There are some places we do. So, use this function, so that the intent is clear.

const DefinitionMap& makVrv::DtModelDefinitionManager::definitions ( ) const

Get a const ref to the map of definitions used for iteration.

DefinitionMap& makVrv::DtModelDefinitionManager::definitions ( )
void makVrv::DtModelDefinitionManager::renameDefinition ( const std::string &  oldModelName,
const std::string &  newModelName 
)

renames model definition

const std::string& makVrv::DtModelDefinitionManager::modelFilename ( ) const

Set the model filename. The default is "Model Definitions.ommx".

void makVrv::DtModelDefinitionManager::setModelFilename ( const std::string &  extension)

Set the model filename.

bool makVrv::DtModelDefinitionManager::modelInstancingEnabled ( ) const

Set if model instance sharing is enabled.

void makVrv::DtModelDefinitionManager::setModelInstancingEnabled ( bool  enabled)

Set if model instance sharing is enabled.

void makVrv::DtModelDefinitionManager::clearModelInstancingCache ( )

Clears the cache of all model definitions.

void makVrv::DtModelDefinitionManager::clear ( )

Clears out entire manager.

virtual void makVrv::DtModelDefinitionManager::merge ( const DtModelDefinitionManager &  )
virtual

Merges contents of supplied model definition manager into this one. Model definitions that exist will be replaced by model definitions in the merging manager. Ones that do not exist will be added. No model definitions will be removed as part of this operation.

virtual bool makVrv::DtModelDefinitionManager::loadModelDefinitions ( const std::string &  filename,
bool  merge = true 
)
virtual

Load a specific model definition manager file.

Return values
trueif the model was loaded.
falseif the model definition manager file was not loaded (if the file was unable to be opened). When the load is complete, and merge is true, will call merge on the resultant model definition manager to place contents into this manager
virtual bool makVrv::DtModelDefinitionManager::loadModelDefinition ( const std::string &  filename)
virtual

Load a specific model file.

Return values
trueif the model was loaded.
falseif the model was not loaded (if the file was unable to be opened)
virtual bool makVrv::DtModelDefinitionManager::exportToFile ( const std::vector< std::string > &  defs,
const std::string &  filename 
) const
virtual

Exports the named definitions to the specified file. The file can then be imported via the loadModelDefinitions() method.

virtual bool makVrv::DtModelDefinitionManager::schemaInUse ( const std::string &  ) const
virtual

Returns true if the schema is in use by and model definition.

virtual bool makVrv::DtModelDefinitionManager::schemaInUse ( const std::string &  ,
std::vector< std::string > &   
) const
virtual
Returns
true if schema is in use and the vector of model defs for those that do
virtual void makVrv::DtModelDefinitionManager::backup ( )
virtual

Backs up model definitions to backup manager.

Reimplemented in DtVrfModelDefinitionManager.

virtual bool makVrv::DtModelDefinitionManager::mergeModelDefinitions ( const std::string &  fileOrDirName)
virtual

merge in model definitions from a file or directory

virtual bool makVrv::DtModelDefinitionManager::modifiedSinceStartup ( )
virtual

return whether the model definitions have modified since start up

virtual void makVrv::DtModelDefinitionManager::addToModifiedDefinitionsMap ( DtModelDefinition  modelDefinition)
virtual

add a model definition to the modifiedDefinitions map

virtual void makVrv::DtModelDefinitionManager::addToAddedDefinitionsMap ( DtModelDefinition  modelDefinition)
virtual

add a model definition to the addedDefinitions map

virtual void makVrv::DtModelDefinitionManager::addToDeletedDefinitionsMap ( DtModelDefinition  modelDefinition)
virtual

add a model definition to the deletedDefinitions map

virtual void makVrv::DtModelDefinitionManager::resetModifiedFlags ( )
virtual

reset the flags about the modification after you have save it.

virtual int makVrv::DtModelDefinitionManager::getNumOfDefinitionsExcludeTerrain ( )
virtual

exclude the definition that has terrain schema

const DtSettingsBackup* makVrv::DtModelDefinitionManager::settingsBackup ( ) const
inline
DtSettingsBackup* makVrv::DtModelDefinitionManager::settingsBackup ( )
inline
virtual DtModelDefinitionManager& makVrv::DtModelDefinitionManager::operator= ( const DtModelDefinitionManager &  )
virtual

Assignment operator.

void makVrv::DtModelDefinitionManager::setAutoSave ( bool  b)
inline

Sets whether or not to automatically save model definition manager on any change. Default is true.

bool makVrv::DtModelDefinitionManager::autoSave ( ) const
inline
virtual void makVrv::DtModelDefinitionManager::removeNonPersistentItems ( )
virtual

Removes items that are not persistent. These items should not be saved to disk or backed-up.

DtModelDefinitionLease makVrv::DtModelDefinitionManager::acquireLease ( const std::string &  modelName,
const DtModelLoadParams &  modelLoadParams 
)

Acquires a lease on the named model definition. Increments the use-count and captures the "filename" parameter atomically under the internal mutex. Returns an invalid lease if no definition with that name exists.

Parameters
modelNameThe name of the definition to lease.
modelLoadParamsParameters pre-captured on the main thread via DtLoaderHandle. Stored in the lease so the background thread never needs to call findParameter() on the live definition.
void makVrv::DtModelDefinitionManager::releaseLease ( const std::string &  modelName)

Releases a lease previously acquired via acquireLease(). Called automatically by DtModelDefinitionLease::release(). If a destroy was deferred while this lease was held and this is the last lease, the destruction is completed here.

boost::recursive_mutex& makVrv::DtModelDefinitionManager::modelDefinitionLoadingMutex ( const std::string &  filename,
DtModelDefinition &  definition 
)

Returns the recursive mutex that serializes background loads for the given filename. The mutex is shared across all definitions that reference the same file, and outlives individual definitions. If the filename is empty, returns a mutex specific to the definition itself, which also outlives background loads of that definition.

Parameters
filenameThe filename for which to get the loading mutex. If empty, the mutex specific to the definition is returned.
definitionThe definition for which to get the loading mutex. This is the fallback case when the filename is empty.
int makVrv::DtModelDefinitionManager::activeLeaseCount ( )

Returns the total number of leases currently held by background threads. A non-zero value during normal loading is expected; a value stuck above zero after cleanup() completes indicates a lease was not released.

int makVrv::DtModelDefinitionManager::pendingDestroyCount ( )

Returns the number of definitions whose destruction was deferred because a background thread held a lease when destroyDefinition() was called. This count should drop to zero by the next preTick() after all leases clear.

virtual std::string makVrv::DtModelDefinitionManager::normalizeModelKey ( const std::string &  modelKey) const
protectedvirtual

Normalizes a filename key for use in the model loading mutex map. Resolves to an absolute path and lowercases on Windows. Override to customize key normalization.

void makVrv::DtModelDefinitionManager::slot_preTick ( DtDe &  de)
protected

Processes any definition destructions that were deferred because a background thread held a lease during a destroyDefinition() call. Connected to DtDe::signal_preTick – always runs on the main thread.

boost::recursive_mutex& makVrv::DtModelDefinitionManager::modelLoadingMutex ( const std::string &  filename)
protected

Returns the recursive mutex that serializes background loads for the given filename. The mutex is shared across all definitions that reference the same file, and outlives individual definitions.

template<typename Archive >
void makVrv::DtModelDefinitionManager::serialize ( Archive &  ar,
unsigned int  version 
)
inlineprotected
bool makVrv::DtModelDefinitionManager::loadModelDefinitionsFromXML ( const std::string &  filename,
bool  shouldMerge 
)
private
bool makVrv::DtModelDefinitionManager::loadModelDefinitionsFromBinary ( const std::string &  filename,
bool  shouldMerge 
)
private

Friends And Related Function Documentation

friend class DtModelDefinitionManagerCreator
friend
friend class DtModelDefinitionManagerBackup
friend
friend class boost::serialization::access
friend

Member Data Documentation

DtDe& makVrv::DtModelDefinitionManager::myDe
protected
DefinitionMap makVrv::DtModelDefinitionManager::myDefinitions
protected
std::string makVrv::DtModelDefinitionManager::myModelFileName
protected
std::string makVrv::DtModelDefinitionManager::myModelFileExtension
protected
bool makVrv::DtModelDefinitionManager::myAutoSave
protected
DtSignalConnectionManager makVrv::DtModelDefinitionManager::myConnectionManager
protected
bool makVrv::DtModelDefinitionManager::myModelInstancingFlag
protected
DtModelDefinitionManagerSignaler& makVrv::DtModelDefinitionManager::mySignaler
protected
DtModelDefinitionManagerBackup* makVrv::DtModelDefinitionManager::myBackup
protected
int makVrv::DtModelDefinitionManager::myStartupNumOfDefinition
protected
DefinitionMap makVrv::DtModelDefinitionManager::myModifiedDefinitions
protected
DefinitionMap makVrv::DtModelDefinitionManager::myAddedDefinitions
protected
DefinitionMap makVrv::DtModelDefinitionManager::myDeletedDefinitions
protected
boost::mutex makVrv::DtModelDefinitionManager::myLeaseMutex
protected
std::map<std::string, int> makVrv::DtModelDefinitionManager::myLeaseCounts
protected
std::set<std::string> makVrv::DtModelDefinitionManager::myPendingDestroyNames
protected
std::vector<std::string> makVrv::DtModelDefinitionManager::myReadyToDestroyNames
protected
boost::mutex makVrv::DtModelDefinitionManager::myModelLoadingMutexMapMutex
protected
ModelLoadingMutexMap makVrv::DtModelDefinitionManager::myModelLoadingMutexByFilename
protected

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

Document ID: Generated on Thu Oct 15 21:27:02 EDT 2026 from SVN revision 296421
Copyright © 2005-2026 MAK Technologies. All Rights Reserved (www.mak.com)