![]() |
VR-Forces Developer's Guide
|
Context object passed to DtModel::backgroundLoad().
Encapsulates all threading prerequisites for a background load:
Cache writes: backgroundLoad() implementations must NOT call definition()->setCachedData() directly. Instead, call addToPayload() to accumulate entries. The caller (DtBackgroundLoadAsyncTask or DtBackgroundLoader::executeBackgroundLoad) will commit the payload to the definition on the main thread after backgroundLoad() returns.
DtBackgroundLoadContext is constructed exclusively by DtBackgroundLoadAsyncTask::execute() and DtBackgroundLoader::executeBackgroundLoad(). It is non-copyable and non-movable – it must not outlive the lease it references.
Public Member Functions | |
| DtBackgroundLoadContext (DtModelDefinitionLease &lease) | |
| ~DtBackgroundLoadContext () | |
| DtBackgroundLoadContext (const DtBackgroundLoadContext &)=delete | |
| DtBackgroundLoadContext & | operator= (const DtBackgroundLoadContext &)=delete |
| DtBackgroundLoadContext (DtBackgroundLoadContext &&)=delete | |
| DtBackgroundLoadContext & | operator= (DtBackgroundLoadContext &&)=delete |
| DtModelDefinition * | definition () const |
| const std::string & | filename () const |
| const DtModelLoadParams & | modelLoadParams () const |
| void | addToPayload (const std::string &name, DtVirtualBaseClass *data) |
| DtDefinitionCachePayload & | payload () |
| DtDefinitionCachePayload * | extractPayload () |
Private Attributes | |
| DtModelDefinitionLease & | myLease |
| DtDefinitionCachePayload * | myPayload |
| makVrv::DtBackgroundLoadContext::DtBackgroundLoadContext | ( | DtModelDefinitionLease & | lease | ) |
| makVrv::DtBackgroundLoadContext::~DtBackgroundLoadContext | ( | ) |
DTOR. Deletes the internal payload if extractPayload() was never called.
|
delete |
|
delete |
|
delete |
|
delete |
| DtModelDefinition* makVrv::DtBackgroundLoadContext::definition | ( | ) | const |
Returns the leased DtModelDefinition.
| const std::string& makVrv::DtBackgroundLoadContext::filename | ( | ) | const |
Returns the "filename" parameter value captured at lease acquisition time. Empty if the definition has no filename parameter.
| const DtModelLoadParams& makVrv::DtBackgroundLoadContext::modelLoadParams | ( | ) | const |
Returns the pre-built DtModelLoadParams captured atomically at lease acquisition time. Safe to call from a background thread.
| void makVrv::DtBackgroundLoadContext::addToPayload | ( | const std::string & | name, |
| DtVirtualBaseClass * | data | ||
| ) |
Adds a (name, data) pair to the payload accumulated during backgroundLoad(). Ownership of data is transferred to the payload. The payload is committed to the definition on the main thread by the caller after backgroundLoad() returns.
| DtDefinitionCachePayload& makVrv::DtBackgroundLoadContext::payload | ( | ) |
Returns a reference to the internal payload for passing directly to functions that accept a DtDefinitionCachePayload*.
| DtDefinitionCachePayload* makVrv::DtBackgroundLoadContext::extractPayload | ( | ) |
Transfers ownership of the accumulated payload to the caller. Returns nullptr if no entries were added. After this call, the context no longer owns the payload and will not delete it. Called by DtBackgroundLoadAsyncTask::execute() and DtBackgroundLoader::executeBackgroundLoad() after backgroundLoad() returns.
|
private |
|
private |