class OSGDB_EXPORT osgDB::Registry

Registry is a singleton factory which stores the reader/writers which are linked in at runtime for reading non-native file formats.

Inheritance:


Public Classes

[more]enum CacheHintOptions
bit mask for setting up which object types get cached by readObject/Image/HeightField/Node(filename) calls
class ReadFileCallback: public osg::Referenced
class WriteFileCallback: public osg::Referenced

Public Methods

[more]static Registry* instance(bool erase = false)
[more]void readCommandLine(osg::ArgumentParser& commandLine)
read the command line arguments
[more]void addFileExtensionAlias(const std::string mapExt, const std::string toExt)
register an fileextension alias to mapExt toExt, the later should the the extension name of the readerwriter plugin library.
[more]void addDotOsgWrapper(DotOsgWrapper* wrapper)
[more]void removeDotOsgWrapper(DotOsgWrapper* wrapper)
[more]void addReaderWriter(ReaderWriter* rw)
[more]void removeReaderWriter(ReaderWriter* rw)
[more]std::string createLibraryNameForFile(const std::string& fileName)
create the platform specific library name associated with file
[more]std::string createLibraryNameForExtension(const std::string& ext)
create the platform specific library name associated with file extension
[more]std::string createLibraryNameForNodeKit(const std::string& name)
create the platform specific library name associated with nodekit library name
[more]bool loadLibrary(const std::string& fileName)
find the library in the SG_LIBRARY_PATH and load it
[more]bool closeLibrary(const std::string& fileName)
close the attached library with specified name
[more]void closeAllLibraries()
close all libraries
[more]ReaderWriter* getReaderWriterForExtension(const std::string& ext)
get a reader writer which handles specified extension
[more]osg::Object* readObjectOfType(const osg::Object& compObj, Input& fr)
[more]osg::Object* readObjectOfType(const basic_type_wrapper &btw, Input& fr)
[more]osg::Object* readObject(Input& fr)
[more]osg::Image* readImage(Input& fr)
[more]osg::Drawable* readDrawable(Input& fr)
[more]osg::StateAttribute* readStateAttribute(Input& fr)
[more]osg::Node* readNode(Input& fr)
[more]bool writeObject(const osg::Object& obj, Output& fw)
[more]void setReadFileCallback( ReadFileCallback* cb)
Set the Registry callback to use in place of the default readFile calls
[more]ReadFileCallback* getReadFileCallback()
Get the readFile callback
[more]const ReadFileCallback* getReadFileCallback() const
Get the const readFile callback
[more]ReaderWriter::ReadResult readObject(const std::string& fileName, CacheHintOptions useObjectCache)
[more]ReaderWriter::ReadResult readObjectImplementation(const std::string& fileName, CacheHintOptions useObjectCache)
[more]ReaderWriter::ReadResult readImage(const std::string& fileName, CacheHintOptions useObjectCache)
[more]ReaderWriter::ReadResult readImageImplementation(const std::string& fileName, CacheHintOptions useObjectCache)
[more]ReaderWriter::ReadResult readHeightField(const std::string& fileName, CacheHintOptions useObjectCache)
[more]ReaderWriter::ReadResult readHeightFieldImplementation(const std::string& fileName, CacheHintOptions useObjectCache)
[more]ReaderWriter::ReadResult readNode(const std::string& fileName, CacheHintOptions useObjectCache)
[more]ReaderWriter::ReadResult readNodeImplementation(const std::string& fileName, CacheHintOptions useObjectCache)
[more]void setWriteFileCallback( WriteFileCallback* cb)
Set the Registry callback to use in place of the default writeFile calls
[more]WriteFileCallback* getWriteFileCallback()
Get the writeFile callback
[more]const WriteFileCallback* getWriteFileCallback() const
Get the const writeFile callback
[more]ReaderWriter::WriteResult writeObject(const osg::Object& obj, const std::string& fileName)
[more]ReaderWriter::WriteResult writeObjectImplementation(const osg::Object& obj, const std::string& fileName)
[more]ReaderWriter::WriteResult writeImage(const osg::Image& obj, const std::string& fileName)
[more]ReaderWriter::WriteResult writeImageImplementation(const osg::Image& obj, const std::string& fileName)
[more]ReaderWriter::WriteResult writeHeightField(const osg::HeightField& obj, const std::string& fileName)
[more]ReaderWriter::WriteResult writeHeightFieldImplementation(const osg::HeightField& obj, const std::string& fileName)
[more]ReaderWriter::WriteResult writeNode(const osg::Node& node, const std::string& fileName)
[more]ReaderWriter::WriteResult writeNodeImplementation(const osg::Node& node, const std::string& fileName)
[more]void setCreateNodeFromImage(bool flag)
[more]bool getCreateNodeFromImage() const
[more]void setOptions(ReaderWriter::Options* opt)
[more]ReaderWriter::Options* getOptions()
[more]const ReaderWriter::Options* getOptions() const
[more]void initFilePathLists()
initilize both the Data and Library FilePaths, by default called by the constructor, so it should only be required if you want to force the re-reading of environmental variables
[more]void initDataFilePathList()
initilize the Data FilePath by reading the OSG_FILE_PATH environmental variable
[more]void setDataFilePathList(const FilePathList& filepath)
Set the data file path using a list of paths stored in a FilePath, which is used when search for data files
[more]void setDataFilePathList(const std::string& paths)
Set the data file path using a single string deliminated either with ';' (Windows) or ':' (All other platforms), which is used when search for data files
[more]FilePathList& getDataFilePathList()
get the data file path which is used when search for data files
[more]const FilePathList& getDataFilePathList() const
get the const data file path which is used when search for data files
[more]void initLibraryFilePathList()
initilize the Library FilePath by reading the OSG_LIBRARY_PATH and the appropriate system environmental variables
[more]void setLibraryFilePathList(const FilePathList& filepath)
Set the library file path using a list of paths stored in a FilePath, which is used when search for data files
[more]void setLibraryFilePathList(const std::string& paths)
Set the library file path using a single string deliminated either with ';' (Windows) or ':' (All other platforms), which is used when search for data files
[more]FilePathList& getLibraryFilePathList()
get the library file path which is used when search for library (dso/dll's) files
[more]const FilePathList& getLibraryFilePathList() const
get the const library file path which is used when search for library (dso/dll's) files
[more]static void convertStringPathIntoFilePathList(const std::string& paths, FilePathList& filepath)
convert a string containing a list of paths deliminated either with ';' (Windows) or ':' (All other platforms) into FilePath represetation
[more]void updateTimeStampOfObjectsInCacheWithExtenalReferences(double currentTime)
For each object in the cache which has an reference count greater than 1 (and therefore referenced by elsewhere in the application) set the time stamp for that object in the cache to specified time.
[more]void removeExpiredObjectsInCache(double expiryTime)
Removed object in the cache which have a time stamp at or before the specified expiry time.
[more]void clearObjectCache()
Remove all objects in the cache regardless of having external references or expiry times
[more]void addEntryToObjectCache(const std::string& filename, osg::Object* object, double timestamp = 0.0)
Add a filename,object,timestamp tripple to the Registry::ObjectCache
[more]void setUseObjectCacheHint(CacheHintOptions useObjectCache)
Set whether the Registry::ObjectCache should be used by default
[more]CacheHintOptions getUseObjectCacheHint() const
Get whether the Registry::ObjectCache should be used by default
[more]DynamicLibrary* getLibrary(const std::string& fileName)
get the attached library with specified name
[more]void setDatabasePager(DatabasePager* databasePager)
Set the DatabasePager
[more]DatabasePager* getOrCreateDatabasePager()
Get the DatabasePager, creating one if one is not already created
[more]DatabasePager* getDatabasePager()
Get the DatabasePager.
[more]void setSharedStateManager(SharedStateManager* SharedStateManager)
Set the SharedStateManager
[more]SharedStateManager* getOrCreateSharedStateManager()
Get the SharedStateManager, creating one if one is not already created
[more]SharedStateManager* getSharedStateManager()
Get the SharedStateManager.

Public

[more]typedef std::vector< osg::ref_ptr<ReaderWriter> > ReaderWriterList

Protected Fields

[more]bool _createNodeFromImage
[more]osg::ref_ptr<ReadFileCallback> _readFileCallback
[more]osg::ref_ptr<WriteFileCallback> _writeFileCallback
[more]DotOsgWrapperMap _objectWrapperMap
[more]DotOsgWrapperMap _imageWrapperMap
[more]DotOsgWrapperMap _drawableWrapperMap
[more]DotOsgWrapperMap _stateAttrWrapperMap
[more]DotOsgWrapperMap _nodeWrapperMap
[more]DotOsgWrapperMap _classNameWrapperMap
[more]ReaderWriterList _rwList
[more]DynamicLibraryList _dlList
[more]bool _openingLibrary
[more]ExtensionAliasMap _extAliasMap
[more]osg::ref_ptr<ReaderWriter::Options> _options
[more]FilePathList _dataFilePath
[more]FilePathList _libraryFilePath
[more]CacheHintOptions _useObjectCacheHint
[more]ObjectCache _objectCache
[more]osg::ref_ptr<DatabasePager> _databasePager
[more]osg::ref_ptr<SharedStateManager> _sharedStateManager

Protected Methods

[more]virtual ~Registry()
[more] Registry()
constructor is private, as its a singleton, preventing construction other than via the instance() method and therefore ensuring only one copy is ever constructed
[more]DynamicLibraryList::iterator getLibraryItr(const std::string& fileName)
get the attached library with specified name
[more]osg::Object* readObject(DotOsgWrapperMap& dowMap, Input& fr)
[more]void eraseWrapper(DotOsgWrapperMap& wrappermap, DotOsgWrapper* wrapper)
[more]ReaderWriter::ReadResult readObject(const std::string& fileName)
[more]ReaderWriter::ReadResult readImage(const std::string& fileName)
[more]ReaderWriter::ReadResult readHeightField(const std::string& fileName)
[more]ReaderWriter::ReadResult readNode(const std::string& fileName)

Protected

[more]typedef std::map< std::string, osg::ref_ptr<DotOsgWrapper> > DotOsgWrapperMap
[more]typedef std::vector< osg::ref_ptr<DynamicLibrary> > DynamicLibraryList
[more]typedef std::map< std::string, std::string> ExtensionAliasMap
[more]typedef std::pair<osg::ref_ptr<osg::Object>, double > ObjectTimeStampPair
[more]typedef std::map<std::string, ObjectTimeStampPair > ObjectCache


Documentation

Registry is a singleton factory which stores the reader/writers which are linked in at runtime for reading non-native file formats.

The RegisterDotOsgWrapperProxy can be used to automatically register DotOsgWrappers, at runtime with the Registry. A DotOsgWrapper encapsulates the functions that can read and write to the .osg for each osg::Object.

The RegisterReaderWriterProxy can be used to automatically register at runtime a reader/writer with the Registry.

oenum CacheHintOptions
bit mask for setting up which object types get cached by readObject/Image/HeightField/Node(filename) calls

o CACHE_NONE
do not cache objects of any type

o CACHE_NODES
cache nodes loaded via readNode(filename)

o CACHE_IMAGES
cache images loaded via readImage(filename)

o CACHE_HEIGHTFIELDS
cache heightfield loaded via readHeightField(filename)

o CACHE_OBJECTS
cache objects loaded via readObject(filename)

o CACHE_ALL
cache on all read*(filename) calls

ostatic Registry* instance(bool erase = false)

ovoid readCommandLine(osg::ArgumentParser& commandLine)
read the command line arguments

ovoid addFileExtensionAlias(const std::string mapExt, const std::string toExt)
register an fileextension alias to mapExt toExt, the later should the the extension name of the readerwriter plugin library. For example to map .tif files to the tiff loader, use addExtAlias("tif","tiff") which will enable .tif to be read by the libdb_tiff readerwriter plugin.

ovoid addDotOsgWrapper(DotOsgWrapper* wrapper)

ovoid removeDotOsgWrapper(DotOsgWrapper* wrapper)

ovoid addReaderWriter(ReaderWriter* rw)

ovoid removeReaderWriter(ReaderWriter* rw)

ostd::string createLibraryNameForFile(const std::string& fileName)
create the platform specific library name associated with file

ostd::string createLibraryNameForExtension(const std::string& ext)
create the platform specific library name associated with file extension

ostd::string createLibraryNameForNodeKit(const std::string& name)
create the platform specific library name associated with nodekit library name

obool loadLibrary(const std::string& fileName)
find the library in the SG_LIBRARY_PATH and load it

obool closeLibrary(const std::string& fileName)
close the attached library with specified name

ovoid closeAllLibraries()
close all libraries

oReaderWriter* getReaderWriterForExtension(const std::string& ext)
get a reader writer which handles specified extension

oosg::Object* readObjectOfType(const osg::Object& compObj, Input& fr)

oosg::Object* readObjectOfType(const basic_type_wrapper &btw, Input& fr)

oosg::Object* readObject(Input& fr)

oosg::Image* readImage(Input& fr)

oosg::Drawable* readDrawable(Input& fr)

oosg::StateAttribute* readStateAttribute(Input& fr)

oosg::Node* readNode(Input& fr)

obool writeObject(const osg::Object& obj, Output& fw)

ovoid setReadFileCallback( ReadFileCallback* cb)
Set the Registry callback to use in place of the default readFile calls

oReadFileCallback* getReadFileCallback()
Get the readFile callback

oconst ReadFileCallback* getReadFileCallback() const
Get the const readFile callback

oReaderWriter::ReadResult readObject(const std::string& fileName, CacheHintOptions useObjectCache)

oReaderWriter::ReadResult readObjectImplementation(const std::string& fileName, CacheHintOptions useObjectCache)

oReaderWriter::ReadResult readImage(const std::string& fileName, CacheHintOptions useObjectCache)

oReaderWriter::ReadResult readImageImplementation(const std::string& fileName, CacheHintOptions useObjectCache)

oReaderWriter::ReadResult readHeightField(const std::string& fileName, CacheHintOptions useObjectCache)

oReaderWriter::ReadResult readHeightFieldImplementation(const std::string& fileName, CacheHintOptions useObjectCache)

oReaderWriter::ReadResult readNode(const std::string& fileName, CacheHintOptions useObjectCache)

oReaderWriter::ReadResult readNodeImplementation(const std::string& fileName, CacheHintOptions useObjectCache)

ovoid setWriteFileCallback( WriteFileCallback* cb)
Set the Registry callback to use in place of the default writeFile calls

oWriteFileCallback* getWriteFileCallback()
Get the writeFile callback

oconst WriteFileCallback* getWriteFileCallback() const
Get the const writeFile callback

oReaderWriter::WriteResult writeObject(const osg::Object& obj, const std::string& fileName)

oReaderWriter::WriteResult writeObjectImplementation(const osg::Object& obj, const std::string& fileName)

oReaderWriter::WriteResult writeImage(const osg::Image& obj, const std::string& fileName)

oReaderWriter::WriteResult writeImageImplementation(const osg::Image& obj, const std::string& fileName)

oReaderWriter::WriteResult writeHeightField(const osg::HeightField& obj, const std::string& fileName)

oReaderWriter::WriteResult writeHeightFieldImplementation(const osg::HeightField& obj, const std::string& fileName)

oReaderWriter::WriteResult writeNode(const osg::Node& node, const std::string& fileName)

oReaderWriter::WriteResult writeNodeImplementation(const osg::Node& node, const std::string& fileName)

ovoid setCreateNodeFromImage(bool flag)

obool getCreateNodeFromImage() const

ovoid setOptions(ReaderWriter::Options* opt)

oReaderWriter::Options* getOptions()

oconst ReaderWriter::Options* getOptions() const

ovoid initFilePathLists()
initilize both the Data and Library FilePaths, by default called by the constructor, so it should only be required if you want to force the re-reading of environmental variables

ovoid initDataFilePathList()
initilize the Data FilePath by reading the OSG_FILE_PATH environmental variable

ovoid setDataFilePathList(const FilePathList& filepath)
Set the data file path using a list of paths stored in a FilePath, which is used when search for data files

ovoid setDataFilePathList(const std::string& paths)
Set the data file path using a single string deliminated either with ';' (Windows) or ':' (All other platforms), which is used when search for data files

oFilePathList& getDataFilePathList()
get the data file path which is used when search for data files

oconst FilePathList& getDataFilePathList() const
get the const data file path which is used when search for data files

ovoid initLibraryFilePathList()
initilize the Library FilePath by reading the OSG_LIBRARY_PATH and the appropriate system environmental variables

ovoid setLibraryFilePathList(const FilePathList& filepath)
Set the library file path using a list of paths stored in a FilePath, which is used when search for data files

ovoid setLibraryFilePathList(const std::string& paths)
Set the library file path using a single string deliminated either with ';' (Windows) or ':' (All other platforms), which is used when search for data files

oFilePathList& getLibraryFilePathList()
get the library file path which is used when search for library (dso/dll's) files

oconst FilePathList& getLibraryFilePathList() const
get the const library file path which is used when search for library (dso/dll's) files

ostatic void convertStringPathIntoFilePathList(const std::string& paths, FilePathList& filepath)
convert a string containing a list of paths deliminated either with ';' (Windows) or ':' (All other platforms) into FilePath represetation

ovoid updateTimeStampOfObjectsInCacheWithExtenalReferences(double currentTime)
For each object in the cache which has an reference count greater than 1 (and therefore referenced by elsewhere in the application) set the time stamp for that object in the cache to specified time. This would typically be called once per frame by applications which are doing database paging, and need to prune objects that are no longer required. Time value is time in sceonds.

ovoid removeExpiredObjectsInCache(double expiryTime)
Removed object in the cache which have a time stamp at or before the specified expiry time. This would typically be called once per frame by applications which are doing database paging, and need to prune objects that are no longer required, and called after the a called after the call to updateTimeStampOfObjectsInCacheWithExtenalReferences(currentTime). Note, the currentTime is not the expiryTime, one would typically set the expiry time to a fixed amount of time before currentTime, such as expiryTime = currentTime-10.0. Time value is time in sceonds.

ovoid clearObjectCache()
Remove all objects in the cache regardless of having external references or expiry times

ovoid addEntryToObjectCache(const std::string& filename, osg::Object* object, double timestamp = 0.0)
Add a filename,object,timestamp tripple to the Registry::ObjectCache

ovoid setUseObjectCacheHint(CacheHintOptions useObjectCache)
Set whether the Registry::ObjectCache should be used by default

oCacheHintOptions getUseObjectCacheHint() const
Get whether the Registry::ObjectCache should be used by default

oDynamicLibrary* getLibrary(const std::string& fileName)
get the attached library with specified name

otypedef std::vector< osg::ref_ptr<ReaderWriter> > ReaderWriterList

ovoid setDatabasePager(DatabasePager* databasePager)
Set the DatabasePager

oDatabasePager* getOrCreateDatabasePager()
Get the DatabasePager, creating one if one is not already created

oDatabasePager* getDatabasePager()
Get the DatabasePager. Return 0 if no DatabasePager has been assigned.

ovoid setSharedStateManager(SharedStateManager* SharedStateManager)
Set the SharedStateManager

oSharedStateManager* getOrCreateSharedStateManager()
Get the SharedStateManager, creating one if one is not already created

oSharedStateManager* getSharedStateManager()
Get the SharedStateManager. Return 0 if no SharedStateManager has been assigned.

ovirtual ~Registry()

otypedef std::map< std::string, osg::ref_ptr<DotOsgWrapper> > DotOsgWrapperMap

otypedef std::vector< osg::ref_ptr<DynamicLibrary> > DynamicLibraryList

otypedef std::map< std::string, std::string> ExtensionAliasMap

otypedef std::pair<osg::ref_ptr<osg::Object>, double > ObjectTimeStampPair

otypedef std::map<std::string, ObjectTimeStampPair > ObjectCache

o Registry()
constructor is private, as its a singleton, preventing construction other than via the instance() method and therefore ensuring only one copy is ever constructed

oDynamicLibraryList::iterator getLibraryItr(const std::string& fileName)
get the attached library with specified name

obool _createNodeFromImage

oosg::Object* readObject(DotOsgWrapperMap& dowMap, Input& fr)

ovoid eraseWrapper(DotOsgWrapperMap& wrappermap, DotOsgWrapper* wrapper)

oReaderWriter::ReadResult readObject(const std::string& fileName)

oReaderWriter::ReadResult readImage(const std::string& fileName)

oReaderWriter::ReadResult readHeightField(const std::string& fileName)

oReaderWriter::ReadResult readNode(const std::string& fileName)

oosg::ref_ptr<ReadFileCallback> _readFileCallback

oosg::ref_ptr<WriteFileCallback> _writeFileCallback

oDotOsgWrapperMap _objectWrapperMap

oDotOsgWrapperMap _imageWrapperMap

oDotOsgWrapperMap _drawableWrapperMap

oDotOsgWrapperMap _stateAttrWrapperMap

oDotOsgWrapperMap _nodeWrapperMap

oDotOsgWrapperMap _classNameWrapperMap

oReaderWriterList _rwList

oDynamicLibraryList _dlList

obool _openingLibrary

oExtensionAliasMap _extAliasMap

oosg::ref_ptr<ReaderWriter::Options> _options

oFilePathList _dataFilePath

oFilePathList _libraryFilePath

oCacheHintOptions _useObjectCacheHint

oObjectCache _objectCache

oosg::ref_ptr<DatabasePager> _databasePager

oosg::ref_ptr<SharedStateManager> _sharedStateManager


This class has no child classes.

Alphabetic index HTML hierarchy of classes or Java



This page was generated with the help of DOC++.