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

Handles the caching of files. Includes functions for excluding files with certain extensions from being cached, which must be set correctly for prop extraction to work.

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

Classes

struct  LoadFileOptions
 

Public Types

typedef boost::unordered_set
< std::string > 
ExcludedExtensions
 
typedef std::deque< std::string > FilePathList
 

Public Member Functions

virtual ~DtFileCache ()
 
virtual void init ()
 
virtual void initSingletonDependencies ()
 
LoadFileOptions defaultOptions () const
 
virtual bool getCachedNodeFile (const std::string &filePathIn, const FilePathList &paths, std::string &cachedFilePathOut, bool emitError)
 
virtual bool getCachedImageFile (const std::string &filePathIn, const FilePathList &paths, std::string &cachedFilePathOut, bool emitError)
 
virtual void setCachingEnabled (bool flag)
 
virtual bool acceleratedCachingEnabled () const
 
virtual void setCompressTextures (bool compress)
 
virtual bool compressTexturesEnabled () const
 
virtual void releaseResources ()
 
virtual void clearAccelerationCache ()
 
virtual void setInstancingEnabled (bool enabled)
 
virtual bool instancingEnabled () const
 
bool clearInstancesOnNewScene () const
 
void setClearInstancesOnNewScene (bool clearInstances)
 
void clearInstancingCache ()
 
void flushInstanceCache (bool multipass, bool flushNodes, bool flushTextures, bool flushImages)
 
unsigned int flushCycleCount ()
 
virtual void ts_clearInstancingCache ()
 
virtual void setFromRecord (const makArchives::DtCacheSettingsRecord &rec)
 
virtual void getRecord (makArchives::DtCacheSettingsRecord &rec) const
 
virtual void getSplitRecord (std::vector< makArchives::DtCacheSettingsRecord > &rec, std::vector< std::string > &fileNames)
 
virtual void addRecords (makArchives::DtCacheSettingsRecord &recs, makArchives::DtCacheSettingsRecord &combinedRec)
 
void loadDefaults (bool loadOnlyFactorySettings=false)
 
void saveAsDefaults ()
 
void exportSettings (const std::string &fileName)
 
void importSettings (const std::string &fileName)
 
virtual ExcludedExtensionsexcludedExtensions ()
 
bool isExcludedExtension (const std::string &ext) const
 
const
DtRecordSettingsBackupInterface
settingsBackup () const
 
DtRecordSettingsBackupInterfacesettingsBackup ()
 
DtDegetDe ()
 
virtual void ts_flushInstancingCache (bool multiPass, bool flushNodes, bool flushTextures, bool flushImages)
 
virtual bool getOrLoadTexture (DtTextureInterface *textureWrapper, const std::string &filename, const DtFileCache::LoadFileOptions &loadFileOptions)
 

Public Attributes

boost::signalslib::signal< void()> signal_clearInstanceCache
 

Protected Member Functions

virtual void autoSaveDefaultsIfNeeded ()
 
virtual bool ts_isExcludedExtension (const std::string &ext) const
 
virtual void addExcludedExtension (const std::string &ext)
 
virtual void removeExcludedExtension (const std::string &ext)
 
 DtFileCache (DtDe &de)
 
virtual bool save (const std::string &origFilename, const std::string &cachedFilename, bool optimize)
 

Protected Attributes

DtDemyDe
 
bool myCachingEnabled
 
bool myCompressTextureFlag
 
bool myClearInstancesOnNewSceneFlag
 
bool myInstancingEnabled
 
unsigned int myFlushCycleCount
 
DtSignalConnectionManager myConnectionManager
 
ExcludedExtensions myExcludedExtensionMap
 
DtRecordSettingsBackupInterfacemySettingsBackup
 

Friends

class DtFileCacheCreator
 
class DtDeSharedState
 

Member Typedef Documentation

typedef boost::unordered_set<std::string> makVrv::DtFileCache::ExcludedExtensions

A set of extensions excluded from the cache.

typedef std::deque<std::string> makVrv::DtFileCache::FilePathList

Constructor & Destructor Documentation

virtual makVrv::DtFileCache::~DtFileCache ( )
virtual

