Changeset 13041 for OpenSceneGraph/trunk/include/osgDB/Registry
- Timestamp:
- 03/21/12 18:36:20 (15 months ago)
- Files:
-
- 1 modified
-
OpenSceneGraph/trunk/include/osgDB/Registry (modified) (28 diffs)
Legend:
- Unmodified
- Added
- Removed
-
OpenSceneGraph/trunk/include/osgDB/Registry
r12937 r13041 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 1 /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield 2 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 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 5 * (at your option) any later version. The full license is in LICENSE file 6 6 * included with this distribution, and on the openscenegraph.org website. 7 * 7 * 8 8 * This library is distributed in the hope that it will be useful, 9 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 11 * OpenSceneGraph Public License for more details. 12 12 */ … … 75 75 76 76 77 77 78 78 static Registry* instance(bool erase = false); 79 79 … … 127 127 /** find the library in the OSG_LIBRARY_PATH and load it.*/ 128 128 LoadStatus loadLibrary(const std::string& fileName); 129 129 130 130 /** close the attached library with specified name.*/ 131 131 bool closeLibrary(const std::string& fileName); 132 132 133 133 /** close all libraries.*/ 134 134 void closeAllLibraries(); … … 142 142 * the registered mime-types. */ 143 143 ReaderWriter* getReaderWriterForMimeType(const std::string& mimeType); 144 144 145 145 /** get list of all registered ReaderWriters.*/ 146 146 ReaderWriterList& getReaderWriterList() { return _rwList; } … … 148 148 /** get const list of all registered ReaderWriters.*/ 149 149 const ReaderWriterList& getReaderWriterList() const { return _rwList; } 150 150 151 151 152 152 typedef std::vector< osg::ref_ptr<ImageProcessor> > ImageProcessorList; … … 203 203 /** Get the readFile callback.*/ 204 204 ReadFileCallback* getReadFileCallback() { return _readFileCallback.get(); } 205 205 206 206 /** Get the const readFile callback.*/ 207 207 const ReadFileCallback* getReadFileCallback() const { return _readFileCallback.get(); } … … 272 272 /** Get the writeFile callback.*/ 273 273 WriteFileCallback* getWriteFileCallback() { return _writeFileCallback.get(); } 274 274 275 275 /** Get the const writeFile callback.*/ 276 276 const WriteFileCallback* getWriteFileCallback() const { return _writeFileCallback.get(); } … … 308 308 } 309 309 ReaderWriter::WriteResult writeNodeImplementation(const osg::Node& node, const std::string& fileName,const Options* options); 310 310 311 311 ReaderWriter::WriteResult writeShader(const osg::Shader& obj, const std::string& fileName,const Options* options) 312 312 { … … 316 316 } 317 317 ReaderWriter::WriteResult writeShaderImplementation(const osg::Shader& obj, const std::string& fileName,const Options* options); 318 318 319 319 320 320 inline void _buildKdTreeIfRequired(ReaderWriter::ReadResult& result, const Options* options) … … 324 324 _buildKdTreesHint == Options::BUILD_KDTREES; 325 325 326 if (doKdTreeBuilder && _kdTreeBuilder.valid() && result.validNode()) 326 if (doKdTreeBuilder && _kdTreeBuilder.valid() && result.validNode()) 327 327 { 328 328 osg::ref_ptr<osg::KdTreeBuilder> builder = _kdTreeBuilder->clone(); … … 374 374 void setCreateNodeFromImage(bool flag) { _createNodeFromImage = flag; } 375 375 bool getCreateNodeFromImage() const { return _createNodeFromImage; } 376 376 377 377 378 378 void setOptions(Options* opt) { _options = opt; } … … 381 381 382 382 383 /** initialize both the Data and Library FilePaths, by default called by the 383 /** initialize both the Data and Library FilePaths, by default called by the 384 384 * constructor, so it should only be required if you want to force 385 385 * the re-reading of environmental variables.*/ 386 386 void initFilePathLists() { initDataFilePathList(); initLibraryFilePathList(); } 387 387 388 388 /** initialize the Data FilePath by reading the OSG_FILE_PATH environmental variable.*/ 389 389 void initDataFilePathList(); … … 401 401 const FilePathList& getDataFilePathList() const { return _dataFilePath; } 402 402 403 /** initialize the Library FilePath by reading the OSG_LIBRARY_PATH 403 /** initialize the Library FilePath by reading the OSG_LIBRARY_PATH 404 404 * and the appropriate system environmental variables*/ 405 405 void initLibraryFilePathList(); … … 413 413 /** get the library file path which is used when search for library (dso/dll's) files.*/ 414 414 FilePathList& getLibraryFilePathList() { return _libraryFilePath; } 415 415 416 416 /** get the const library file path which is used when search for library (dso/dll's) files.*/ 417 417 const FilePathList& getLibraryFilePathList() const { return _libraryFilePath; } 418 418 419 /** For each object in the cache which has an reference count greater than 1 419 /** For each object in the cache which has an reference count greater than 1 420 420 * (and therefore referenced by elsewhere in the application) set the time stamp 421 421 * for that object in the cache to specified time. … … 437 437 438 438 439 /** Remove all objects in the cache regardless of having external references or expiry times.*/ 439 /** Remove all objects in the cache regardless of having external references or expiry times.*/ 440 440 void clearObjectCache(); 441 441 … … 448 448 /** Get an Object from the object cache*/ 449 449 osg::Object* getFromObjectCache(const std::string& fileName); 450 450 451 451 /** Get an ref_ptr<Object> from the object cache*/ 452 452 osg::ref_ptr<osg::Object> getRefFromObjectCache(const std::string& fileName); 453 453 454 454 455 455 456 456 /** Add archive to archive cache so that future calls reference this archive.*/ 457 457 void addToArchiveCache(const std::string& fileName, osgDB::Archive* archive); … … 459 459 /** Remove Archive from cache.*/ 460 460 void removeFromArchiveCache(const std::string& fileName); 461 461 462 462 /** Get an Archive from the archive cache.*/ 463 463 osgDB::Archive* getFromArchiveCache(const std::string& fileName); … … 465 465 /** Get an ref_ptr<Archive> from the archive cache.*/ 466 466 osg::ref_ptr<osgDB::Archive> getRefFromArchiveCache(const std::string& fileName); 467 467 468 468 /** Remove all archives from the archive cache.*/ 469 469 void clearArchiveCache(); 470 470 471 471 /** If State is non-zero, this function releases OpenGL objects for 472 472 * the specified graphics context. Otherwise, releases OpenGL objexts … … 482 482 /** Get the SharedStateManager, creating one if one is not already created.*/ 483 483 SharedStateManager* getOrCreateSharedStateManager(); 484 484 485 485 /** Get the SharedStateManager. Return 0 if no SharedStateManager has been assigned.*/ 486 486 SharedStateManager* getSharedStateManager() { return _sharedStateManager.get(); } … … 488 488 /** Add an Archive extension.*/ 489 489 void addArchiveExtension(const std::string ext); 490 490 491 491 /** registers a protocol */ 492 492 void registerProtocol(const std::string& protocol); 493 493 494 494 /** returns true, if named protocol is registered */ 495 495 bool isProtocolRegistered(const std::string& protocol); … … 510 510 typedef std::vector< osg::ref_ptr<DynamicLibrary> > DynamicLibraryList; 511 511 typedef std::map< std::string, std::string> ExtensionAliasMap; 512 512 513 513 typedef std::pair<osg::ref_ptr<osg::Object>, double > ObjectTimeStampPair; 514 514 typedef std::map<std::string, ObjectTimeStampPair > ObjectCache; 515 515 typedef std::map<std::string, osg::ref_ptr<osgDB::Archive> > ArchiveCache; 516 516 517 517 typedef std::set<std::string> RegisteredProtocolsSet; 518 518 … … 527 527 Options::BuildKdTreesHint _buildKdTreesHint; 528 528 osg::ref_ptr<osg::KdTreeBuilder> _kdTreeBuilder; 529 529 530 530 osg::ref_ptr<FileCache> _fileCache; 531 531 532 532 osg::ref_ptr<AuthenticationMap> _authenticationMap; 533 533 534 534 bool _createNodeFromImage; 535 535 536 536 RegisteredProtocolsSet _registeredProtocols; 537 537 … … 556 556 557 557 protected: 558 558 559 559 void destruct(); 560 560 561 561 // forward declare helper classes 562 562 struct ReadObjectFunctor; … … 566 566 struct ReadArchiveFunctor; 567 567 struct ReadShaderFunctor; 568 568 569 569 // make helper classes friends to get round VS6.0 "issues" 570 570 friend struct ReadFunctor; … … 601 601 602 602 bool _openingLibrary; 603 603 604 604 // map to alias to extensions to plugins. 605 605 ExtensionAliasMap _extAliasMap; … … 610 610 // Utility: Removes whitespace from both ends of a string. 611 611 static std::string trim( const std::string& str ); 612 612 613 613 // options to pass to reader writers. 614 614 osg::ref_ptr<Options> _options; 615 615 616 616 FilePathList _dataFilePath; 617 617 FilePathList _libraryFilePath; … … 620 620 ObjectCache _objectCache; 621 621 OpenThreads::Mutex _objectCacheMutex; 622 622 623 623 624 624 ArchiveExtensionList _archiveExtList; … … 657 657 } 658 658 } 659 659 660 660 T* get() { return _rw.get(); } 661 661 662 662 protected: 663 663 osg::ref_ptr<T> _rw;
