VR-Forces 4.5 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
List of all members | Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Types | Protected Member Functions | Protected Attributes | Friends
makVrv::DtOsgFileCache Class Reference

The OSG implementation of makVrv::DtOsgFileCache. More...

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

Classes

class  TextureCollection

Public Member Functions

virtual ~DtOsgFileCache ()
 CTOR.
virtual void releaseResources ()
 Release all rendering resources.
virtual void releaseResources (osg::State *state)
 Release all rendering resources.
virtual void setFromRecord (const makArchives::DtCacheSettingsRecord &rec)
 Push loader options to global registry whenever they're loaded from a record.
osg::Node * readNodeFile (const std::string &inputFilename, const LoadFileOptions &loadFileOptions)
 Read a node file, provides options for controlling This is call is equivalent to osg::readNodeFile function with the options encoded in a options string.
osg::ref_ptr< osg::Node > findNodeFile (const std::string &inputFilename)
 Find a node file.
osg::Image * readImageFile (const std::string &inputFilename, const LoadFileOptions &loadFileOptions)
 Read a node file, provides options for controlling This is call is equivalent to osg::readImageFile function with the options encoded in a options string.
virtual osg::Texture * getTextureInstance (const std::string &filePath, osg::Texture::FilterMode minFilter, osg::Texture::FilterMode magFilter, osg::Texture::WrapMode s, osg::Texture::WrapMode t, const LoadFileOptions &loadFileOptions)
 Returns a cached texture instance, or a new copy of a texture if instancing is disabled; returns 0 if file failed to load.
virtual void ts_getTextureInstance (const std::string &filePath, osg::Texture::FilterMode minFilter, osg::Texture::FilterMode magFilter, osg::Texture::WrapMode s, osg::Texture::WrapMode t, const LoadFileOptions &loadFileOptions, osg::ref_ptr< osg::Texture > &texture)
 Passes back a cached texture instance, or a new copy of a texture if instancing is disabled; returns 0 if file failed to load use this instead of getTextureInstance if it is called outside the main thread.
virtual void encodeOptionsString (const LoadFileOptions &loadFileOptions, osgDB::ReaderWriter::Options &options) const
 Encode load file options into reader write options.
virtual void decodeOptions (const osgDB::ReaderWriter::Options &options, LoadFileOptions &loadFileOptions) const
 Decode reader write options into load file options.
DtMetaFileManagermetaFileManager ()
 Retrieve the Metafile manager (load, parse .meta files)
const DtOsgShaderManagershaderManager (void) const
DtOsgShaderManagershaderManager (void)
const DtOsgShaderFilesCacheshaderFilesCache (void) const
DtEffectControllerFactoryeffectControllerFactory (void) const
- Public Member Functions inherited from makVrv::DtFileCache
virtual ~DtFileCache ()
 DTOR.
virtual void init ()
 Initialize the cache. Must be called before using.
LoadFileOptions defaultOptions () const
 Get the current default options.
virtual bool getCachedNodeFile (const std::string &filePathIn, const FilePathList &paths, std::string &cachedFilePathOut, bool emitError)
 Returns true if cachedFilePathOut contains the path to a cached version of filePathIn.
virtual bool getCachedImageFile (const std::string &filePathIn, const FilePathList &paths, std::string &cachedFilePathOut, bool emitError)
 Returns true if cachedFilePathOut contains the path to a cached version of filePathIn.
virtual void setCachingEnabled (bool flag)
 Toggle caching on or off.
virtual bool acceleratedCachingEnabled () const
 Returns true if caching is enabled.
virtual void setCompressTextures (bool compress)
 Set whether all textures will be compressed.
virtual bool compressTexturesEnabled () const
 Should we compress textures.
virtual void clearAccelerationCache ()
 Clears the cache.
virtual void setInstancingEnabled (bool enabled)
 Sets whether model instancing is enabled.
virtual bool instancingEnabled () const
 Returns true if model instancing is enabled.
bool clearInstancesOnNewScene () const
 Returns whether to clear instances on new scene.
void setClearInstancesOnNewScene (bool clearInstances)
 Returns whether to clear instances on new scene.
void clearInstancingCache ()
 Clear the model instance cache.
void flushInstanceCache (bool multipass, bool flushNodes, bool flushTextures, bool flushImages)
 Removes all instances that only have 1 reference.
unsigned int flushCycleCount ()
 Get the flush cycle count, this is incremented each time flush instance cache is called.