DTOR.

makVrv::DtFileCache::DtFileCache ( DtDe de)
protected

Protected CTOR. Must be called by creator.

Must call init() after constructing before use

Member Function Documentation

virtual void makVrv::DtFileCache::init ( )
virtual

Initialize the cache. Must be called before using.

virtual void makVrv::DtFileCache::initSingletonDependencies ( )
virtual

Called during initialization after the object is created and registered with de. Any singleton dependencies need to be created here to prepare for multi-threaded code.

Reimplemented in makVrv::DtOsgFileCache.

LoadFileOptions makVrv::DtFileCache::defaultOptions ( ) const

Get the current default options.

virtual bool makVrv::DtFileCache::getCachedNodeFile ( const std::string &  filePathIn,
const FilePathList paths,
std::string &  cachedFilePathOut,
bool  emitError 
)
virtual

Returns true if cachedFilePathOut contains the path to a cached version of filePathIn.

virtual bool makVrv::DtFileCache::getCachedImageFile ( const std::string &  filePathIn,
const FilePathList paths,
std::string &  cachedFilePathOut,
bool  emitError 
)
virtual

Returns true if cachedFilePathOut contains the path to a cached version of filePathIn.

virtual void makVrv::DtFileCache::setCachingEnabled ( bool  flag)
virtual

Toggle caching on or off.

virtual bool makVrv::DtFileCache::acceleratedCachingEnabled ( ) const
virtual

Returns true if caching is enabled.

virtual void makVrv::DtFileCache::setCompressTextures ( bool  compress)
virtual

Set whether all textures will be compressed. This slows down texture loading unless the input file is already compressed. Only .DDS and .MEIF files support HW compressed. JPEG, PNG etc are NOT considered compressed formats.

virtual bool makVrv::DtFileCache::compressTexturesEnabled ( ) const
virtual

Should we compress textures.

virtual void makVrv::DtFileCache::releaseResources ( )
virtual

Release all rendering resources.

Reimplemented in makVrv::DtOsgFileCache.

virtual void makVrv::DtFileCache::clearAccelerationCache ( )
virtual

Clears the cache.

virtual void makVrv::DtFileCache::setInstancingEnabled ( bool  enabled)
virtual

Sets whether model instancing is enabled.

virtual bool makVrv::DtFileCache::instancingEnabled ( ) const
virtual

Returns true if model instancing is enabled.

bool makVrv::DtFileCache::clearInstancesOnNewScene ( ) const

Returns whether to clear instances on new scene.

void makVrv::DtFileCache::setClearInstancesOnNewScene ( bool  clearInstances)

Returns whether to clear instances on new scene.

void makVrv::DtFileCache::clearInstancingCache ( )

Clear the model instance cache.

void makVrv::DtFileCache::flushInstanceCache ( bool  multipass,
bool  flushNodes,
bool  flushTextures,
bool  flushImages 
)

Removes all instances that only have 1 reference. When multipass = true, while a flush causes item[s] to be removed then another flush will be called. This allows instances that are referenced by other instances to be cleared. Async has been removed for now since it flushing this cache is not thread safe yet.

unsigned int makVrv::DtFileCache::flushCycleCount ( )

Get the flush cycle count, this is incremented each time flush instance cache is called.

virtual void makVrv::DtFileCache::ts_clearInstancingCache ( )
virtual

Clear the model instance cache.

Reimplemented in makVrv::DtOsgFileCache.

virtual void makVrv::DtFileCache::setFromRecord ( const makArchives::DtCacheSettingsRecord rec)
virtual

Set the DtFileCache state from a cache settings record.

Reimplemented in makVrv::DtOsgFileCache.

virtual void makVrv::DtFileCache::getRecord ( makArchives::DtCacheSettingsRecord rec) const
virtual

Fill out a cache settings record with the DtFileCache state.

virtual void makVrv::DtFileCache::getSplitRecord ( std::vector< makArchives::DtCacheSettingsRecord > &  rec,
std::vector< std::string > &  fileNames 
)
inlinevirtual

To support writing element definitions in folders as multiple files not implemented for DtFileCache.

