OSG  3.4.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Registry.h
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>
30 #include <osgDB/SharedStateManager>
31 #include <osgDB/ImageProcessor>
32 
33 #include <vector>
34 #include <map>
35 #include <string>
36 
37 extern "C"
38 {
39  typedef void (* CPluginFunction) (void);
40 }
41 
42 namespace osgDB {
43 
44 
54 {
55  public:
56 
57 
58 
59 
60  static Registry* instance(bool erase = false);
61 
63  void readCommandLine(osg::ArgumentParser& commandLine);
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);
84  MimeTypeExtensionMap& getMimeTypeExtensionMap() { return _mimeTypeExtMap; }
85  const MimeTypeExtensionMap& getMimeTypeExtensionMap() const { return _mimeTypeExtMap; }
86 
87  void addReaderWriter(ReaderWriter* rw);
88  void removeReaderWriter(ReaderWriter* rw);
89 
90  void addImageProcessor(ImageProcessor* ip);
91  void removeImageProcessor(ImageProcessor* ip);
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 
103  enum LoadStatus {
104  NOT_LOADED = 0,
106  LOADED
107  };
108 
110  LoadStatus loadLibrary(const std::string& fileName);
111 
113  bool closeLibrary(const std::string& fileName);
114 
116  void closeAllLibraries();
117 
118  typedef std::vector< osg::ref_ptr<ReaderWriter> > ReaderWriterList;
119 
121  ReaderWriter* getReaderWriterForExtension(const std::string& ext);
122 
125  ReaderWriter* getReaderWriterForMimeType(const std::string& mimeType);
126 
128  ReaderWriterList& getReaderWriterList() { return _rwList; }
129 
131  const ReaderWriterList& getReaderWriterList() const { return _rwList; }
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 
142  ImageProcessor* getImageProcessor();
143 
145  ImageProcessor* getImageProcessorForExtension(const std::string& ext);
146 
148  ImageProcessorList& getImageProcessorList() { return _ipList; }
149 
151  const ImageProcessorList& getImageProcessorList() const { return _ipList; }
152 
153 
158 
160  void setFindFileCallback( FindFileCallback* cb) { _findFileCallback = cb; }
161 
163  FindFileCallback* getFindFileCallback() { return _findFileCallback.get(); }
164 
166  const FindFileCallback* getFindFileCallback() const { return _findFileCallback.get(); }
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 
188  void setReadFileCallback( ReadFileCallback* cb) { _readFileCallback = cb; }
189 
191  ReadFileCallback* getReadFileCallback() { return _readFileCallback.get(); }
192 
194  const ReadFileCallback* getReadFileCallback() const { return _readFileCallback.get(); }
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 
265  void setWriteFileCallback( WriteFileCallback* cb) { _writeFileCallback = cb; }
266 
268  WriteFileCallback* getWriteFileCallback() { return _writeFileCallback.get(); }
269 
271  const WriteFileCallback* getWriteFileCallback() const { return _writeFileCallback.get(); }
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) ?
326  _buildKdTreesHint == Options::BUILD_KDTREES;
327 
328  if (doKdTreeBuilder && _kdTreeBuilder.valid() && result.validNode())
329  {
330  osg::ref_ptr<osg::KdTreeBuilder> builder = _kdTreeBuilder->clone();
331  result.getNode()->accept(*builder);
332  }
333  }
334 
336  void setFileLocationCallback( FileLocationCallback* cb) { _fileLocationCallback = cb; }
337 
339  FileLocationCallback* getFileLocationCallback() const { return _fileLocationCallback.get(); }
340 
341 
342 
344  void setBuildKdTreesHint(Options::BuildKdTreesHint hint) { _buildKdTreesHint = hint; }
345 
347  Options::BuildKdTreesHint getBuildKdTreesHint() const { return _buildKdTreesHint; }
348 
350  void setKdTreeBuilder(osg::KdTreeBuilder* builder) { _kdTreeBuilder = builder; }
351 
353  osg::KdTreeBuilder* getKdTreeBuilder() { return _kdTreeBuilder.get(); }
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 
370  AuthenticationMap* getAuthenticationMap() { return _authenticationMap.get(); }
371 
373  const AuthenticationMap* getAuthenticationMap() const { return _authenticationMap.get(); }
374 
375 
376  void setCreateNodeFromImage(bool flag) { _createNodeFromImage = flag; }
377  bool getCreateNodeFromImage() const { return _createNodeFromImage; }
378 
379 
380  void setOptions(Options* opt) { _options = opt; }
381  Options* getOptions() { return _options.get(); }
382  const Options* getOptions() const { return _options.get(); }
383 
384 
388  void initFilePathLists() { initDataFilePathList(); initLibraryFilePathList(); }
389 
391  void initDataFilePathList();
392 
394  void setDataFilePathList(const FilePathList& filepath) { _dataFilePath = filepath; }
395 
397  void setDataFilePathList(const std::string& paths);
398 
400  FilePathList& getDataFilePathList() { return _dataFilePath; }
401 
403  const FilePathList& getDataFilePathList() const { return _dataFilePath; }
404 
407  void initLibraryFilePathList();
408 
410  void setLibraryFilePathList(const FilePathList& filepath) { _libraryFilePath = filepath; }
411 
413  void setLibraryFilePathList(const std::string& paths);
414 
416  FilePathList& getLibraryFilePathList() { return _libraryFilePath; }
417 
419  const FilePathList& getLibraryFilePathList() const { return _libraryFilePath; }
420 
421 
422 
424  void setObjectCache(ObjectCache* objectCache) { _objectCache = objectCache; }
425 
427  ObjectCache* getObjectCache() { return _objectCache.get(); }
428 
430  const ObjectCache* getObjectCache() const { return _objectCache.get(); }
431 
433  void setExpiryDelay(double expiryDelay) { _expiryDelay = expiryDelay; }
434 
435  double getExpiryDelay() const { return _expiryDelay; }
436 
443  void updateTimeStampOfObjectsInCacheWithExternalReferences(const osg::FrameStamp& frameStamp);
444 
449  void removeExpiredObjectsInCache(const osg::FrameStamp& frameStamp);
450 
452  void clearObjectCache();
453 
455  void addEntryToObjectCache(const std::string& filename, osg::Object* object, double timestamp = 0.0);
456 
458  void removeFromObjectCache(const std::string& fileName);
459 
461  osg::Object* getFromObjectCache(const std::string& fileName);
462 
464  osg::ref_ptr<osg::Object> getRefFromObjectCache(const std::string& fileName);
465 
466 
467 
469  void addToArchiveCache(const std::string& fileName, osgDB::Archive* archive);
470 
472  void removeFromArchiveCache(const std::string& fileName);
473 
475  osgDB::Archive* getFromArchiveCache(const std::string& fileName);
476 
478  osg::ref_ptr<osgDB::Archive> getRefFromArchiveCache(const std::string& fileName);
479 
481  void clearArchiveCache();
482 
486  void releaseGLObjects(osg::State* state=0);
487 
489  DynamicLibrary* getLibrary(const std::string& fileName);
490 
492  void setSharedStateManager(SharedStateManager* SharedStateManager) { _sharedStateManager = SharedStateManager; }
493 
495  SharedStateManager* getOrCreateSharedStateManager();
496 
498  SharedStateManager* getSharedStateManager() { return _sharedStateManager.get(); }
499 
501  void addArchiveExtension(const std::string ext);
502 
504  void registerProtocol(const std::string& protocol);
505 
507  bool isProtocolRegistered(const std::string& protocol);
508 
510  ObjectWrapperManager* getObjectWrapperManager() { return _objectWrapperManager.get(); }
511 
513  DeprecatedDotOsgWrapperManager* getDeprecatedDotOsgObjectWrapperManager() { return _deprecatedDotOsgWrapperManager.get(); }
514 
515  typedef std::vector< std::string> ArchiveExtensionList;
516  const ArchiveExtensionList& getArchiveExtensions() const { return _archiveExtList; }
517 
518  protected:
519 
520  virtual ~Registry();
521 
522  typedef std::vector< osg::ref_ptr<DynamicLibrary> > DynamicLibraryList;
523  typedef std::map< std::string, std::string> ExtensionAliasMap;
524 
525  typedef std::map<std::string, osg::ref_ptr<osgDB::Archive> > ArchiveCache;
526 
527  typedef std::set<std::string> RegisteredProtocolsSet;
528 
532  Registry();
533 
535  DynamicLibraryList::iterator getLibraryItr(const std::string& fileName);
536 
539 
541 
543 
545 
546  RegisteredProtocolsSet _registeredProtocols;
547 
548  public:
550  struct ReadFunctor
551  {
552  ReadFunctor(const std::string& filename, const Options* options):
553  _filename(filename),
554  _options(options) {}
555 
556  virtual ~ReadFunctor() {}
557  virtual ReaderWriter::ReadResult doRead(ReaderWriter& rw) const = 0;
558  virtual bool isValid(ReaderWriter::ReadResult& readResult) const = 0;
559  virtual bool isValid(osg::Object* object) const = 0;
560 
561  virtual ReadFunctor* cloneType(const std::string& filename, const Options* options) const = 0;
562 
563  std::string _filename;
565  };
566 
567  protected:
568 
569  void destruct();
570 
571  // forward declare helper classes
572  struct ReadObjectFunctor;
573  struct ReadImageFunctor;
574  struct ReadHeightFieldFunctor;
575  struct ReadNodeFunctor;
576  struct ReadArchiveFunctor;
577  struct ReadShaderFunctor;
578  struct ReadScriptFunctor;
579 
580  // make helper classes friends to get round VS6.0 "issues"
581  friend struct ReadFunctor;
582  friend struct ReadObjectFunctor;
583  friend struct ReadImageFunctor;
584  friend struct ReadHeightFieldFunctor;
585  friend struct ReadNodeFunctor;
586  friend struct ReadArchiveFunctor;
587  friend struct ReadShaderFunctor;
588  friend struct ReadScriptFunctor;
589 
590  ReaderWriter::ReadResult read(const ReadFunctor& readFunctor);
591  ReaderWriter::ReadResult readImplementation(const ReadFunctor& readFunctor,Options::CacheHintOptions cacheHint);
592 
593 
594  // forward declare helper class
595  class AvailableReaderWriterIterator;
596  friend class AvailableReaderWriterIterator;
597  class AvailableArchiveIterator;
598  friend class AvailableArchiveIterator;
599 
600 
605 
607  ReaderWriterList _rwList;
608  ImageProcessorList _ipList;
609  DynamicLibraryList _dlList;
610 
612  ArchiveCache _archiveCache;
613 
615 
616  // map to alias to extensions to plugins.
617  ExtensionAliasMap _extAliasMap;
618 
619  // maps mime-types to extensions.
620  MimeTypeExtensionMap _mimeTypeExtMap;
621 
622  // Utility: Removes whitespace from both ends of a string.
623  static std::string trim( const std::string& str );
624 
625  // options to pass to reader writers.
627 
630 
632 
633  double _expiryDelay;
634 
635 
636  ArchiveExtensionList _archiveExtList;
637 
639 
642 };
643 
646 {
648 }
649 
651 template<class T>
653 {
654  public:
656  {
657  if (Registry::instance())
658  {
659  _rw = new T;
661  }
662  }
663 
665  {
666  if (Registry::instance())
667  {
669  }
670  }
671 
672  T* get() { return _rw.get(); }
673 
674  protected:
676 };
677 
678 
680 template<class T>
682 {
683  public:
685  {
686  if (Registry::instance())
687  {
688  _rw = new T;
690  }
691  }
692 
694  {
695  if (Registry::instance())
696  {
698  }
699  }
700 
701  T* get() { return _rw.get(); }
702 
703  protected:
705 };
706 
708 {
709  PluginFunctionProxy(CPluginFunction function) { (function)(); }
710 };
711 
712 #define USE_OSGPLUGIN(ext) \
713  extern "C" void osgdb_##ext(void); \
714  static osgDB::PluginFunctionProxy proxy_##ext(osgdb_##ext);
715 
716 #define USE_DOTOSGWRAPPER(classname) \
717  extern "C" void dotosgwrapper_##classname(void); \
718  static osgDB::PluginFunctionProxy proxy_dotosgwrapper_##classname(dotosgwrapper_##classname);
719 
720 #define USE_DOTOSGWRAPPER_LIBRARY(libname) \
721  extern "C" void dotosgwrapper_library_##libname(void); \
722  static osgDB::PluginFunctionProxy proxy_dotosgwrapper_library_##libname(dotosgwrapper_library_##libname);
723 
724 #define USE_SERIALIZER_WRAPPER(classname) \
725  extern "C" void wrapper_serializer_##classname(void); \
726  static osgDB::PluginFunctionProxy proxy_serializer_##classname(wrapper_serializer_##classname);
727 
728 #define USE_SERIALIZER_WRAPPER_LIBRARY(libname) \
729  extern "C" void wrapper_serializer_library_##libname(void); \
730  static osgDB::PluginFunctionProxy proxy_serializer_library_##libname(wrapper_serializer_library_##libname);
731 
732 #define USE_COMPRESSOR_WRAPPER(classname) \
733  extern "C" void wrapper_compressor_##classname(void); \
734  static osgDB::PluginFunctionProxy proxy_compressor_##classname(wrapper_compressor_##classname);
735 
736 #define REGISTER_OSGPLUGIN(ext, classname) \
737  extern "C" void osgdb_##ext(void) {} \
738  static osgDB::RegisterReaderWriterProxy<classname> g_proxy_##classname;
739 
740 #define REGISTER_OSGIMAGEPROCESSOR(ext, classname) \
741  extern "C" void osgdb_##ext(void) {} \
742  static osgDB::RegisterImageProcessorProxy<classname> g_proxy_##classname;
743 
744 }
745 
746 #endif
std::map< std::string, std::string > MimeTypeExtensionMap
Definition: Registry.h:77
virtual ReaderWriter::WriteResult writeObject(const osg::Object &obj, const std::string &fileName, const Options *options)
WriteFileCallback * getWriteFileCallback() const
Definition: Options.h:230
ReaderWriter::ReadResult readImage(const std::string &fileName, const Options *options)
Definition: Registry.h:218
ArchiveCache _archiveCache
Definition: Registry.h:612
CacheHintOptions
bit mask for setting up which object types get cached by readObject/Image/HeightField/Node(filename) ...
Definition: Options.h:34
const MimeTypeExtensionMap & getMimeTypeExtensionMap() const
Definition: Registry.h:85
void setDataFilePathList(const FilePathList &filepath)
Definition: Registry.h:394
void setOptions(Options *opt)
Definition: Registry.h:380
BuildKdTreesHint getBuildKdTreesHint() const
Definition: Options.h:159
ReaderWriter::WriteResult writeImage(const osg::Image &obj, const std::string &fileName, const Options *options)
Definition: Registry.h:282
ObjectWrapperManager * getObjectWrapperManager()
Definition: Registry.h:510
virtual ReaderWriter::ReadResult readHeightField(const std::string &filename, const Options *options)
BuildKdTreesHint
range of options of whether to build kdtrees automatically on loading
Definition: Options.h:90
class osgDB::ReadFileCallback ReadFileCallback
Definition: Registry.h:155
Options::BuildKdTreesHint _buildKdTreesHint
Definition: Registry.h:537
void setDataFilePathList(const FilePathList &filepath)
Definition: FileUtils.h:110
virtual ReaderWriter::ReadResult openArchive(const std::string &filename, ReaderWriter::ArchiveStatus status, unsigned int indexBlockSizeHint, const Options *useObjectCache)
bool getCreateNodeFromImage() const
Definition: Registry.h:377
virtual ReaderWriter::WriteResult writeImage(const osg::Image &obj, const std::string &fileName, const Options *options)
osg::ref_ptr< FindFileCallback > _findFileCallback
Definition: Registry.h:601
ReaderWriter::WriteResult writeNode(const osg::Node &node, const std::string &fileName, const Options *options)
Definition: Registry.h:298
virtual ReaderWriter::WriteResult writeScript(const osg::Script &obj, const std::string &fileName, const Options *options)
osg::ref_ptr< WriteFileCallback > _writeFileCallback
Definition: Registry.h:603
class osgDB::WriteFileCallback WriteFileCallback
Definition: Registry.h:156
AuthenticationMap * getAuthenticationMap()
Definition: Registry.h:370
osg::ref_ptr< SharedStateManager > _sharedStateManager
Definition: Registry.h:638
void setExpiryDelay(double expiryDelay)
Definition: Registry.h:433
WriteFileCallback * getWriteFileCallback()
Definition: Registry.h:268
ReaderWriterList & getReaderWriterList()
Definition: Registry.h:128
ReadFileCallback * getReadFileCallback() const
Definition: Options.h:223
ReaderWriter::WriteResult writeShader(const osg::Shader &obj, const std::string &fileName, const Options *options)
Definition: Registry.h:306
const FileCache * getFileCache() const
Definition: Registry.h:363
void setObjectCache(ObjectCache *objectCache)
Definition: Registry.h:424
ReadFileCallback * getReadFileCallback()
Definition: Registry.h:191
void removeReaderWriter(ReaderWriter *rw)
std::set< std::string > RegisteredProtocolsSet
Definition: Registry.h:527
virtual ReaderWriter::ReadResult readNode(const std::string &filename, const Options *options)
FilePathList & getDataFilePathList()
Definition: Registry.h:400
ReaderWriter::WriteResult writeScript(const osg::Script &obj, const std::string &fileName, const Options *options)
Definition: Registry.h:314
std::vector< osg::ref_ptr< DynamicLibrary > > DynamicLibraryList
Definition: Registry.h:522
bool _openingLibrary
Definition: Registry.h:614
void readCommandLine(osg::ArgumentParser &parser)
Definition: Registry.h:645
void setWriteFileCallback(WriteFileCallback *cb)
Definition: Registry.h:265
Options * getOptions()
Definition: Registry.h:381
ImageProcessorList _ipList
Definition: Registry.h:608
const AuthenticationMap * getAuthenticationMap() const
Definition: Registry.h:373
ReaderWriterList _rwList
Definition: Registry.h:607
void setFileLocationCallback(FileLocationCallback *cb)
Definition: Registry.h:336
OpenThreads::ReentrantMutex _archiveCacheMutex
Definition: Registry.h:611
DynamicLibraryList _dlList
Definition: Registry.h:609
virtual ReaderWriter::WriteResult writeShader(const osg::Shader &obj, const std::string &fileName, const Options *options)
const FilePathList & getLibraryFilePathList() const
Definition: Registry.h:419
osg::ref_ptr< DeprecatedDotOsgWrapperManager > _deprecatedDotOsgWrapperManager
Definition: Registry.h:641
ReaderWriter::WriteResult writeHeightField(const osg::HeightField &obj, const std::string &fileName, const Options *options)
Definition: Registry.h:290
ReaderWriter::ReadResult openArchive(const std::string &fileName, ReaderWriter::ArchiveStatus status, unsigned int indexBlockSizeHint, const Options *options)
Definition: Registry.h:197
void readCommandLine(osg::ArgumentParser &commandLine)
FileCache * getFileCache()
Definition: Registry.h:360
ObjectCache * getObjectCache()
Definition: Registry.h:427
const ImageProcessorList & getImageProcessorList() const
Definition: Registry.h:151
void addReaderWriter(ReaderWriter *rw)
ExtensionAliasMap _extAliasMap
Definition: Registry.h:617
osg::ref_ptr< ObjectCache > _objectCache
Definition: Registry.h:631
const ReaderWriterList & getReaderWriterList() const
Definition: Registry.h:131
virtual ReaderWriter::WriteResult writeNode(const osg::Node &obj, const std::string &fileName, const Options *options)
virtual ReaderWriter::ReadResult readScript(const std::string &filename, const Options *options)
void removeImageProcessor(ImageProcessor *ip)
osg::ref_ptr< FileCache > _fileCache
Definition: Registry.h:540
class osgDB::FindFileCallback FindFileCallback
Definition: Registry.h:154
ImageProcessorList & getImageProcessorList()
Definition: Registry.h:148
std::map< std::string, osg::ref_ptr< osgDB::Archive > > ArchiveCache
Definition: Registry.h:525
typedef void(GL_APIENTRY *GLTexImage3DProc)(GLenum target
std::string findLibraryFile(const std::string &fileName, const Options *options, CaseSensitivity caseSensitivity)
Definition: Registry.h:177
const Options * _options
Definition: Registry.h:564
void setSharedStateManager(SharedStateManager *SharedStateManager)
Definition: Registry.h:492
virtual ReaderWriter::ReadResult readImage(const std::string &filename, const Options *options)
T * cloneType(const T *t)
Definition: Object.h:284
virtual Object * clone(const CopyOp &) const =0
class osgDB::FileLocationCallback FileLocationCallback
Definition: Registry.h:157
SharedStateManager * getSharedStateManager()
Definition: Registry.h:498
virtual void accept(NodeVisitor &nv)
void setBuildKdTreesHint(Options::BuildKdTreesHint hint)
Definition: Registry.h:344
void setAuthenticationMap(AuthenticationMap *authenticationMap)
Definition: Registry.h:367
virtual ReaderWriter::ReadResult readObject(const std::string &filename, const Options *options)
double getExpiryDelay() const
Definition: Registry.h:435
void setKdTreeBuilder(osg::KdTreeBuilder *builder)
Definition: Registry.h:350
ReadFunctor(const std::string &filename, const Options *options)
Definition: Registry.h:552
osg::ref_ptr< Options > _options
Definition: Registry.h:626
double _expiryDelay
Definition: Registry.h:633
std::map< std::string, std::string > ExtensionAliasMap
Definition: Registry.h:523
void _buildKdTreeIfRequired(ReaderWriter::ReadResult &result, const Options *options)
Definition: Registry.h:322
Definition: Archive.h:24
MimeTypeExtensionMap & getMimeTypeExtensionMap()
Definition: Registry.h:84
ArchiveExtensionList _archiveExtList
Definition: Registry.h:636
void addImageProcessor(ImageProcessor *ip)
void setLibraryFilePathList(const FilePathList &filepaths)
Definition: FileUtils.h:126
void setFindFileCallback(FindFileCallback *cb)
Definition: Registry.h:160
ReaderWriter::ReadResult readScript(const std::string &fileName, const Options *options)
Definition: Registry.h:255
Options::BuildKdTreesHint getBuildKdTreesHint() const
Definition: Registry.h:347
const WriteFileCallback * getWriteFileCallback() const
Definition: Registry.h:271
std::deque< std::string > FilePathList
Definition: Callbacks.h:28
void setReadFileCallback(ReadFileCallback *cb)
Definition: Registry.h:188
osg::ref_ptr< ObjectWrapperManager > _objectWrapperManager
Definition: Registry.h:640
#define OSGDB_EXPORT
Definition: Export.h:39
std::vector< osg::ref_ptr< ImageProcessor > > ImageProcessorList
Definition: Registry.h:139
void setCreateNodeFromImage(bool flag)
Definition: Registry.h:376
const Options * getOptions() const
Definition: Registry.h:382
CaseSensitivity
Definition: Callbacks.h:30
RegisteredProtocolsSet _registeredProtocols
Definition: Registry.h:546
ReaderWriter::WriteResult writeObject(const osg::Object &obj, const std::string &fileName, const Options *options)
Definition: Registry.h:274
osg::ref_ptr< osg::KdTreeBuilder > _kdTreeBuilder
Definition: Registry.h:538
const ReadFileCallback * getReadFileCallback() const
Definition: Registry.h:194
ReaderWriter::ReadResult readObject(const std::string &fileName, const Options *options, bool buildKdTreeIfRequired=true)
Definition: Registry.h:205
static Registry * instance(bool erase=false)
PluginFunctionProxy(CPluginFunction function)
Definition: Registry.h:709
FindFileCallback * getFindFileCallback()
Definition: Registry.h:163
std::vector< osg::ref_ptr< ReaderWriter > > ReaderWriterList
Definition: Registry.h:118
Definition: Node.h:71
const ObjectCache * getObjectCache() const
Definition: Registry.h:430
FilePathList _libraryFilePath
Definition: Registry.h:629
void setFileCache(FileCache *fileCache)
Definition: Registry.h:357
ReaderWriter::ReadResult readNode(const std::string &fileName, const Options *options, bool buildKdTreeIfRequired=true)
Definition: Registry.h:234
osg::ref_ptr< AuthenticationMap > _authenticationMap
Definition: Registry.h:542
osg::KdTreeBuilder * getKdTreeBuilder()
Definition: Registry.h:353
OpenThreads::ReentrantMutex _pluginMutex
Definition: Registry.h:606
osg::ref_ptr< ReadFileCallback > _readFileCallback
Definition: Registry.h:602
FileLocationCallback * getFileLocationCallback() const
Definition: Registry.h:339
FilePathList & getLibraryFilePathList()
Definition: Registry.h:416
void initFilePathLists()
Definition: Registry.h:388
const ArchiveExtensionList & getArchiveExtensions() const
Definition: Registry.h:516
MimeTypeExtensionMap _mimeTypeExtMap
Definition: Registry.h:620
std::vector< std::string > ArchiveExtensionList
Definition: Registry.h:515
ReaderWriter::ReadResult readShader(const std::string &fileName, const Options *options)
Definition: Registry.h:247
virtual ReaderWriter::WriteResult writeHeightField(const osg::HeightField &obj, const std::string &fileName, const Options *options)
bool _createNodeFromImage
Definition: Registry.h:544
const FilePathList & getDataFilePathList() const
Definition: Registry.h:403
virtual std::string findLibraryFile(const std::string &filename, const Options *options, CaseSensitivity caseSensitivity)
void setLibraryFilePathList(const FilePathList &filepath)
Definition: Registry.h:410
virtual ReaderWriter::ReadResult readShader(const std::string &filename, const Options *options)
FilePathList _dataFilePath
Definition: Registry.h:628
std::string findDataFile(const std::string &fileName, const Options *options, CaseSensitivity caseSensitivity)
Definition: Registry.h:169
void(* CPluginFunction)(void)
Definition: Registry.h:39
virtual std::string findDataFile(const std::string &filename, const Options *options, CaseSensitivity caseSensitivity)
ReaderWriter::ReadResult readHeightField(const std::string &fileName, const Options *options)
Definition: Registry.h:226
osg::ref_ptr< FileLocationCallback > _fileLocationCallback
Definition: Registry.h:604
DeprecatedDotOsgWrapperManager * getDeprecatedDotOsgObjectWrapperManager()
Definition: Registry.h:513
FindFileCallback * getFindFileCallback() const
Definition: Options.h:216
const FindFileCallback * getFindFileCallback() const
Definition: Registry.h:166