OpenSceneGraph 3.6.5
Options
Go to the documentation of this file.
1/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2 *
3 * This library is open source and may be redistributed and/or modified under
4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
5 * (at your option) any later version. The full license is in LICENSE file
6 * included with this distribution, and on the openscenegraph.org website.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * OpenSceneGraph Public License for more details.
12*/
13
14#ifndef OSGDB_OPTIONS
15#define OSGDB_OPTIONS 1
16
17#include <osgDB/Callbacks>
18#include <osgDB/ObjectCache>
19#include <osg/ObserverNodePath>
20
21#include <deque>
22#include <list>
23#include <iosfwd>
24
25namespace osgDB {
26
27
30{
31 public:
32
64
88
96
97
99
100 Options(const std::string& str);
101
103
105
106 Options* cloneOptions(const osg::CopyOp& copyop=osg::CopyOp::SHALLOW_COPY) const { return static_cast<Options*>(clone(copyop)); }
107
109 void setOptionString(const std::string& str) { _str = str; parsePluginStringData(str); }
110
112 const std::string& getOptionString() const { return _str; }
113
115 void setDatabasePath(const std::string& str) { _databasePaths.clear(); _databasePaths.push_back(str); }
116
119
122
123
125 void setObjectCacheHint(CacheHintOptions useObjectCache) { _objectCacheHint = useObjectCache; }
126
129
131 void setObjectCache(ObjectCache* objectCache) { _objectCache = objectCache; }
132
134 ObjectCache* getObjectCache() const { return _objectCache.get(); }
135
136
139
142
145
148
149
151 void setAuthenticationMap(AuthenticationMap* authenticationMap) { _authenticationMap = authenticationMap; }
152
155
156
158 void setPluginData(const std::string& s, void* v) const { _pluginData[s] = v; }
159
161 void* getPluginData(const std::string& s) { return _pluginData[s]; }
162
164 const void* getPluginData(const std::string& s) const
165 {
166 PluginDataMap::const_iterator itr = _pluginData.find(s);
167 return (itr == _pluginData.end()) ? 0 : itr->second;
168 }
169
171 void removePluginData(const std::string& s) const { _pluginData.erase(s); }
172
174 unsigned int getNumPluginData() const { return static_cast<unsigned int>(_pluginData.size()); }
175
176
178 void setPluginStringData(const std::string& s, const std::string& v) const { _pluginStringData[s] = v; }
179
181 std::string& getPluginStringData(const std::string& s) { return _pluginStringData[s]; }
182
184 const std::string getPluginStringData(const std::string& s) const
185 {
186 PluginStringDataMap::const_iterator itr = _pluginStringData.find(s);
187 return (itr == _pluginStringData.end()) ? std::string("") : itr->second;
188 }
189
191 void removePluginStringData(const std::string& s) const { _pluginStringData.erase(s); }
192
194 unsigned int getNumPluginStringData() const { return static_cast<unsigned int>(_pluginStringData.size()); }
195
197 void parsePluginStringData(const std::string& str, char separator1=' ', char separator2='=');
198
199
202
205
206
209
212
213
216
219
220
223
226
228 void setFileCache(FileCache* fileCache) { _fileCache = fileCache; }
229
231 FileCache* getFileCache() const { return _fileCache.get(); }
232
233
236
239
241 void setParentGroup(osg::observer_ptr<osg::Group>& parentGroup) { _parentGroup= parentGroup; }
242
245
246 bool operator < (const Options &rhs) const;
247 bool operator == (const Options &rhs) const;
248
249 protected:
250
251 virtual ~Options();
252
253 std::string _str;
255
258
262
263 typedef std::map<std::string,void*> PluginDataMap;
265 typedef std::map<std::string,std::string> PluginStringDataMap;
267
272
274
276 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
277};
278
279}
280
281#endif // OSGDB_OPTIONS
The osgDB library provides support for reading and writing scene graphs, providing a plugin framework...
Definition Archive:24
std::deque< std::string > FilePathList
list of directories to search through which searching for files.
Definition Callbacks:28
Copy Op(erator) used to control whether shallow or deep copy is used during copy construction and clo...
Definition CopyOp:41
@ SHALLOW_COPY
Definition CopyOp:47
Base class/standard interface for objects which require IO support, cloning and reference counting.
Definition Object:61
virtual Object * clone(const CopyOp &) const =0
Clone an object, with Object* return type.
Smart pointer for observed objects, that automatically set pointers to them to null when they are del...
Definition observer_ptr:39
Smart pointer for handling referenced counted objects.
Definition ref_ptr:32
Definition AuthenticationMap:62
Definition Callbacks:40
Definition Callbacks:53
Definition Callbacks:75
Definition Callbacks:95
Definition FileCache:27
Definition ObjectCache:27
void setDatabasePath(const std::string &str)
Set the database path to use a hint of where to look when loading models.
Definition Options:115
osg::ref_ptr< WriteFileCallback > _writeFileCallback
Definition Options:270
void removePluginData(const std::string &s) const
Remove a value from the PluginData.
Definition Options:171
osg::ref_ptr< ObjectCache > _objectCache
Definition Options:257
const AuthenticationMap * getAuthenticationMap() const
Get the password map to be used by plugins when access files from secure locations.
Definition Options:154
CacheHintOptions
bit mask for setting up which object types get cached by readObject/Image/HeightField/Node(filename) ...
Definition Options:35
@ CACHE_HEIGHTFIELDS
cache heightfield loaded via readHeightField(filename)
Definition Options:45
@ CACHE_NONE
do not cache objects of any type
Definition Options:36
@ CACHE_OBJECTS
cache objects loaded via readObject(filename)
Definition Options:51
@ CACHE_IMAGES
cache images loaded via readImage(filename)
Definition Options:42
@ CACHE_ALL
cache on all read*(filename) calls
Definition Options:57
@ CACHE_SHADERS
cache shaders loaded via readShader(filename)
Definition Options:54
@ CACHE_NODES
cache nodes loaded via readNode(filename)
Definition Options:39
@ CACHE_ARCHIVES
cache heightfield loaded via readHeightField(filename)
Definition Options:48
void setWriteFileCallback(WriteFileCallback *cb)
Set the callback to use in place of the default writeFile calls.
Definition Options:215
void setObjectCacheHint(CacheHintOptions useObjectCache)
Set whether the Registry::ObjectCache should be used by default.
Definition Options:125
BuildKdTreesHint
range of options of whether to build kdtrees automatically on loading
Definition Options:91
@ NO_PREFERENCE
Definition Options:92
@ BUILD_KDTREES
Definition Options:94
@ DO_NOT_BUILD_KDTREES
Definition Options:93
void setParentGroup(osg::observer_ptr< osg::Group > &parentGroup)
Set the parentGroup observer_ptr, where the loaded model is intended to be added.
Definition Options:241
std::string & getPluginStringData(const std::string &s)
Get a string from the PluginStrData.
Definition Options:181
void setReadFileCallback(ReadFileCallback *cb)
Set the read callback to use in place of the default readFile calls.
Definition Options:208
const FilePathList & getDatabasePathList() const
Get the const database path which is used a hint of where to look when loading models.
Definition Options:121
FilePathList _databasePaths
Definition Options:254
const void * getPluginData(const std::string &s) const
Get a value from the PluginData.
Definition Options:164
virtual ~Options()
FilePathList & getDatabasePathList()
Get the database path which is used a hint of where to look when loading models.
Definition Options:118
PrecisionHint getPrecisionHint() const
Get which geometry attributes plugins should import at double precision.
Definition Options:141
const osg::observer_ptr< osg::Node > & getTerrain() const
Get the terrain observer_ptr, use to decorate any osgTerrain subgraphs.
Definition Options:238
void setBuildKdTreesHint(BuildKdTreesHint hint)
Set whether the KdTrees should be built for geometry in the loader model.
Definition Options:144
CacheHintOptions getObjectCacheHint() const
Get whether the Registry::ObjectCache should be used by default.
Definition Options:128
PrecisionHint _precisionHint
Definition Options:259
const std::string getPluginStringData(const std::string &s) const
Get a value from the PluginData.
Definition Options:184
void setOptionString(const std::string &str)
Set the general Options string.
Definition Options:109
void * getPluginData(const std::string &s)
Get a value from the PluginData.
Definition Options:161
unsigned int getNumPluginData() const
Get number of PluginData values.
Definition Options:174
const osg::observer_ptr< osg::Group > & getParentGroup() const
Get the parentGroup observer_ptr, where the loaded model is intended to be added.
Definition Options:244
Options(const std::string &str)
FileCache * getFileCache() const
Get the FileCache that is used to manage local storage of files downloaded from the internet.
Definition Options:231
void removePluginStringData(const std::string &s) const
Remove a value from the PluginData.
Definition Options:191
osg::observer_ptr< osg::Group > _parentGroup
Definition Options:276
void setAuthenticationMap(AuthenticationMap *authenticationMap)
Set the password map to be used by plugins when access files from secure locations.
Definition Options:151
ReadFileCallback * getReadFileCallback() const
Get the const readFile callback.
Definition Options:211
ObjectCache * getObjectCache() const
Get the ObjectCache that is used to cache previously loaded data.
Definition Options:134
osg::ref_ptr< FindFileCallback > _findFileCallback
Definition Options:268
Options(const Options &options, const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY)
void setPluginData(const std::string &s, void *v) const
Sets a plugindata value PluginData with a string.
Definition Options:158
osg::ref_ptr< FileCache > _fileCache
Definition Options:273
CacheHintOptions _objectCacheHint
Definition Options:256
std::map< std::string, std::string > PluginStringDataMap
Definition Options:265
void parsePluginStringData(const std::string &str, char separator1=' ', char separator2='=')
Parse string into plugin string data.
void setFindFileCallback(FindFileCallback *cb)
Set the find callback to use in place of the default findFile calls.
Definition Options:201
osg::ref_ptr< AuthenticationMap > _authenticationMap
Definition Options:261
PluginDataMap _pluginData
Definition Options:264
void setTerrain(osg::observer_ptr< osg::Node > &terrain)
Set the terrain observer_ptr, use to decorate any osgTerrain subgraphs.
Definition Options:235
FileLocationCallback * getFileLocationCallback() const
Get the callback to use inform the DatabasePager whether a file is located on local or remote file sy...
Definition Options:225
void setFileCache(FileCache *fileCache)
Set the FileCache that is used to manage local storage of files downloaded from the internet.
Definition Options:228
std::map< std::string, void * > PluginDataMap
Definition Options:263
BuildKdTreesHint _buildKdTreesHint
Definition Options:260
BuildKdTreesHint getBuildKdTreesHint() const
Get whether the KdTrees should be built for geometry in the loader model.
Definition Options:147
void setPluginStringData(const std::string &s, const std::string &v) const
Sets a plugindata value PluginData with a string.
Definition Options:178
osg::observer_ptr< osg::Node > _terrain
Definition Options:275
const std::string & getOptionString() const
Get the general Options string.
Definition Options:112
FindFileCallback * getFindFileCallback() const
Get the const findFile callback.
Definition Options:204
PluginStringDataMap _pluginStringData
Definition Options:266
WriteFileCallback * getWriteFileCallback() const
Get the const writeFile callback.
Definition Options:218
PrecisionHint
Bit mask for which geometry attributes should be imported with double precision where source data is ...
Definition Options:69
@ DOUBLE_PRECISION_ALL
Definition Options:80
@ DOUBLE_PRECISION_SECONDARY_COLOR
Definition Options:75
@ DOUBLE_PRECISION_VERTEX_ATTRIB
Definition Options:78
@ FLOAT_PRECISION_ALL
Definition Options:70
@ DOUBLE_PRECISION_NORMAL
Definition Options:73
@ DOUBLE_PRECISION_FOG_COORD
Definition Options:76
@ DOUBLE_PRECISION_VERTEX
Definition Options:72
@ DOUBLE_PRECISION_TEX_COORD
Definition Options:77
@ DOUBLE_PRECISION_COLOR
Definition Options:74
void setObjectCache(ObjectCache *objectCache)
Set the ObjectCache that is used to cache previously loaded data.
Definition Options:131
META_Object(osgDB, Options)
unsigned int getNumPluginStringData() const
Get number of PluginStrData values.
Definition Options:194
osg::ref_ptr< ReadFileCallback > _readFileCallback
Definition Options:269
void setFileLocationCallback(FileLocationCallback *cb)
Set the callback to use inform the DatabasePager whether a file is located on local or remote file sy...
Definition Options:222
Options * cloneOptions(const osg::CopyOp &copyop=osg::CopyOp::SHALLOW_COPY) const
Definition Options:106
std::string _str
Definition Options:253
void setPrecisionHint(PrecisionHint hint)
Set which geometry attributes plugins should import at double precision.
Definition Options:138
osg::ref_ptr< FileLocationCallback > _fileLocationCallback
Definition Options:271
#define OSGDB_EXPORT
Definition Export:39

osg logo
Generated at Sun Jul 27 2025 00:00:00 for the OpenSceneGraph by doxygen 1.14.0.