OpenSceneGraph 3.6.5
Registry
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_REGISTRY
15#define OSGDB_REGISTRY 1
16
17#include <OpenThreads/ReentrantMutex>
18
19#include <osg/ref_ptr>
20#include <osg/ArgumentParser>
21#include <osg/KdTree>
22
23#include <osgDB/DynamicLibrary>
24#include <osgDB/ReaderWriter>
25#include <osgDB/Options>
26#include <osgDB/DotOsgWrapper>
27#include <osgDB/ObjectWrapper>
28#include <osgDB/FileCache>
29#include <osgDB/ObjectCache>
31#include <osgDB/ImageProcessor>
32
33#include <vector>
34#include <map>
35#include <string>
36
37extern "C"
38{
39 typedef void (* CPluginFunction) (void);
40}
41
42namespace osgDB {
43
44
54{
55 public:
56
57
58
59
60 static Registry* instance(bool erase = false);
61
64
70 void addFileExtensionAlias(const std::string mapExt, const std::string toExt);
71
75 bool readPluginAliasConfigurationFile( const std::string& file );
76
77 typedef std::map< std::string, std::string> MimeTypeExtensionMap;
78
83 void addMimeTypeExtensionMapping(const std::string fromMimeType, const std::string toExt);
86
89
92
94 std::string createLibraryNameForFile(const std::string& fileName);
95
97 std::string createLibraryNameForExtension(const std::string& ext);
98
100 std::string createLibraryNameForNodeKit(const std::string& name);
101
102
108
110 LoadStatus loadLibrary(const std::string& fileName);
111
113 bool closeLibrary(const std::string& fileName);
114
117
118 typedef std::vector< osg::ref_ptr<ReaderWriter> > ReaderWriterList;
119
122
125 ReaderWriter* getReaderWriterForMimeType(const std::string& mimeType);
126
129
132
134 void getReaderWriterListForProtocol(const std::string& protocol, ReaderWriterList& results) const;
135
136 ReaderWriter* getReaderWriterForProtocolAndExtension(const std::string& protocol, const std::string& extension);
137
138
139 typedef std::vector< osg::ref_ptr<ImageProcessor> > ImageProcessorList;
140
143
146
149
152
153
158
161
164
167
168
169 std::string findDataFile(const std::string& fileName, const Options* options, CaseSensitivity caseSensitivity)
170 {
171 if (options && options->getFindFileCallback()) return options->getFindFileCallback()->findDataFile(fileName, options, caseSensitivity);
172 else if (_findFileCallback.valid()) return _findFileCallback->findDataFile(fileName, options, caseSensitivity);
173 else return findDataFileImplementation(fileName, options, caseSensitivity);
174 }
175 std::string findDataFileImplementation(const std::string& fileName, const Options* options, CaseSensitivity caseSensitivity);
176
177 std::string findLibraryFile(const std::string& fileName, const Options* options, CaseSensitivity caseSensitivity)
178 {
179 if (options && options->getFindFileCallback()) return options->getFindFileCallback()->findLibraryFile(fileName, options, caseSensitivity);
180 else if (_findFileCallback.valid()) return _findFileCallback->findLibraryFile(fileName, options, caseSensitivity);
181 else return findLibraryFileImplementation(fileName, options, caseSensitivity);
182 }
183 std::string findLibraryFileImplementation(const std::string& fileName, const Options* options, CaseSensitivity caseSensitivity);
184
185
186
189
192
195
196
197 ReaderWriter::ReadResult openArchive(const std::string& fileName,ReaderWriter::ArchiveStatus status, unsigned int indexBlockSizeHint, const Options* options)
198 {
199 if (options && options->getReadFileCallback()) return options->getReadFileCallback()->openArchive(fileName, status, indexBlockSizeHint, options);
200 else if (_readFileCallback.valid()) return _readFileCallback->openArchive(fileName, status, indexBlockSizeHint, options);
201 else return openArchiveImplementation(fileName, status, indexBlockSizeHint, options);
202 }
203 ReaderWriter::ReadResult openArchiveImplementation(const std::string& fileName, ReaderWriter::ArchiveStatus status, unsigned int indexBlockSizeHint, const Options* options);
204
205 ReaderWriter::ReadResult readObject(const std::string& fileName,const Options* options, bool buildKdTreeIfRequired=true)
206 {
208 if (options && options->getReadFileCallback()) result = options->getReadFileCallback()->readObject(fileName,options);
209 else if (_readFileCallback.valid()) result = _readFileCallback->readObject(fileName,options);
210 else result = readObjectImplementation(fileName,options);
211
212 if (buildKdTreeIfRequired) _buildKdTreeIfRequired(result, options);
213
214 return result;
215 }
216 ReaderWriter::ReadResult readObjectImplementation(const std::string& fileName,const Options* options);
217
218 ReaderWriter::ReadResult readImage(const std::string& fileName,const Options* options)
219 {
220 if (options && options->getReadFileCallback()) return options->getReadFileCallback()->readImage(fileName,options);
221 else if (_readFileCallback.valid()) return _readFileCallback->readImage(fileName,options);
222 else return readImageImplementation(fileName,options);
223 }
224 ReaderWriter::ReadResult readImageImplementation(const std::string& fileName,const Options* options);
225
226 ReaderWriter::ReadResult readHeightField(const std::string& fileName,const Options* options)
227 {
228 if (options && options->getReadFileCallback()) return options->getReadFileCallback()->readHeightField(fileName,options);
229 else if (_readFileCallback.valid()) return _readFileCallback->readHeightField(fileName,options);
230 else return readHeightFieldImplementation(fileName,options);
231 }
232 ReaderWriter::ReadResult readHeightFieldImplementation(const std::string& fileName,const Options* options);
233
234 ReaderWriter::ReadResult readNode(const std::string& fileName,const Options* options, bool buildKdTreeIfRequired=true)
235 {
237 if (options && options->getReadFileCallback()) result = options->getReadFileCallback()->readNode(fileName,options);
238 else if (_readFileCallback.valid()) result = _readFileCallback->readNode(fileName,options);
239 else result = readNodeImplementation(fileName,options);
240
241 if (buildKdTreeIfRequired) _buildKdTreeIfRequired(result, options);
242
243 return result;
244 }
245 ReaderWriter::ReadResult readNodeImplementation(const std::string& fileName,const Options* options);
246
247 ReaderWriter::ReadResult readShader(const std::string& fileName,const Options* options)
248 {
249 if (options && options->getReadFileCallback()) return options->getReadFileCallback()->readShader(fileName,options);
250 if (_readFileCallback.valid()) return _readFileCallback->readShader(fileName,options);
251 else return readShaderImplementation(fileName,options);
252 }
253 ReaderWriter::ReadResult readShaderImplementation(const std::string& fileName,const Options* options);
254
255 ReaderWriter::ReadResult readScript(const std::string& fileName,const Options* options)
256 {
257 if (options && options->getReadFileCallback()) return options->getReadFileCallback()->readScript(fileName,options);
258 else if (_readFileCallback.valid()) return _readFileCallback->readScript(fileName,options);
259 else return readScriptImplementation(fileName,options);
260 }
261 ReaderWriter::ReadResult readScriptImplementation(const std::string& fileName,const Options* options);
262
263
266
269
272
273
274 ReaderWriter::WriteResult writeObject(const osg::Object& obj, const std::string& fileName,const Options* options)
275 {
276 if (options && options->getWriteFileCallback()) return options->getWriteFileCallback()->writeObject(obj,fileName,options);
277 else if (_writeFileCallback.valid()) return _writeFileCallback->writeObject(obj,fileName,options);
278 else return writeObjectImplementation(obj,fileName,options);
279 }
280 ReaderWriter::WriteResult writeObjectImplementation(const osg::Object& obj, const std::string& fileName,const Options* options);
281
282 ReaderWriter::WriteResult writeImage(const osg::Image& obj, const std::string& fileName,const Options* options)
283 {
284 if (options && options->getWriteFileCallback()) return options->getWriteFileCallback()->writeImage(obj,fileName,options);
285 else if (_writeFileCallback.valid()) return _writeFileCallback->writeImage(obj,fileName,options);
286 else return writeImageImplementation(obj,fileName,options);
287 }
288 ReaderWriter::WriteResult writeImageImplementation(const osg::Image& obj, const std::string& fileName,const Options* options);
289
290 ReaderWriter::WriteResult writeHeightField(const osg::HeightField& obj, const std::string& fileName,const Options* options)
291 {
292 if (options && options->getWriteFileCallback()) return options->getWriteFileCallback()->writeHeightField(obj,fileName,options);
293 else if (_writeFileCallback.valid()) return _writeFileCallback->writeHeightField(obj,fileName,options);
294 else return writeHeightFieldImplementation(obj,fileName,options);
295 }
296 ReaderWriter::WriteResult writeHeightFieldImplementation(const osg::HeightField& obj, const std::string& fileName,const Options* options);
297
298 ReaderWriter::WriteResult writeNode(const osg::Node& node, const std::string& fileName,const Options* options)
299 {
300 if (options && options->getWriteFileCallback()) return options->getWriteFileCallback()->writeNode(node,fileName,options);
301 else if (_writeFileCallback.valid()) return _writeFileCallback->writeNode(node,fileName,options);
302 else return writeNodeImplementation(node,fileName,options);
303 }
304 ReaderWriter::WriteResult writeNodeImplementation(const osg::Node& node, const std::string& fileName,const Options* options);
305
306 ReaderWriter::WriteResult writeShader(const osg::Shader& obj, const std::string& fileName,const Options* options)
307 {
308 if (options && options->getWriteFileCallback()) return options->getWriteFileCallback()->writeShader(obj,fileName,options);
309 else if (_writeFileCallback.valid()) return _writeFileCallback->writeShader(obj,fileName,options);
310 else return writeShaderImplementation(obj,fileName,options);
311 }
312 ReaderWriter::WriteResult writeShaderImplementation(const osg::Shader& obj, const std::string& fileName,const Options* options);
313
314 ReaderWriter::WriteResult writeScript(const osg::Script& obj, const std::string& fileName,const Options* options)
315 {
316 if (options && options->getWriteFileCallback()) return options->getWriteFileCallback()->writeScript(obj,fileName,options);
317 else if (_writeFileCallback.valid()) return _writeFileCallback->writeScript(obj,fileName,options);
318 else return writeScriptImplementation(obj,fileName,options);
319 }
320 ReaderWriter::WriteResult writeScriptImplementation(const osg::Script& obj, const std::string& fileName,const Options* options);
321
322 inline void _buildKdTreeIfRequired(ReaderWriter::ReadResult& result, const Options* options)
323 {
324 bool doKdTreeBuilder = (options && options->getBuildKdTreesHint()!=Options::NO_PREFERENCE) ?
327
328 if (doKdTreeBuilder && _kdTreeBuilder.valid() && result.validNode())
329 {
331 result.getNode()->accept(*builder);
332 }
333 }
334
337
340
341
342
345
348
351
354
355
357 void setFileCache(FileCache* fileCache) { _fileCache = fileCache; }
358
360 FileCache* getFileCache() { return _fileCache.get(); }
361
363 const FileCache* getFileCache() const { return _fileCache.get(); }
364
365
367 void setAuthenticationMap(AuthenticationMap* authenticationMap) { _authenticationMap = authenticationMap; }
368
375
378
381
382
385
386
387 void setOptions(Options* opt) { _options = opt; }
388 Options* getOptions() { return _options.get(); }
389 const Options* getOptions() const { return _options.get(); }
390
391
396
399
401 void setDataFilePathList(const FilePathList& filepath) { _dataFilePath = filepath; }
402
404 void setDataFilePathList(const std::string& paths);
405
408
411
415
417 void setLibraryFilePathList(const FilePathList& filepath) { _libraryFilePath = filepath; }
418
420 void setLibraryFilePathList(const std::string& paths);
421
424
427
428
429
431 void setObjectCache(ObjectCache* objectCache) { _objectCache = objectCache; }
432
435
437 const ObjectCache* getObjectCache() const { return _objectCache.get(); }
438
440 void setExpiryDelay(double expiryDelay) { _expiryDelay = expiryDelay; }
441
442 double getExpiryDelay() const { return _expiryDelay; }
443
451
457
460
462 void addEntryToObjectCache(const std::string& filename, osg::Object* object, double timestamp = 0.0, Options *options = NULL);
463
465 void removeFromObjectCache(const std::string& fileName, Options *options = NULL);
466
468 osg::Object* getFromObjectCache(const std::string& fileName, Options *options = NULL);
469
471 osg::ref_ptr<osg::Object> getRefFromObjectCache(const std::string& fileName, Options *options = NULL);
472
473
474
476 void addToArchiveCache(const std::string& fileName, osgDB::Archive* archive);
477
479 void removeFromArchiveCache(const std::string& fileName);
480
482 osgDB::Archive* getFromArchiveCache(const std::string& fileName);
483
486
489
494
496 DynamicLibrary* getLibrary(const std::string& fileName);
497
500
503
506
508 void addArchiveExtension(const std::string ext);
509
511 void registerProtocol(const std::string& protocol);
512
514 bool isProtocolRegistered(const std::string& protocol);
515
518
521
522 typedef std::vector< std::string> ArchiveExtensionList;
524
525 protected:
526
527 virtual ~Registry();
528
529 typedef std::vector< osg::ref_ptr<DynamicLibrary> > DynamicLibraryList;
530 typedef std::map< std::string, std::string> ExtensionAliasMap;
531
532 typedef std::map<std::string, osg::ref_ptr<osgDB::Archive> > ArchiveCache;
533
534 typedef std::set<std::string> RegisteredProtocolsSet;
535
540
542 DynamicLibraryList::iterator getLibraryItr(const std::string& fileName);
543
546
548
550
552
554
555 public:
558 {
559 ReadFunctor(const std::string& filename, const Options* options):
560 _filename(filename),
561 _options(options) {}
562
563 virtual ~ReadFunctor() {}
565 virtual bool isValid(ReaderWriter::ReadResult& readResult) const = 0;
566 virtual bool isValid(osg::Object* object) const = 0;
567
568 virtual ReadFunctor* cloneType(const std::string& filename, const Options* options) const = 0;
569
570 std::string _filename;
572 };
573
574 protected:
575
576 void destruct();
577
578 // forward declare helper classes
579 struct ReadObjectFunctor;
580 struct ReadImageFunctor;
582 struct ReadNodeFunctor;
583 struct ReadArchiveFunctor;
584 struct ReadShaderFunctor;
585 struct ReadScriptFunctor;
586
587 // make helper classes friends to get round VS6.0 "issues"
588 friend struct ReadFunctor;
589 friend struct ReadObjectFunctor;
590 friend struct ReadImageFunctor;
592 friend struct ReadNodeFunctor;
593 friend struct ReadArchiveFunctor;
594 friend struct ReadShaderFunctor;
595 friend struct ReadScriptFunctor;
596
599
600
601 // forward declare helper class
606
607
612
613 OpenThreads::ReentrantMutex _pluginMutex;
617
618 OpenThreads::ReentrantMutex _archiveCacheMutex;
620
622
623 // map to alias to extensions to plugins.
625
626 // maps mime-types to extensions.
628
629 // Utility: Removes whitespace from both ends of a string.
630 static std::string trim( const std::string& str );
631
632 // options to pass to reader writers.
634
637
639
641
642
644
646
649};
650
653{
655}
656
658template<class T>
660{
661 public:
663 {
664 if (Registry::instance())
665 {
666 _rw = new T;
668 }
669 }
670
672 {
673 if (Registry::instance())
674 {
676 }
677 }
678
679 T* get() { return _rw.get(); }
680
681 protected:
683};
684
685
687template<class T>
689{
690 public:
692 {
693 if (Registry::instance())
694 {
695 _rw = new T;
697 }
698 }
699
707
708 T* get() { return _rw.get(); }
709
710 protected:
712};
713
715{
716 PluginFunctionProxy(CPluginFunction function) { (function)(); }
717};
718
719#define USE_OSGPLUGIN(ext) \
720 extern "C" void osgdb_##ext(void); \
721 static osgDB::PluginFunctionProxy proxy_##ext(osgdb_##ext);
722
723#define USE_DOTOSGWRAPPER(classname) \
724 extern "C" void dotosgwrapper_##classname(void); \
725 static osgDB::PluginFunctionProxy proxy_dotosgwrapper_##classname(dotosgwrapper_##classname);
726
727#define USE_DOTOSGWRAPPER_LIBRARY(libname) \
728 extern "C" void dotosgwrapper_library_##libname(void); \
729 static osgDB::PluginFunctionProxy proxy_dotosgwrapper_library_##libname(dotosgwrapper_library_##libname);
730
731#define USE_SERIALIZER_WRAPPER(classname) \
732 extern "C" void wrapper_serializer_##classname(void); \
733 static osgDB::PluginFunctionProxy proxy_serializer_##classname(wrapper_serializer_##classname);
734
735#define USE_SERIALIZER_WRAPPER_LIBRARY(libname) \
736 extern "C" void wrapper_serializer_library_##libname(void); \
737 static osgDB::PluginFunctionProxy proxy_serializer_library_##libname(wrapper_serializer_library_##libname);
738
739#define USE_COMPRESSOR_WRAPPER(classname) \
740 extern "C" void wrapper_compressor_##classname(void); \
741 static osgDB::PluginFunctionProxy proxy_compressor_##classname(wrapper_compressor_##classname);
742
743#define REGISTER_OSGPLUGIN(ext, classname) \
744 extern "C" void osgdb_##ext(void) {} \
745 static osgDB::RegisterReaderWriterProxy<classname> g_proxy_##classname;
746
747#define REGISTER_OSGIMAGEPROCESSOR(ext, classname) \
748 extern "C" void osgdb_##ext(void) {} \
749 static osgDB::RegisterImageProcessorProxy<classname> g_proxy_##classname;
750
751}
752
753#endif
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
CaseSensitivity
Definition Callbacks:31
void readCommandLine(osg::ArgumentParser &parser)
read the command line arguments.
Definition Registry:652
Definition ArgumentParser:28
Class which encapsulates the frame number, reference time and calendar time of specific frame,...
Definition FrameStamp:35
Image class for encapsulating the storage texture image data.
Definition Image:179
Definition KdTree:193
Base class for all internal nodes in the scene graph.
Definition Node:72
virtual void accept(NodeVisitor &nv)
Visitor Pattern : calls the apply method of a NodeVisitor with this node's type.
Base class/standard interface for objects which require IO support, cloning and reference counting.
Definition Object:61
Smart pointer for handling referenced counted objects.
Definition ref_ptr:32
Base class for providing reference counted objects.
Definition Referenced:44
Definition ScriptEngine:30
osg::Shader is an application-level abstraction of an OpenGL glShader.
Definition Shader:89
Definition Shape:483
Encapsulates the current applied OpenGL modes, attributes and vertex arrays settings,...
Definition State:80
Base class for implementing database Archives.
Definition Archive:29
Definition AuthenticationMap:62
Definition Callbacks:40
virtual std::string findDataFile(const std::string &filename, const Options *options, CaseSensitivity caseSensitivity)
virtual std::string findLibraryFile(const std::string &filename, const Options *options, CaseSensitivity caseSensitivity)
Definition Callbacks:53
virtual ReaderWriter::ReadResult readHeightField(const std::string &filename, const Options *options)
virtual ReaderWriter::ReadResult openArchive(const std::string &filename, ReaderWriter::ArchiveStatus status, unsigned int indexBlockSizeHint, const Options *useObjectCache)
virtual ReaderWriter::ReadResult readShader(const std::string &filename, const Options *options)
virtual ReaderWriter::ReadResult readImage(const std::string &filename, const Options *options)
virtual ReaderWriter::ReadResult readObject(const std::string &filename, const Options *options)
virtual ReaderWriter::ReadResult readNode(const std::string &filename, const Options *options)
virtual ReaderWriter::ReadResult readScript(const std::string &filename, const Options *options)
Definition Callbacks:75
virtual ReaderWriter::WriteResult writeHeightField(const osg::HeightField &obj, const std::string &fileName, const Options *options)
virtual ReaderWriter::WriteResult writeScript(const osg::Script &obj, const std::string &fileName, const Options *options)
virtual ReaderWriter::WriteResult writeImage(const osg::Image &obj, const std::string &fileName, const Options *options)
virtual ReaderWriter::WriteResult writeNode(const osg::Node &obj, const std::string &fileName, const Options *options)
virtual ReaderWriter::WriteResult writeShader(const osg::Shader &obj, const std::string &fileName, const Options *options)
virtual ReaderWriter::WriteResult writeObject(const osg::Object &obj, const std::string &fileName, const Options *options)
Definition Callbacks:95
deprecated.
Definition DotOsgWrapper:84
DynamicLibrary - encapsulates the loading and unloading of dynamic libraries, typically used for load...
Definition DynamicLibrary:29
Definition FileCache:27
Definition ImageProcessor:22
Definition ObjectCache:27
Definition ObjectWrapper:157
Options base class used for passing options into plugins to control their operation.
Definition Options:30
CacheHintOptions
bit mask for setting up which object types get cached by readObject/Image/HeightField/Node(filename) ...
Definition Options:35
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
ReadFileCallback * getReadFileCallback() const
Get the const readFile callback.
Definition Options:211
BuildKdTreesHint getBuildKdTreesHint() const
Get whether the KdTrees should be built for geometry in the loader model.
Definition Options:147
FindFileCallback * getFindFileCallback() const
Get the const findFile callback.
Definition Options:204
WriteFileCallback * getWriteFileCallback() const
Get the const writeFile callback.
Definition Options:218
Pure virtual base class for reading and writing of non native formats.
Definition ReaderWriter:40
ArchiveStatus
Definition ReaderWriter:221
Definition ReaderWriter:109
bool validNode()
Definition ReaderWriter:148
Definition ReaderWriter:184
osg::ref_ptr< FileCache > _fileCache
Definition Registry:547
osg::ref_ptr< AuthenticationMap > _authenticationMap
Definition Registry:549
friend struct ReadImageFunctor
Definition Registry:590
ImageProcessor * getImageProcessorForExtension(const std::string &ext)
get a image processor which is associated specified extension.
FileCache * getFileCache()
Get the FileCache that is used to manage local storage of files downloaded from the internet.
Definition Registry:360
const ObjectCache * getObjectCache() const
Get the const ObjectCache that is used to manage local storage of files downloaded from the internet.
Definition Registry:437
osg::KdTreeBuilder * getKdTreeBuilder()
Get the KdTreeBuilder visitor that is used to build KdTree on loaded models.
Definition Registry:353
void setReadFileCallback(ReadFileCallback *cb)
Set the Registry callback to use in place of the default readFile calls.
Definition Registry:188
void removeExpiredObjectsInCache(const osg::FrameStamp &frameStamp)
Removed object in the cache which have a time stamp at or before the specified expiry time.
std::vector< std::string > ArchiveExtensionList
Definition Registry:522
ReaderWriter::ReadResult read(const ReadFunctor &readFunctor)
void addFileExtensionAlias(const std::string mapExt, const std::string toExt)
register an .fileextension alias to mapExt toExt, the later should be the extension name of the reade...
static std::string trim(const std::string &str)
void removeReaderWriter(ReaderWriter *rw)
bool getCreateNodeFromImage() const
Definition Registry:384
FilePathList & getLibraryFilePathList()
get the library file path which is used when search for library (dso/dll's) files.
Definition Registry:423
void setSharedStateManager(SharedStateManager *SharedStateManager)
Set the SharedStateManager.
Definition Registry:499
MimeTypeExtensionMap _mimeTypeExtMap
Definition Registry:627
void getReaderWriterListForProtocol(const std::string &protocol, ReaderWriterList &results) const
get a list of registered ReaderWriters which can handle given protocol
ReaderWriter::ReadResult readImplementation(const ReadFunctor &readFunctor, Options::CacheHintOptions cacheHint)
FindFileCallback * getFindFileCallback()
Get the findFile callback.
Definition Registry:163
friend class AvailableReaderWriterIterator
Definition Registry:603
ReaderWriter * getReaderWriterForProtocolAndExtension(const std::string &protocol, const std::string &extension)
void setAuthenticationMap(AuthenticationMap *authenticationMap)
Set the password map to be used by plugins when access files from secure locations.
Definition Registry:367
std::string findLibraryFile(const std::string &fileName, const Options *options, CaseSensitivity caseSensitivity)
Definition Registry:177
ExtensionAliasMap _extAliasMap
Definition Registry:624
void setWriteFileCallback(WriteFileCallback *cb)
Set the Registry callback to use in place of the default writeFile calls.
Definition Registry:265
std::set< std::string > RegisteredProtocolsSet
Definition Registry:534
friend struct ReadArchiveFunctor
Definition Registry:593
ReaderWriterList & getReaderWriterList()
get list of all registered ReaderWriters.
Definition Registry:128
ReaderWriter::ReadResult readHeightFieldImplementation(const std::string &fileName, const Options *options)
friend struct ReadNodeFunctor
Definition Registry:592
osgDB::Archive * getFromArchiveCache(const std::string &fileName)
Get an Archive from the archive cache.
const WriteFileCallback * getWriteFileCallback() const
Get the const writeFile callback.
Definition Registry:271
class osgDB::FindFileCallback FindFileCallback
Definition Registry:154
ReaderWriter::ReadResult readNode(const std::string &fileName, const Options *options, bool buildKdTreeIfRequired=true)
Definition Registry:234
ReaderWriter * getReaderWriterForMimeType(const std::string &mimeType)
gets a reader/writer that handles the extension mapped to by one of the registered mime-types.
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...
Definition Registry:401
ReaderWriterList _rwList
Definition Registry:614
ReaderWriter * getReaderWriterForExtension(const std::string &ext)
get a reader writer which handles specified extension.
void setCreateNodeFromImage(bool flag)
Definition Registry:383
void initDataFilePathList()
initialize the Data FilePath by reading the OSG_FILE_PATH environmental variable.
Options * getOptions()
Definition Registry:388
LoadStatus
Definition Registry:103
@ LOADED
Definition Registry:106
@ NOT_LOADED
Definition Registry:104
@ PREVIOUSLY_LOADED
Definition Registry:105
ReaderWriter::WriteResult writeScriptImplementation(const osg::Script &obj, const std::string &fileName, const Options *options)
ReaderWriter::WriteResult writeScript(const osg::Script &obj, const std::string &fileName, const Options *options)
Definition Registry:314
osg::ref_ptr< osg::KdTreeBuilder > _kdTreeBuilder
Definition Registry:545
ReaderWriter::ReadResult readImage(const std::string &fileName, const Options *options)
Definition Registry:218
void closeAllLibraries()
close all libraries.
const ReaderWriterList & getReaderWriterList() const
get const list of all registered ReaderWriters.
Definition Registry:131
void setDataFilePathList(const std::string &paths)
Set the data file path using a single string delimited either with ';' (Windows) or ':' (All other pl...
AuthenticationMap * getAuthenticationMap()
Get the password map to be used by plugins when access files from secure locations.
Definition Registry:377
virtual ~Registry()
friend struct ReadScriptFunctor
Definition Registry:595
bool _createNodeFromImage
Definition Registry:551
const FilePathList & getDataFilePathList() const
get the const data file path which is used when search for data files.
Definition Registry:410
std::string findLibraryFileImplementation(const std::string &fileName, const Options *options, CaseSensitivity caseSensitivity)
osg::ref_ptr< ObjectCache > _objectCache
Definition Registry:638
void addImageProcessor(ImageProcessor *ip)
ReaderWriter::WriteResult writeImageImplementation(const osg::Image &obj, const std::string &fileName, const Options *options)
osg::ref_ptr< FileLocationCallback > _fileLocationCallback
Definition Registry:611
FilePathList _libraryFilePath
Definition Registry:636
FileLocationCallback * getFileLocationCallback() const
Get the callback to use inform to the DatabasePager whether a file is located on local or remote file...
Definition Registry:339
const ArchiveExtensionList & getArchiveExtensions() const
Definition Registry:523
std::map< std::string, std::string > ExtensionAliasMap
Definition Registry:530
osg::ref_ptr< SharedStateManager > _sharedStateManager
Definition Registry:645
void removeFromObjectCache(const std::string &fileName, Options *options=NULL)
Remove Object from cache.
ArchiveExtensionList _archiveExtList
Definition Registry:643
AuthenticationMap * getOrCreateAuthenticationMap()
Get the password map to be used by plugins when access files from secure locations.
Definition Registry:370
ReadFileCallback * getReadFileCallback()
Get the readFile callback.
Definition Registry:191
void _buildKdTreeIfRequired(ReaderWriter::ReadResult &result, const Options *options)
Definition Registry:322
osg::ref_ptr< osg::Object > getRefFromObjectCache(const std::string &fileName, Options *options=NULL)
Get an ref_ptr<Object> from the object cache.
FilePathList & getDataFilePathList()
get the data file path which is used when search for data files.
Definition Registry:407
void addEntryToObjectCache(const std::string &filename, osg::Object *object, double timestamp=0.0, Options *options=NULL)
Add a filename,object,timestamp triple to the Registry::ObjectCache.
void setObjectCache(ObjectCache *objectCache)
Set the ObjectCache that is used to manage local storage of files downloaded from the internet.
Definition Registry:431
ReaderWriter::ReadResult readShader(const std::string &fileName, const Options *options)
Definition Registry:247
ReaderWriter::ReadResult readNodeImplementation(const std::string &fileName, const Options *options)
void setFileCache(FileCache *fileCache)
Set the FileCache that is used to manage local storage of files downloaded from the internet.
Definition Registry:357
osg::ref_ptr< ReadFileCallback > _readFileCallback
Definition Registry:609
void clearObjectCache()
Remove all objects in the cache regardless of having external references or expiry times.
Registry()
constructor is private, as its a singleton, preventing construction other than via the instance() met...
ReaderWriter::ReadResult openArchive(const std::string &fileName, ReaderWriter::ArchiveStatus status, unsigned int indexBlockSizeHint, const Options *options)
Definition Registry:197
OpenThreads::ReentrantMutex _archiveCacheMutex
Definition Registry:618
friend struct ReadHeightFieldFunctor
Definition Registry:591
DynamicLibraryList::iterator getLibraryItr(const std::string &fileName)
get the attached library with specified name.
ReaderWriter::WriteResult writeHeightField(const osg::HeightField &obj, const std::string &fileName, const Options *options)
Definition Registry:290
ReaderWriter::WriteResult writeShaderImplementation(const osg::Shader &obj, const std::string &fileName, const Options *options)
ReaderWriter::ReadResult readHeightField(const std::string &fileName, const Options *options)
Definition Registry:226
SharedStateManager * getOrCreateSharedStateManager()
Get the SharedStateManager, creating one if one is not already created.
ImageProcessor * getImageProcessor()
get a image processor if available.
const ReadFileCallback * getReadFileCallback() const
Get the const readFile callback.
Definition Registry:194
class osgDB::ReadFileCallback ReadFileCallback
Definition Registry:155
static Registry * instance(bool erase=false)
ObjectWrapperManager * getObjectWrapperManager()
Get the ObjectWrapperManager that is used to store all the ObjectWrappers.
Definition Registry:517
void setBuildKdTreesHint(Options::BuildKdTreesHint hint)
Set whether the KdTrees should be built for geometry in the loader model.
Definition Registry:344
bool isProtocolRegistered(const std::string &protocol)
returns true, if named protocol is registered
void setExpiryDelay(double expiryDelay)
set hint to viewer code calling removeExpiredObjectsInCache to specify how long it should give before...
Definition Registry:440
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 d...
Definition Registry:417
SharedStateManager * getSharedStateManager()
Get the SharedStateManager.
Definition Registry:505
void updateTimeStampOfObjectsInCacheWithExternalReferences(const osg::FrameStamp &frameStamp)
For each object in the cache which has an reference count greater than 1 (and therefore referenced by...
std::string createLibraryNameForFile(const std::string &fileName)
create the platform specific library name associated with file.
DynamicLibrary * getLibrary(const std::string &fileName)
get the attached library with specified name.
ReaderWriter::WriteResult writeNode(const osg::Node &node, const std::string &fileName, const Options *options)
Definition Registry:298
std::map< std::string, std::string > MimeTypeExtensionMap
Definition Registry:77
const FileCache * getFileCache() const
Get the const FileCache that is used to manage local storage of files downloaded from the internet.
Definition Registry:363
void removeFromArchiveCache(const std::string &fileName)
Remove Archive from cache.
std::vector< osg::ref_ptr< DynamicLibrary > > DynamicLibraryList
Definition Registry:529
std::string createLibraryNameForExtension(const std::string &ext)
create the platform specific library name associated with file extension.
ImageProcessorList & getImageProcessorList()
get list of all registered ImageProcessors.
Definition Registry:148
void clearArchiveCache()
Remove all archives from the archive cache.
void setFileLocationCallback(FileLocationCallback *cb)
Set the callback to use inform to the DatabasePager whether a file is located on local or remote file...
Definition Registry:336
DynamicLibraryList _dlList
Definition Registry:616
const Options * getOptions() const
Definition Registry:389
void readCommandLine(osg::ArgumentParser &commandLine)
read the command line arguments.
Options::BuildKdTreesHint _buildKdTreesHint
Definition Registry:544
bool readPluginAliasConfigurationFile(const std::string &file)
Reads a file that configures extension mappings.
RegisteredProtocolsSet _registeredProtocols
Definition Registry:553
void setLibraryFilePathList(const std::string &paths)
Set the library file path using a single string delimited either with ';' (Windows) or ':' (All other...
OpenThreads::ReentrantMutex _pluginMutex
Definition Registry:613
double getExpiryDelay() const
Definition Registry:442
ReaderWriter::ReadResult readObject(const std::string &fileName, const Options *options, bool buildKdTreeIfRequired=true)
Definition Registry:205
osg::ref_ptr< FindFileCallback > _findFileCallback
Definition Registry:608
LoadStatus loadLibrary(const std::string &fileName)
find the library in the OSG_LIBRARY_PATH and load it.
void initFilePathLists()
initialize both the Data and Library FilePaths, by default called by the constructor,...
Definition Registry:395
void removeImageProcessor(ImageProcessor *ip)
bool closeLibrary(const std::string &fileName)
close the attached library with specified name.
ReaderWriter::WriteResult writeObject(const osg::Object &obj, const std::string &fileName, const Options *options)
Definition Registry:274
void addReaderWriter(ReaderWriter *rw)
friend struct ReadObjectFunctor
Definition Registry:589
bool _openingLibrary
Definition Registry:621
osg::ref_ptr< Options > _options
Definition Registry:633
const FilePathList & getLibraryFilePathList() const
get the const library file path which is used when search for library (dso/dll's) files.
Definition Registry:426
ReaderWriter::ReadResult readScript(const std::string &fileName, const Options *options)
Definition Registry:255
void releaseGLObjects(osg::State *state=0)
If State is non-zero, this function releases OpenGL objects for the specified graphics context.
ReaderWriter::ReadResult readImageImplementation(const std::string &fileName, const Options *options)
ReaderWriter::ReadResult readObjectImplementation(const std::string &fileName, const Options *options)
void registerProtocol(const std::string &protocol)
registers a protocol
std::string findDataFile(const std::string &fileName, const Options *options, CaseSensitivity caseSensitivity)
Definition Registry:169
ReaderWriter::ReadResult readShaderImplementation(const std::string &fileName, const Options *options)
MimeTypeExtensionMap & getMimeTypeExtensionMap()
Definition Registry:84
ReaderWriter::WriteResult writeShader(const osg::Shader &obj, const std::string &fileName, const Options *options)
Definition Registry:306
ReaderWriter::WriteResult writeImage(const osg::Image &obj, const std::string &fileName, const Options *options)
Definition Registry:282
osg::ref_ptr< WriteFileCallback > _writeFileCallback
Definition Registry:610
friend class AvailableArchiveIterator
Definition Registry:605
void setFindFileCallback(FindFileCallback *cb)
Set the Registry callback to use in place of the default findFile calls.
Definition Registry:160
ReaderWriter::WriteResult writeNodeImplementation(const osg::Node &node, const std::string &fileName, const Options *options)
ReaderWriter::WriteResult writeObjectImplementation(const osg::Object &obj, const std::string &fileName, const Options *options)
const MimeTypeExtensionMap & getMimeTypeExtensionMap() const
Definition Registry:85
const ImageProcessorList & getImageProcessorList() const
get const list of all registered ImageProcessors.
Definition Registry:151
std::string findDataFileImplementation(const std::string &fileName, const Options *options, CaseSensitivity caseSensitivity)
void addArchiveExtension(const std::string ext)
Add an Archive extension.
std::vector< osg::ref_ptr< ImageProcessor > > ImageProcessorList
Definition Registry:139
friend struct ReadShaderFunctor
Definition Registry:594
void addMimeTypeExtensionMapping(const std::string fromMimeType, const std::string toExt)
Registers a mapping of a mime-type to an extension.
double _expiryDelay
Definition Registry:640
osg::Object * getFromObjectCache(const std::string &fileName, Options *options=NULL)
Get an Object from the object cache.
osg::ref_ptr< DeprecatedDotOsgWrapperManager > _deprecatedDotOsgWrapperManager
Definition Registry:648
ImageProcessorList _ipList
Definition Registry:615
ArchiveCache _archiveCache
Definition Registry:619
void initLibraryFilePathList()
initialize the Library FilePath by reading the OSG_LIBRARY_PATH and the appropriate system environmen...
FilePathList _dataFilePath
Definition Registry:635
ReaderWriter::ReadResult openArchiveImplementation(const std::string &fileName, ReaderWriter::ArchiveStatus status, unsigned int indexBlockSizeHint, const Options *options)
ReaderWriter::WriteResult writeHeightFieldImplementation(const osg::HeightField &obj, const std::string &fileName, const Options *options)
void addToArchiveCache(const std::string &fileName, osgDB::Archive *archive)
Add archive to archive cache so that future calls reference this archive.
void setKdTreeBuilder(osg::KdTreeBuilder *builder)
Set the KdTreeBuilder visitor that is used to build KdTree on loaded models.
Definition Registry:350
WriteFileCallback * getWriteFileCallback()
Get the writeFile callback.
Definition Registry:268
ReaderWriter::ReadResult readScriptImplementation(const std::string &fileName, const Options *options)
std::vector< osg::ref_ptr< ReaderWriter > > ReaderWriterList
Definition Registry:118
class osgDB::FileLocationCallback FileLocationCallback
Definition Registry:157
osg::ref_ptr< ObjectWrapperManager > _objectWrapperManager
Definition Registry:647
osg::ref_ptr< osgDB::Archive > getRefFromArchiveCache(const std::string &fileName)
Get an ref_ptr<Archive> from the archive cache.
ObjectCache * getObjectCache()
Get the ObjectCache that is used to manage local storage of files downloaded from the internet.
Definition Registry:434
DeprecatedDotOsgWrapperManager * getDeprecatedDotOsgObjectWrapperManager()
Get the ObjectWrapperManager that is used to store all the ObjectWrappers.
Definition Registry:520
const FindFileCallback * getFindFileCallback() const
Get the const findFile callback.
Definition Registry:166
std::string createLibraryNameForNodeKit(const std::string &name)
create the platform specific library name associated with nodekit library name.
const AuthenticationMap * getAuthenticationMap() const
Get the password map to be used by plugins when access files from secure locations.
Definition Registry:380
std::map< std::string, osg::ref_ptr< osgDB::Archive > > ArchiveCache
Definition Registry:532
Options::BuildKdTreesHint getBuildKdTreesHint() const
Get whether the KdTrees should be built for geometry in the loader model.
Definition Registry:347
void setOptions(Options *opt)
Definition Registry:387
class osgDB::WriteFileCallback WriteFileCallback
Definition Registry:156
Functor used in internal implementations.
Definition Registry:558
virtual ReadFunctor * cloneType(const std::string &filename, const Options *options) const =0
std::string _filename
Definition Registry:570
virtual ReaderWriter::ReadResult doRead(ReaderWriter &rw) const =0
ReadFunctor(const std::string &filename, const Options *options)
Definition Registry:559
const Options * _options
Definition Registry:571
virtual bool isValid(ReaderWriter::ReadResult &readResult) const =0
virtual bool isValid(osg::Object *object) const =0
virtual ~ReadFunctor()
Definition Registry:563
osg::ref_ptr< T > _rw
Definition Registry:682
RegisterReaderWriterProxy()
Definition Registry:662
~RegisterReaderWriterProxy()
Definition Registry:671
T * get()
Definition Registry:679
~RegisterImageProcessorProxy()
Definition Registry:700
osg::ref_ptr< T > _rw
Definition Registry:711
RegisterImageProcessorProxy()
Definition Registry:691
T * get()
Definition Registry:708
PluginFunctionProxy(CPluginFunction function)
Definition Registry:716
Definition SharedStateManager:31
#define NULL
Definition Export:55
#define OSGDB_EXPORT
Definition Export:39
void(* CPluginFunction)(void)
Definition Registry:39

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