virtual void getRecord (makArchives::DtCacheSettingsRecord &rec)
 Fill out a cache settings record with the DtFileCache state.
virtual void getSplitRecord (std::vector< makArchives::DtCacheSettingsRecord > &rec, std::vector< std::string > &fileNames)
 To support writing element definitions in folders as multiple files not implemented for DtFileCache.
virtual void addRecords (makArchives::DtCacheSettingsRecord &recs, makArchives::DtCacheSettingsRecord &combinedRec)
 To support writing element definitions in folders as multiple files not implemented for DtFileCache.
void loadDefaults (bool loadOnlyFactorySettings=false)
 Called from CTOR to load the default settings.
void saveAsDefaults ()
 Called to save the current settings as the default settings.
void exportSettings (const std::string &fileName)
 Exports the current cache settings to a file.
void importSettings (const std::string &fileName)
 Import the current cache settings from a file.
virtual ExcludedExtensionsexcludedExtensions ()
 Accessor for excluded extensions.
bool isExcludedExtension (const std::string &ext) const
 Check if the extension is in the list of excluded file types.
const
DtRecordSettingsBackupInterface
settingsBackup () const
DtRecordSettingsBackupInterfacesettingsBackup ()

Static Public Member Functions

static void optimizeNodeGeometry (osg::Node *node)
 Run extra optimization passes on node.

Public Attributes

boost::signals2::signal< void(osg::Node
*, const std::string
&origFileName, const
std::string &actualFileName)> 
signal_nodeFileLoaded
 Signal emitted whenever a Node file is loaded from disk.
boost::signals2::signal< void(osg::Image
*, const std::string
&origFileName, const
std::string &actualFileName)> 
signal_imageFileLoaded
 Signal emitted whenever an image file is loaded from disk.
boost::signals2::signal< void(const
std::string &filename,
osgDB::ReaderWriter::ReadResult
&, const
osgDB::ReaderWriter::Options *)> 
signal_readNodeCallback
 Signaled emitted when osg calls readNodeFile.
boost::signals2::signal< void(const
std::string &filename,
osgDB::ReaderWriter::ReadResult
&, const
osgDB::ReaderWriter::Options *)> 
signal_readImageCallback
 Signaled emitted when osg calls readImageFile.
- Public Attributes inherited from makVrv::DtFileCache
boost::signal< void()> signal_clearInstanceCache
 Signal emmitted when clearCache is called, used to allow other caches to be cleared.

Protected Types

typedef boost::unordered_map
< std::string, std::string > 
RelativePathCache

Protected Member Functions

virtual osg::ref_ptr< osg::Node > ts_readNodeFile (const std::string &inputFilename, const LoadFileOptions &loadFileOptions, const osg::UserDataContainer *optionsUserData)
 Thread safe Implementation of readNodeFile.
virtual osg::ref_ptr< osg::Node > ts_findNodeFile (const std::string &inputFilename)
 Thread safe Implementation of findNodeFile.
virtual osg::ref_ptr< osg::Image > ts_readImageFile (const std::string &inputFilename, const LoadFileOptions &loadFileOptions, const osg::UserDataContainer *optionsUserData=0L)
 Thread safe Implementation of readImageFile.
void ts_encryptImage (const std::string &inputFileName, const std::string &outputFilename, const osgDB::ReaderWriter::Options *options, bool printToConsole)
 Thread safe implementation of encrypting an image.
bool ts_resolveRelativeFilename (const LoadFileOptions &loadFileOptions, std::string &absoluteInputFilename)
 Attempt to resolve the absolute input filename.
virtual void ts_clearInstancingCache ()
 Clear the model instance cache.
virtual void ts_flushInstancingCache (bool multipass, bool flushNodes, bool flushTextures, bool flushImages)
 Flush the instancing cache.
 DtOsgFileCache (DtDe &de)
 Protected CTOR. Must be called by creator.
std::string ts_buildAcceleratedFilename (const std::string &filePathIn, const std::string &cachedDir, const std::string &cachedExtension) const
 Build the cached filename for a file to be cached.
virtual bool save (const std::string &origFilename, const std::string &cachedFilename, bool optimize)
 Returns true if origFilename was successfully written out as cachedFilename.
bool shouldSaveFile (const std::string &filename)
 Should this file be saved as an accelerated file.
bool saveToAcceleratedFile (const std::string &origFileName, osg::Node *nodeRef, const std::string &cachedFilename, bool writeExternalReferences)
 Save the node to an accelerated file.
