## 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 Methods

static Registry* instance()
void readCommandLine(osg::ArgumentParser& commandLine)
  read the command line arguments
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.
void addDotOsgWrapper(DotOsgWrapper* wrapper)
void removeDotOsgWrapper(DotOsgWrapper* wrapper)
void addReaderWriter(ReaderWriter* rw)
void removeReaderWriter(ReaderWriter* rw)
std::string createLibraryNameForFile(const std::string& fileName)
  create the platform specific library name associated with file
std::string createLibraryNameForExtension(const std::string& ext)
  create the platform specific library name associated with file extension
std::string createLibraryNameForNodeKit(const std::string& name)
  create the platform specific library name associated with nodekit library name
bool loadLibrary(const std::string& fileName)
  find the library in the SG_LIBRARY_PATH and load it
bool closeLibrary(const std::string& fileName)
  close the attached library with specified name
ReaderWriter* getReaderWriterForExtension(const std::string& ext)
  get a reader writer which handles specified extension
osg::Object* readObjectOfType(const osg::Object& compObj, Input& fr)
osg::Object* readObjectOfType(const basic_type_wrapper &btw, Input& fr)
osg::Object* readObject(Input& fr)
osg::Image* readImage(Input& fr)
osg::Drawable* readDrawable(Input& fr)
osg::StateAttribute* readStateAttribute(Input& fr)
osg::Node* readNode(Input& fr)
bool writeObject(const osg::Object& obj, Output& fw)
ReaderWriter::ReadResult readObject(const std::string& fileName, bool useObjectCache)
ReaderWriter::WriteResult writeObject(const osg::Object& obj, const std::string& fileName)
ReaderWriter::ReadResult readImage(const std::string& fileName, bool useObjectCache)
ReaderWriter::WriteResult writeImage(const osg::Image& obj, const std::string& fileName)
ReaderWriter::ReadResult readNode(const std::string& fileName, bool useObjectCache)
ReaderWriter::WriteResult writeNode(const osg::Node& node, const std::string& fileName)
void setCreateNodeFromImage(bool flag)
bool getCreateNodeFromImage() const
void setOptions(ReaderWriter::Options* opt)
ReaderWriter::Options* getOptions()
const ReaderWriter::Options* getOptions() const
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
void initDataFilePathList()
  initilize the Data FilePath by reading the OSG_FILE_PATH environmental variable
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
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
FilePathList& getDataFilePathList()
  get the data file path which is used when search for data files
const FilePathList& getDataFilePathList() const
  get the const data file path which is used when search for data files