virtual void makVrv::DtFileCache::addRecords ( makArchives::DtCacheSettingsRecord recs,
makArchives::DtCacheSettingsRecord combinedRec 
)
inlinevirtual

To support writing element definitions in folders as multiple files not implemented for DtFileCache.

void makVrv::DtFileCache::loadDefaults ( bool  loadOnlyFactorySettings = false)

Called from CTOR to load the default settings.

void makVrv::DtFileCache::saveAsDefaults ( )

Called to save the current settings as the default settings.

void makVrv::DtFileCache::exportSettings ( const std::string &  fileName)

Exports the current cache settings to a file.

void makVrv::DtFileCache::importSettings ( const std::string &  fileName)

Import the current cache settings from a file.

virtual ExcludedExtensions& makVrv::DtFileCache::excludedExtensions ( )
virtual

Accessor for excluded extensions.

bool makVrv::DtFileCache::isExcludedExtension ( const std::string &  ext) const
inline

Check if the extension is in the list of excluded file types.

const DtRecordSettingsBackupInterface* makVrv::DtFileCache::settingsBackup ( ) const
inline
DtRecordSettingsBackupInterface* makVrv::DtFileCache::settingsBackup ( )
inline
DtDe& makVrv::DtFileCache::getDe ( )
inline
virtual void makVrv::DtFileCache::ts_flushInstancingCache ( bool  multiPass,
bool  flushNodes,
bool  flushTextures,
bool  flushImages 
)
virtual

Thread safe call to flush the cache.

Reimplemented in makVrv::DtOsgFileCache.

virtual bool makVrv::DtFileCache::getOrLoadTexture ( DtTextureInterface textureWrapper,
const std::string &  filename,
const DtFileCache::LoadFileOptions loadFileOptions 
)
virtual

Get or load a texture to cache no-op, osg overrides param DtTextureInterface* textureWrapper the interface the texture is set on param filename file to load param loadFileOptions, options.

Reimplemented in makVrv::DtOsgFileCache.

virtual void makVrv::DtFileCache::autoSaveDefaultsIfNeeded ( )
protectedvirtual

Save the default settings if necessary.

virtual bool makVrv::DtFileCache::ts_isExcludedExtension ( const std::string &  ext) const
protectedvirtual

Thread safe call.

virtual void makVrv::DtFileCache::addExcludedExtension ( const std::string &  ext)
protectedvirtual

Add the extension to the list of excluded file types This function can only be called in the CTOR of the file cache.

virtual void makVrv::DtFileCache::removeExcludedExtension ( const std::string &  ext)
protectedvirtual

remove the extension from the list of excluded file types This function can only be called in the CTOR of the file cache.

virtual bool makVrv::DtFileCache::save ( const std::string &  origFilename,
const std::string &  cachedFilename,
bool  optimize 
)
protectedvirtual

Returns true if origFilename was successfully written out as cachedFilename.

Reimplemented in makVrv::DtOsgFileCache.

Friends And Related Function Documentation

friend class DtFileCacheCreator
friend

This allows the protected constructor to be called by the DtFileCacheCreator.

friend class DtDeSharedState
friend

This allows the de shared DtDeSharedState clear the cache.

Member Data Documentation

boost::signalslib::signal<void ()> makVrv::DtFileCache::signal_clearInstanceCache

Signal emmitted when clearCache is called, used to allow other caches to be cleared.

DtDe& makVrv::DtFileCache::myDe
protected
bool makVrv::DtFileCache::myCachingEnabled
protected
bool makVrv::DtFileCache::myCompressTextureFlag
protected
bool makVrv::DtFileCache::myClearInstancesOnNewSceneFlag
protected
bool makVrv::DtFileCache::myInstancingEnabled
protected
unsigned int makVrv::DtFileCache::myFlushCycleCount
protected
DtSignalConnectionManager makVrv::DtFileCache::myConnectionManager
protected
ExcludedExtensions makVrv::DtFileCache::myExcludedExtensionMap
protected
DtRecordSettingsBackupInterface* makVrv::DtFileCache::mySettingsBackup
protected

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

Document ID: Generated on Wed Mar 27 22:49:11 EDT 2024 from SVN revision 264633
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)