virtual void addMetaFlightOptions (std::string &optionsString)
 Add meta flight options to the option string.
virtual bool needsShaderGeneration (const std::string &filename, const LoadFileOptions &options) const
 Returns TRUE if we should run the shader generator on the node.
virtual void updateGlobalOptions ()
 updates the osgDB::Registry::instance() options with the defaults based on the shared state.
virtual void slot_onDdsFlipChanged (bool flip)
 slot for the onDdsFlipChanged signal so we can update the global options to match the shared state
virtual void slot_instancingChanged (bool enabled)
 slot for the instancingChanged signal so we can update the global options to match the shared state
- Protected Member Functions inherited from makVrv::DtFileCache
virtual void autoSaveDefaultsIfNeeded ()
 Save the default settings if necessary.
virtual bool ts_isExcludedExtension (const std::string &ext) const
 Thread safe call.
virtual void addExcludedExtension (const std::string &ext)
 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 removeExcludedExtension (const std::string &ext)
 remove the extension from the list of excluded file types This function can only be called in the CTOR of the file cache.
 DtFileCache (DtDe &de)
 Protected CTOR.

Protected Attributes

DtOsgReferencedCollection
< osg::Node > 
myNodeCollection
DtOsgReferencedCollection
< TextureCollection
myTextureCollection
DtOsgReferencedCollection
< osg::Image > 
myImageCollection
unsigned int myMaxFlushTextureCount
unsigned int myMaxFlushNodeCount
unsigned int myMaxFlushImageCount
boost::mutex myRelativePathMutex
RelativePathCache myRelativePathCache
DtMeifConvertermyImageCompressor
DtMetaFileManagermyMetaFileManager
DtOsgShaderManagermyShaderManager
DtOsgShaderFilesCachemyShaderFilesCache
DtEffectControllerFactorymyEffectControllerFactory
boost::mutex myImageUserValueMutex
- Protected Attributes inherited from makVrv::DtFileCache
DtDemyDe
bool myCachingEnabled
bool myCompressTextureFlag
bool myClearInstancesOnNewSceneFlag
bool myInstancingEnabled
unsigned int myFlushCycleCount
ExcludedExtensions myExcludedExtensionMap
DtRecordSettingsBackupInterfacemySettingsBackup

Friends

class DtOsgFileCacheCreator
 This allows the protected constructor to be called by the DtOsgFileCacheCreator.
class DtReadFileCallback

Additional Inherited Members

- Public Types inherited from makVrv::DtFileCache
typedef boost::unordered_set
< std::string > 
ExcludedExtensions
 A set of extensions excluded from the cache.
typedef std::deque< std::string > FilePathList

Detailed Description

The OSG implementation of makVrv::DtOsgFileCache.

This will cache files as .ive's for quicker load times, except for files with an extension in the excluded extensions list.

Member Typedef Documentation

typedef boost::unordered_map<std::string,std::string> makVrv::DtOsgFileCache::RelativePathCache
protected

Constructor & Destructor Documentation

virtual makVrv::DtOsgFileCache::~DtOsgFileCache ( )
virtual

CTOR.

makVrv::DtOsgFileCache::DtOsgFileCache ( DtDe de)
protected

Protected CTOR. Must be called by creator.

Member Function Documentation

virtual void makVrv::DtOsgFileCache::releaseResources ( )
inlinevirtual

Release all rendering resources.

Reimplemented from makVrv::DtFileCache.

virtual void makVrv::DtOsgFileCache::releaseResources ( osg::State *  state)
virtual

Release all rendering resources.

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

Push loader options to global registry whenever they're loaded from a record.

Reimplemented from makVrv::DtFileCache.

static void makVrv::DtOsgFileCache::optimizeNodeGeometry ( osg::Node *  node)
static

Run extra optimization passes on node.

Merges geometry and geodes skipped by regular OSG optimizer

osg::Node* makVrv::DtOsgFileCache::readNodeFile ( const std::string &  inputFilename,
const LoadFileOptions loadFileOptions 
)

Read a node file, provides options for controlling This is call is equivalent to osg::readNodeFile function with the options encoded in a options string.

osg::ref_ptr<osg::Node> makVrv::DtOsgFileCache::findNodeFile ( const std::string &  inputFilename)
inline

Find a node file.

If the file was already cached then a copy will be returned.

osg::Image* makVrv::DtOsgFileCache::readImageFile ( const std::string &  inputFilename,
const LoadFileOptions loadFileOptions 
)

