Options
Go to the documentation of this file.
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef OSGDB_OPTIONS
#define OSGDB_OPTIONS 1
#include <osgDB/Callbacks>
#include <osgDB/ObjectCache>
#include <osg/ObserverNodePath>
#include <deque>
#include <list>
#include <iosfwd>
namespace osgDB {
class OSGDB_EXPORT Options : public osg::Object
{
public:
enum CacheHintOptions
{
CACHE_NONE = 0,
CACHE_NODES = 1<<0,
CACHE_IMAGES = 1<<1,
CACHE_HEIGHTFIELDS = 1<<2,
CACHE_ARCHIVES = 1<<3,
CACHE_OBJECTS = 1<<4,
CACHE_SHADERS = 1<<5,
CACHE_ALL = CACHE_NODES |
CACHE_IMAGES |
CACHE_HEIGHTFIELDS |
CACHE_ARCHIVES |
CACHE_OBJECTS |
CACHE_SHADERS
};
enum PrecisionHint
{
FLOAT_PRECISION_ALL = 0,
DOUBLE_PRECISION_VERTEX = 1<<0,
DOUBLE_PRECISION_NORMAL = 1<<1,
DOUBLE_PRECISION_COLOR = 1<<2,
DOUBLE_PRECISION_SECONDARY_COLOR = 1<<3,
DOUBLE_PRECISION_FOG_COORD = 1<<4,
DOUBLE_PRECISION_TEX_COORD = 1<<5,
DOUBLE_PRECISION_VERTEX_ATTRIB = 1<<6,
DOUBLE_PRECISION_ALL = DOUBLE_PRECISION_VERTEX |
DOUBLE_PRECISION_NORMAL |
DOUBLE_PRECISION_COLOR |
DOUBLE_PRECISION_SECONDARY_COLOR |
DOUBLE_PRECISION_FOG_COORD |
DOUBLE_PRECISION_TEX_COORD |
DOUBLE_PRECISION_VERTEX_ATTRIB
};
enum BuildKdTreesHint
{
NO_PREFERENCE,
DO_NOT_BUILD_KDTREES,
BUILD_KDTREES
};
Options();
Options(const std::string& str);
Options(const Options& options,const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY);
META_Object(osgDB,Options);
Options* cloneOptions(const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY) const { return static_cast<Options*>(clone(copyop)); }
void setOptionString(const std::string& str) { _str = str; parsePluginStringData(str); }
const std::string& getOptionString() const { return _str; }
void setDatabasePath(const std::string& str) { _databasePaths.clear(); _databasePaths.push_back(str); }
FilePathList& getDatabasePathList() { return _databasePaths; }
const FilePathList& getDatabasePathList() const { return _databasePaths; }
void setObjectCacheHint(CacheHintOptions useObjectCache) { _objectCacheHint = useObjectCache; }
CacheHintOptions getObjectCacheHint() const { return _objectCacheHint; }
void setObjectCache(ObjectCache* objectCache) { _objectCache = objectCache; }
ObjectCache* getObjectCache() const { return _objectCache.get(); }
void setPrecisionHint(PrecisionHint hint) { _precisionHint = hint; }
PrecisionHint getPrecisionHint() const { return _precisionHint; }
void setBuildKdTreesHint(BuildKdTreesHint hint) { _buildKdTreesHint = hint; }
BuildKdTreesHint getBuildKdTreesHint() const { return _buildKdTreesHint; }
void setAuthenticationMap(AuthenticationMap* authenticationMap) { _authenticationMap = authenticationMap; }
const AuthenticationMap* getAuthenticationMap() const { return _authenticationMap.get(); }
void setPluginData(const std::string& s, void* v) const { _pluginData[s] = v; }
void* getPluginData(const std::string& s) { return _pluginData[s]; }
const void* getPluginData(const std::string& s) const
{
PluginDataMap::const_iterator itr = _pluginData.find(s);
return (itr == _pluginData.end()) ? 0 : itr->second;
}
void removePluginData(const std::string& s) const { _pluginData.erase(s); }
unsigned int getNumPluginData() const { return static_cast<unsigned int>(_pluginData.size()); }
void setPluginStringData(const std::string& s, const std::string& v) const { _pluginStringData[s] = v; }
std::string& getPluginStringData(const std::string& s) { return _pluginStringData[s]; }
const std::string getPluginStringData(const std::string& s) const
{
PluginStringDataMap::const_iterator itr = _pluginStringData.find(s);
return (itr == _pluginStringData.end()) ? std::string("") : itr->second;
}
void removePluginStringData(const std::string& s) const { _pluginStringData.erase(s); }
unsigned int getNumPluginStringData() const { return static_cast<unsigned int>(_pluginStringData.size()); }
void parsePluginStringData(const std::string& str, char separator1=' ', char separator2='=');
void setFindFileCallback( FindFileCallback* cb) { _findFileCallback = cb; }
FindFileCallback* getFindFileCallback() const { return _findFileCallback.get(); }
void setReadFileCallback( ReadFileCallback* cb) { _readFileCallback = cb; }
ReadFileCallback* getReadFileCallback() const { return _readFileCallback.get(); }
void setWriteFileCallback( WriteFileCallback* cb) { _writeFileCallback = cb; }
WriteFileCallback* getWriteFileCallback() const { return _writeFileCallback.get(); }
void setFileLocationCallback( FileLocationCallback* cb) { _fileLocationCallback = cb; }
FileLocationCallback* getFileLocationCallback() const { return _fileLocationCallback.get(); }
void setFileCache(FileCache* fileCache) { _fileCache = fileCache; }
FileCache* getFileCache() const { return _fileCache.get(); }
void setTerrain(osg::observer_ptr<osg::Node>& terrain) { _terrain = terrain; }
const osg::observer_ptr<osg::Node>& getTerrain() const { return _terrain; }
void setParentGroup(osg::observer_ptr<osg::Group>& parentGroup) { _parentGroup= parentGroup; }
const osg::observer_ptr<osg::Group>& getParentGroup() const { return _parentGroup; }
bool operator < (const Options &rhs) const;
bool operator == (const Options &rhs) const;
protected:
virtual ~Options();
std::string _str;
FilePathList _databasePaths;
CacheHintOptions _objectCacheHint;
osg::ref_ptr<ObjectCache> _objectCache;
PrecisionHint _precisionHint;
BuildKdTreesHint _buildKdTreesHint;
osg::ref_ptr<AuthenticationMap> _authenticationMap;
typedef std::map<std::string,void*> PluginDataMap;
mutable PluginDataMap _pluginData;
typedef std::map<std::string,std::string> PluginStringDataMap;
mutable PluginStringDataMap _pluginStringData;
osg::ref_ptr<FindFileCallback> _findFileCallback;
osg::ref_ptr<ReadFileCallback> _readFileCallback;
osg::ref_ptr<WriteFileCallback> _writeFileCallback;
osg::ref_ptr<FileLocationCallback> _fileLocationCallback;
osg::ref_ptr<FileCache> _fileCache;
osg::observer_ptr<osg::Node> _terrain;
osg::observer_ptr<osg::Group> _parentGroup; // Set by the DatabasePager to the node where the requested file will be inserted. NOTE: observer since prent can be dettached whilst DB thread is loading the object
};
}
#endif // OSGDB_OPTIONS
ObjectCache
ObserverNodePath
osgDB::AuthenticationMap
Definition AuthenticationMap:62
osgDB::FileCache
Definition FileCache:27
osgDB::FileLocationCallback
Definition osgDB/Callbacks:95
osgDB::FindFileCallback
Definition osgDB/Callbacks:40
osgDB::ObjectCache
Definition ObjectCache:27
osgDB::Options::setDatabasePath
void setDatabasePath(const std::string &str)
Definition Options:115
osgDB::Options::_writeFileCallback
osg::ref_ptr< WriteFileCallback > _writeFileCallback
Definition Options:270
osgDB::Options::removePluginData
void removePluginData(const std::string &s) const
Definition Options:171
osgDB::Options::_objectCache
osg::ref_ptr< ObjectCache > _objectCache
Definition Options:257
osgDB::Options::getAuthenticationMap
const AuthenticationMap * getAuthenticationMap() const
Definition Options:154
osgDB::Options::CacheHintOptions
CacheHintOptions
bit mask for setting up which object types get cached by readObject/Image/HeightField/Node(filename) ...
Definition Options:35
osgDB::Options::CACHE_HEIGHTFIELDS
@ CACHE_HEIGHTFIELDS
cache heightfield loaded via readHeightField(filename)
Definition Options:45
osgDB::Options::CACHE_NONE
@ CACHE_NONE
do not cache objects of any type
Definition Options:36
osgDB::Options::CACHE_OBJECTS
@ CACHE_OBJECTS
cache objects loaded via readObject(filename)
Definition Options:51
osgDB::Options::CACHE_IMAGES
@ CACHE_IMAGES
cache images loaded via readImage(filename)
Definition Options:42
osgDB::Options::CACHE_ALL
@ CACHE_ALL
cache on all read*(filename) calls
Definition Options:57
osgDB::Options::CACHE_SHADERS
@ CACHE_SHADERS
cache shaders loaded via readShader(filename)
Definition Options:54
osgDB::Options::CACHE_NODES
@ CACHE_NODES
cache nodes loaded via readNode(filename)
Definition Options:39
osgDB::Options::CACHE_ARCHIVES
@ CACHE_ARCHIVES
cache heightfield loaded via readHeightField(filename)
Definition Options:48
osgDB::Options::setWriteFileCallback
void setWriteFileCallback(WriteFileCallback *cb)
Definition Options:215
osgDB::Options::setObjectCacheHint
void setObjectCacheHint(CacheHintOptions useObjectCache)
Definition Options:125
osgDB::Options::BuildKdTreesHint
BuildKdTreesHint
range of options of whether to build kdtrees automatically on loading
Definition Options:91
osgDB::Options::NO_PREFERENCE
@ NO_PREFERENCE
Definition Options:92
osgDB::Options::BUILD_KDTREES
@ BUILD_KDTREES
Definition Options:94
osgDB::Options::DO_NOT_BUILD_KDTREES
@ DO_NOT_BUILD_KDTREES
Definition Options:93
osgDB::Options::setParentGroup
void setParentGroup(osg::observer_ptr< osg::Group > &parentGroup)
Definition Options:241
osgDB::Options::getPluginStringData
std::string & getPluginStringData(const std::string &s)
Definition Options:181
osgDB::Options::setReadFileCallback
void setReadFileCallback(ReadFileCallback *cb)
Definition Options:208
osgDB::Options::Options
Options()
osgDB::Options::getDatabasePathList
const FilePathList & getDatabasePathList() const
Definition Options:121
osgDB::Options::_databasePaths
FilePathList _databasePaths
Definition Options:254
osgDB::Options::getPluginData
const void * getPluginData(const std::string &s) const
Definition Options:164
osgDB::Options::~Options
virtual ~Options()
osgDB::Options::getDatabasePathList
FilePathList & getDatabasePathList()
Definition Options:118
osgDB::Options::getPrecisionHint
PrecisionHint getPrecisionHint() const
Definition Options:141
osgDB::Options::getTerrain
const osg::observer_ptr< osg::Node > & getTerrain() const
Definition Options:238
osgDB::Options::setBuildKdTreesHint
void setBuildKdTreesHint(BuildKdTreesHint hint)
Definition Options:144
osgDB::Options::getObjectCacheHint
CacheHintOptions getObjectCacheHint() const
Definition Options:128
osgDB::Options::_precisionHint
PrecisionHint _precisionHint
Definition Options:259
osgDB::Options::getPluginStringData
const std::string getPluginStringData(const std::string &s) const
Definition Options:184
osgDB::Options::setOptionString
void setOptionString(const std::string &str)
Definition Options:109
osgDB::Options::getPluginData
void * getPluginData(const std::string &s)
Definition Options:161
osgDB::Options::getNumPluginData
unsigned int getNumPluginData() const
Definition Options:174
osgDB::Options::getParentGroup
const osg::observer_ptr< osg::Group > & getParentGroup() const
Definition Options:244
osgDB::Options::Options
Options(const std::string &str)
osgDB::Options::getFileCache
FileCache * getFileCache() const
Definition Options:231
osgDB::Options::removePluginStringData
void removePluginStringData(const std::string &s) const
Definition Options:191
osgDB::Options::_parentGroup
osg::observer_ptr< osg::Group > _parentGroup
Definition Options:276
osgDB::Options::setAuthenticationMap
void setAuthenticationMap(AuthenticationMap *authenticationMap)
Definition Options:151
osgDB::Options::getReadFileCallback
ReadFileCallback * getReadFileCallback() const
Definition Options:211
osgDB::Options::getObjectCache
ObjectCache * getObjectCache() const
Definition Options:134
osgDB::Options::_findFileCallback
osg::ref_ptr< FindFileCallback > _findFileCallback
Definition Options:268
osgDB::Options::Options
Options(const Options &options, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
osgDB::Options::setPluginData
void setPluginData(const std::string &s, void *v) const
Definition Options:158
osgDB::Options::_fileCache
osg::ref_ptr< FileCache > _fileCache
Definition Options:273
osgDB::Options::_objectCacheHint
CacheHintOptions _objectCacheHint
Definition Options:256
osgDB::Options::PluginStringDataMap
std::map< std::string, std::string > PluginStringDataMap
Definition Options:265
osgDB::Options::parsePluginStringData
void parsePluginStringData(const std::string &str, char separator1=' ', char separator2='=')
osgDB::Options::setFindFileCallback
void setFindFileCallback(FindFileCallback *cb)
Definition Options:201
osgDB::Options::_authenticationMap
osg::ref_ptr< AuthenticationMap > _authenticationMap
Definition Options:261
osgDB::Options::_pluginData
PluginDataMap _pluginData
Definition Options:264
osgDB::Options::setTerrain
void setTerrain(osg::observer_ptr< osg::Node > &terrain)
Definition Options:235
osgDB::Options::getFileLocationCallback
FileLocationCallback * getFileLocationCallback() const
Definition Options:225
osgDB::Options::setFileCache
void setFileCache(FileCache *fileCache)
Definition Options:228
osgDB::Options::PluginDataMap
std::map< std::string, void * > PluginDataMap
Definition Options:263
osgDB::Options::_buildKdTreesHint
BuildKdTreesHint _buildKdTreesHint
Definition Options:260
osgDB::Options::getBuildKdTreesHint
BuildKdTreesHint getBuildKdTreesHint() const
Definition Options:147
osgDB::Options::setPluginStringData
void setPluginStringData(const std::string &s, const std::string &v) const
Definition Options:178
osgDB::Options::_terrain
osg::observer_ptr< osg::Node > _terrain
Definition Options:275
osgDB::Options::getOptionString
const std::string & getOptionString() const
Definition Options:112
osgDB::Options::getFindFileCallback
FindFileCallback * getFindFileCallback() const
Definition Options:204
osgDB::Options::_pluginStringData
PluginStringDataMap _pluginStringData
Definition Options:266
osgDB::Options::getWriteFileCallback
WriteFileCallback * getWriteFileCallback() const
Definition Options:218
osgDB::Options::PrecisionHint
PrecisionHint
Definition Options:69
osgDB::Options::DOUBLE_PRECISION_ALL
@ DOUBLE_PRECISION_ALL
Definition Options:80
osgDB::Options::DOUBLE_PRECISION_SECONDARY_COLOR
@ DOUBLE_PRECISION_SECONDARY_COLOR
Definition Options:75
osgDB::Options::DOUBLE_PRECISION_VERTEX_ATTRIB
@ DOUBLE_PRECISION_VERTEX_ATTRIB
Definition Options:78
osgDB::Options::FLOAT_PRECISION_ALL
@ FLOAT_PRECISION_ALL
Definition Options:70
osgDB::Options::DOUBLE_PRECISION_NORMAL
@ DOUBLE_PRECISION_NORMAL
Definition Options:73
osgDB::Options::DOUBLE_PRECISION_FOG_COORD
@ DOUBLE_PRECISION_FOG_COORD
Definition Options:76
osgDB::Options::DOUBLE_PRECISION_VERTEX
@ DOUBLE_PRECISION_VERTEX
Definition Options:72
osgDB::Options::DOUBLE_PRECISION_TEX_COORD
@ DOUBLE_PRECISION_TEX_COORD
Definition Options:77
osgDB::Options::DOUBLE_PRECISION_COLOR
@ DOUBLE_PRECISION_COLOR
Definition Options:74
osgDB::Options::setObjectCache
void setObjectCache(ObjectCache *objectCache)
Definition Options:131
osgDB::Options::META_Object
META_Object(osgDB, Options)
osgDB::Options::getNumPluginStringData
unsigned int getNumPluginStringData() const
Definition Options:194
osgDB::Options::_readFileCallback
osg::ref_ptr< ReadFileCallback > _readFileCallback
Definition Options:269
osgDB::Options::setFileLocationCallback
void setFileLocationCallback(FileLocationCallback *cb)
Definition Options:222
osgDB::Options::cloneOptions
Options * cloneOptions(const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY) const
Definition Options:106
osgDB::Options::_str
std::string _str
Definition Options:253
osgDB::Options::setPrecisionHint
void setPrecisionHint(PrecisionHint hint)
Definition Options:138
osgDB::Options::_fileLocationCallback
osg::ref_ptr< FileLocationCallback > _fileLocationCallback
Definition Options:271
osgDB::ReadFileCallback
Definition osgDB/Callbacks:53
osgDB::WriteFileCallback
Definition osgDB/Callbacks:75
osg::CopyOp
Definition CopyOp:41
osg::CopyOp::SHALLOW_COPY
@ SHALLOW_COPY
Definition CopyOp:47
osg::Object
Definition Object:61
osg::Object::clone
virtual Object * clone(const CopyOp &) const =0
osg::observer_ptr
Definition observer_ptr:39
osg::ref_ptr
Definition ref_ptr:32
osgDB
Definition Archive:24
osgDB::FilePathList
std::deque< std::string > FilePathList
Definition osgDB/Callbacks:28
Callbacks
OSGDB_EXPORT
#define OSGDB_EXPORT
Definition osgDB/Export:39