void initLibraryFilePathList()
  initilize the Library FilePath by reading the OSG_LIBRARY_PATH and the appropriate system environmental variables
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
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
FilePathList& getLibraryFilePathList()
  get the library file path which is used when search for library (dso/dll's) files
const FilePathList& getLibraryFilePathList() const
  get the const library file path which is used when search for library (dso/dll's) files
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
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.
void removeExpiredObjectsInCache(double expiryTime)
  Removed object in the cache which have a time stamp at or before the specified expiry time.
void clearObjectCache()
  Remove all objects in the cache regardless of having external references or expiry times
void addEntryToObjectCache(const std::string& filename, osg::Object* object, double timestamp = 0.0)
  Add a filename,object,timestamp tripple to the Registry::ObjectCache
void setUseObjectCacheHint(bool useObjectCache)
  Set whether the Registry::ObjectCache should be used by default
bool getUseObjectCacheHint() const
  Get whether the Registry::ObjectCache should be used by default
DynamicLibrary* getLibrary(const std::string& fileName)
  get the attached library with specified name

### Protected Fields

bool _createNodeFromImage
DotOsgWrapperMap _objectWrapperMap
DotOsgWrapperMap _imageWrapperMap
DotOsgWrapperMap _drawableWrapperMap
DotOsgWrapperMap _stateAttrWrapperMap
DotOsgWrapperMap _nodeWrapperMap
DotOsgWrapperMap _classNameWrapperMap
ReaderWriterList _rwList
DynamicLibraryList _dlList
bool _openingLibrary
ExtensionAliasMap _extAliasMap
osg::ref_ptr<ReaderWriter::Options> _options
FilePathList _dataFilePath
FilePathList _libraryFilePath
bool _useObjectCacheHint
ObjectCache _objectCache

### Protected Methods

virtual ~Registry()
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
DynamicLibraryList::iterator getLibraryItr(const std::string& fileName)
  get the attached library with specified name
osg::Object* readObject(DotOsgWrapperMap& dowMap, Input& fr)
void eraseWrapper(DotOsgWrapperMap& wrappermap, DotOsgWrapper* wrapper)
ReaderWriter::ReadResult readObject(const std::string& fileName)
ReaderWriter::ReadResult readImage(const std::string& fileName)
ReaderWriter::ReadResult readNode(const std::string& fileName)

### Protected Members

typedef std::map< std::string, osg::ref_ptr<DotOsgWrapper> > DotOsgWrapperMap
typedef std::vector< osg::ref_ptr<ReaderWriter> > ReaderWriterList
typedef std::vector< osg::ref_ptr<DynamicLibrary> > DynamicLibraryList
typedef std::map< std::string, std::string> ExtensionAliasMap
typedef std::pair<osg::ref_ptr<osg::Object>, double > ObjectTimeStampPair
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.

`static Registry* instance()`

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

`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. 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.

`void addDotOsgWrapper(DotOsgWrapper* wrapper)`

`void removeDotOsgWrapper(DotOsgWrapper* wrapper)`

`void addReaderWriter(ReaderWriter* rw)`

`void removeReaderWriter(ReaderWriter* rw)`

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

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

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

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

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

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

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

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

`osg::Object* readObject(Input& fr)`

`osg::Image* readImage(Input& fr)`

`osg::Drawable* readDrawable(Input& fr)`

`osg::StateAttribute* readStateAttribute(Input& fr)`

`osg::Node* readNode(Input& fr)`

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

`ReaderWriter::ReadResult readObject(const std::string& fileName, bool useObjectCache)`

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

`ReaderWriter::ReadResult readImage(const std::string& fileName, bool useObjectCache)`

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

`ReaderWriter::ReadResult readNode(const std::string& fileName, bool useObjectCache)`

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

`void setCreateNodeFromImage(bool flag)`

`bool getCreateNodeFromImage() const`

`void setOptions(ReaderWriter::Options* opt)`

`ReaderWriter::Options* getOptions()`

`const ReaderWriter::Options* getOptions() const`

`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

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

`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

`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

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

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

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

`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

`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

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

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

`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

`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. 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.

`void 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.

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

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

`void setUseObjectCacheHint(bool useObjectCache)`
  Set whether the Registry::ObjectCache should be used by default

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

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

`virtual ~Registry()`

`typedef std::map< std::string, osg::ref_ptr<DotOsgWrapper> > DotOsgWrapperMap`

`typedef std::vector< osg::ref_ptr<ReaderWriter> > ReaderWriterList`

`typedef std::vector< osg::ref_ptr<DynamicLibrary> > DynamicLibraryList`

`typedef std::map< std::string, std::string> ExtensionAliasMap`

`typedef std::pair<osg::ref_ptr<osg::Object>, double > ObjectTimeStampPair`

`typedef std::map<std::string, ObjectTimeStampPair > ObjectCache`

`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

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

`bool _createNodeFromImage`

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

`void eraseWrapper(DotOsgWrapperMap& wrappermap, DotOsgWrapper* wrapper)`

`ReaderWriter::ReadResult readObject(const std::string& fileName)`

`ReaderWriter::ReadResult readImage(const std::string& fileName)`

`ReaderWriter::ReadResult readNode(const std::string& fileName)`

`DotOsgWrapperMap _objectWrapperMap`

`DotOsgWrapperMap _imageWrapperMap`

`DotOsgWrapperMap _drawableWrapperMap`

`DotOsgWrapperMap _stateAttrWrapperMap`

`DotOsgWrapperMap _nodeWrapperMap`

`DotOsgWrapperMap _classNameWrapperMap`

`ReaderWriterList _rwList`

`DynamicLibraryList _dlList`

`bool _openingLibrary`

`ExtensionAliasMap _extAliasMap`

`osg::ref_ptr<ReaderWriter::Options> _options`

`FilePathList _dataFilePath`

`FilePathList _libraryFilePath`

`bool _useObjectCacheHint`

`ObjectCache _objectCache`

This class has no child classes.

Alphabetic index HTML hierarchy of classes or Java

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