Read a node file, provides options for controlling This is call is equivalent to osg::readImageFile function with the options encoded in a options string.

virtual osg::Texture* makVrv::DtOsgFileCache::getTextureInstance ( const std::string &  filePath,
osg::Texture::FilterMode  minFilter,
osg::Texture::FilterMode  magFilter,
osg::Texture::WrapMode  s,
osg::Texture::WrapMode  t,
const LoadFileOptions loadFileOptions 
)
virtual

Returns a cached texture instance, or a new copy of a texture if instancing is disabled; returns 0 if file failed to load.

virtual void makVrv::DtOsgFileCache::ts_getTextureInstance ( const std::string &  filePath,
osg::Texture::FilterMode  minFilter,
osg::Texture::FilterMode  magFilter,
osg::Texture::WrapMode  s,
osg::Texture::WrapMode  t,
const LoadFileOptions loadFileOptions,
osg::ref_ptr< osg::Texture > &  texture 
)
virtual

Passes back a cached texture instance, or a new copy of a texture if instancing is disabled; returns 0 if file failed to load use this instead of getTextureInstance if it is called outside the main thread.

virtual void makVrv::DtOsgFileCache::encodeOptionsString ( const LoadFileOptions loadFileOptions,
osgDB::ReaderWriter::Options &  options 
) const
virtual

Encode load file options into reader write options.

Reimplemented in DtVrfOsgFileCache.

virtual void makVrv::DtOsgFileCache::decodeOptions ( const osgDB::ReaderWriter::Options &  options,
LoadFileOptions loadFileOptions 
) const
virtual

Decode reader write options into load file options.

Reimplemented in DtVrfOsgFileCache.

DtMetaFileManager* makVrv::DtOsgFileCache::metaFileManager ( )

Retrieve the Metafile manager (load, parse .meta files)

const DtOsgShaderManager& makVrv::DtOsgFileCache::shaderManager ( void  ) const
inline
DtOsgShaderManager& makVrv::DtOsgFileCache::shaderManager ( void  )
inline
const DtOsgShaderFilesCache& makVrv::DtOsgFileCache::shaderFilesCache ( void  ) const
inline
DtEffectControllerFactory& makVrv::DtOsgFileCache::effectControllerFactory ( void  ) const
inline
virtual osg::ref_ptr<osg::Node> makVrv::DtOsgFileCache::ts_readNodeFile ( const std::string &  inputFilename,
const LoadFileOptions loadFileOptions,
const osg::UserDataContainer *  optionsUserData 
)
protectedvirtual

Thread safe Implementation of readNodeFile.

virtual osg::ref_ptr<osg::Node> makVrv::DtOsgFileCache::ts_findNodeFile ( const std::string &  inputFilename)
protectedvirtual

Thread safe Implementation of findNodeFile.

virtual osg::ref_ptr<osg::Image> makVrv::DtOsgFileCache::ts_readImageFile ( const std::string &  inputFilename,
const LoadFileOptions loadFileOptions,
const osg::UserDataContainer *  optionsUserData = 0L 
)
protectedvirtual

Thread safe Implementation of readImageFile.

void makVrv::DtOsgFileCache::ts_encryptImage ( const std::string &  inputFileName,
const std::string &  outputFilename,
const osgDB::ReaderWriter::Options *  options,
bool  printToConsole 
)
protected

Thread safe implementation of encrypting an image.

bool makVrv::DtOsgFileCache::ts_resolveRelativeFilename ( const LoadFileOptions loadFileOptions,
std::string &  absoluteInputFilename 
)
protected

Attempt to resolve the absolute input filename.

virtual void makVrv::DtOsgFileCache::ts_clearInstancingCache ( )
protectedvirtual

Clear the model instance cache.

Reimplemented from makVrv::DtFileCache.

virtual void makVrv::DtOsgFileCache::ts_flushInstancingCache ( bool  multipass,
bool  flushNodes,
bool  flushTextures,
bool  flushImages 
)
protectedvirtual

Flush the instancing cache.

Reimplemented from makVrv::DtFileCache.

std::string makVrv::DtOsgFileCache::ts_buildAcceleratedFilename ( const std::string &  filePathIn,
const std::string &  cachedDir,
const std::string &  cachedExtension 
) const
protected

Build the cached filename for a file to be cached.

Takes the path of the file being cached, and the extension that the cached version will have.

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

Returns true if origFilename was successfully written out as cachedFilename.

Reimplemented from makVrv::DtFileCache.

