![]() |
VR-Forces Developer's Guide
|
Accumulates definition cache entries produced by a background load.
A background thread calls add() to record (name, data) pairs that would otherwise be written directly to DtModelDefinition via setCachedData(). The payload is then transferred to the main thread, where commitTo() writes each entry into the definition. This ensures setCachedData() is always called on the main thread, eliminating the need to hold the per-filename loading mutex across the cache write.
Ownership: this object owns all data pointers added to it until commitTo() is called. If the object is destroyed before commitTo(), all remaining data pointers are deleted to prevent leaks.
Public Member Functions | |
| DtDefinitionCachePayload (const std::string &definitionName) | |
| ~DtDefinitionCachePayload () | |
| DtDefinitionCachePayload (const DtDefinitionCachePayload &)=delete | |
| DtDefinitionCachePayload & | operator= (const DtDefinitionCachePayload &)=delete |
| void | add (const std::string &name, DtVirtualBaseClass *data) |
| void | commitTo (DtModelDefinition &definition) |
| const std::string & | definitionName () const |
| bool | empty () const |
Private Attributes | |
| std::string | myDefinitionName |
| std::vector< std::pair < std::string, DtVirtualBaseClass * > > | myEntries |
|
explicit |
CTOR.
| definitionName | The name of the DtModelDefinition that owns this payload. Used by the main thread to look up the definition before calling commitTo(). |
| makVrv::DtDefinitionCachePayload::~DtDefinitionCachePayload | ( | ) |
DTOR. Deletes any data pointers that were not committed.
|
delete |
|
delete |
| void makVrv::DtDefinitionCachePayload::add | ( | const std::string & | name, |
| DtVirtualBaseClass * | data | ||
| ) |
Adds a (name, data) pair to the payload. Ownership of data is transferred to this object. Passing a null data pointer is valid and records an explicit clear.
| void makVrv::DtDefinitionCachePayload::commitTo | ( | DtModelDefinition & | definition | ) |
Commits all entries to the given definition via setCachedData(), then clears the internal list. Safe to call only on the main thread.
| const std::string& makVrv::DtDefinitionCachePayload::definitionName | ( | ) | const |
Returns the definition name supplied at construction.
| bool makVrv::DtDefinitionCachePayload::empty | ( | ) | const |
Returns true if no entries have been added.
|
private |
|
private |