bool makVrv::DtOsgFileCache::shouldSaveFile ( const std::string &  filename)
protected

Should this file be saved as an accelerated file.

bool makVrv::DtOsgFileCache::saveToAcceleratedFile ( const std::string &  origFileName,
osg::Node *  nodeRef,
const std::string &  cachedFilename,
bool  writeExternalReferences 
)
protected

Save the node to an accelerated file.

virtual void makVrv::DtOsgFileCache::addMetaFlightOptions ( std::string &  optionsString)
protectedvirtual

Add meta flight options to the option string.

virtual bool makVrv::DtOsgFileCache::needsShaderGeneration ( const std::string &  filename,
const LoadFileOptions options 
) const
protectedvirtual

Returns TRUE if we should run the shader generator on the node.

Reimplemented in DtVrfOsgFileCache.

virtual void makVrv::DtOsgFileCache::updateGlobalOptions ( )
protectedvirtual

updates the osgDB::Registry::instance() options with the defaults based on the shared state.

virtual void makVrv::DtOsgFileCache::slot_onDdsFlipChanged ( bool  flip)
protectedvirtual

slot for the onDdsFlipChanged signal so we can update the global options to match the shared state

virtual void makVrv::DtOsgFileCache::slot_instancingChanged ( bool  enabled)
protectedvirtual

slot for the instancingChanged signal so we can update the global options to match the shared state

Friends And Related Function Documentation

friend class DtOsgFileCacheCreator
friend

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

friend class DtReadFileCallback
friend

Member Data Documentation

boost::signals2::signal<void (osg::Node*, const std::string& origFileName, const std::string& actualFileName)> makVrv::DtOsgFileCache::signal_nodeFileLoaded

Signal emitted whenever a Node file is loaded from disk.

When instancing is enabled then each file will only ever be loaded from disk once. Passes the node loaded, the original filename requested, and the actual filename loaded.

boost::signals2::signal<void (osg::Image*, const std::string& origFileName, const std::string& actualFileName)> makVrv::DtOsgFileCache::signal_imageFileLoaded

Signal emitted whenever an image file is loaded from disk.

When instancing is enabled then each file will only ever be loaded from disk once. Passes the node loaded, the original filename requested, and the actual filename loaded.

boost::signals2::signal<void (const std::string& filename, osgDB::ReaderWriter::ReadResult&,const osgDB::ReaderWriter::Options*)> makVrv::DtOsgFileCache::signal_readNodeCallback

Signaled emitted when osg calls readNodeFile.

This signal is emitted every time read image is called regardless of if the image was actually loaded or found in a cache.

boost::signals2::signal<void (const std::string& filename, osgDB::ReaderWriter::ReadResult&,const osgDB::ReaderWriter::Options*)> makVrv::DtOsgFileCache::signal_readImageCallback

Signaled emitted when osg calls readImageFile.

This signal is emitted every time read image is called regardless of if the image was actually loaded or found in a cache.

DtOsgReferencedCollection<osg::Node> makVrv::DtOsgFileCache::myNodeCollection
protected
DtOsgReferencedCollection<TextureCollection> makVrv::DtOsgFileCache::myTextureCollection
protected
DtOsgReferencedCollection<osg::Image> makVrv::DtOsgFileCache::myImageCollection
protected
unsigned int makVrv::DtOsgFileCache::myMaxFlushTextureCount
protected
unsigned int makVrv::DtOsgFileCache::myMaxFlushNodeCount
protected
unsigned int makVrv::DtOsgFileCache::myMaxFlushImageCount
protected
boost::mutex makVrv::DtOsgFileCache::myRelativePathMutex
protected
RelativePathCache makVrv::DtOsgFileCache::myRelativePathCache
protected
DtMeifConverter* makVrv::DtOsgFileCache::myImageCompressor
protected
DtMetaFileManager* makVrv::DtOsgFileCache::myMetaFileManager
protected
DtOsgShaderManager& makVrv::DtOsgFileCache::myShaderManager
protected
DtOsgShaderFilesCache& makVrv::DtOsgFileCache::myShaderFilesCache
protected
DtEffectControllerFactory& makVrv::DtOsgFileCache::myEffectControllerFactory
protected
boost::mutex makVrv::DtOsgFileCache::myImageUserValueMutex
protected

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

Document ID: Generated on Thu Mar 23 18:54:12 EDT 2017 from SVN revision 174804
Copyright © 2005-2017 VT MÄK. All Rights Reserved (www.mak.com)