root/OpenSceneGraph/trunk/src/osgDB/ReaderWriter.cpp @ 8620

Revision 8620, 3.3 kB (checked in by robert, 6 years ago)

Moved AuthenticalMap/AuthenticationDetails? out in their own files

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
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#include <osgDB/ReaderWriter>
15#include <osgDB/FileNameUtils>
16#include <osgDB/Archive>
17
18using namespace osgDB;
19
20osg::Object* ReaderWriter::ReadResult::getObject() { return _object.get(); }
21osg::Image* ReaderWriter::ReadResult::getImage() { return dynamic_cast<osg::Image*>(_object.get()); }
22osg::HeightField* ReaderWriter::ReadResult::getHeightField() { return dynamic_cast<osg::HeightField*>(_object.get()); }
23osg::Node* ReaderWriter::ReadResult::getNode() { return dynamic_cast<osg::Node*>(_object.get()); }
24osgDB::Archive* ReaderWriter::ReadResult::getArchive() { return dynamic_cast<osgDB::Archive*>(_object.get()); }
25osg::Shader* ReaderWriter::ReadResult::getShader() { return dynamic_cast<osg::Shader*>(_object.get()); }
26
27osg::Object* ReaderWriter::ReadResult::takeObject() { osg::Object* obj = _object.get(); if (obj) { obj->ref(); _object=NULL; obj->unref_nodelete(); } return obj; }
28osg::Image* ReaderWriter::ReadResult::takeImage() { osg::Image* image=dynamic_cast<osg::Image*>(_object.get()); if (image) { image->ref(); _object=NULL; image->unref_nodelete(); } return image; }
29osg::HeightField* ReaderWriter::ReadResult::takeHeightField() { osg::HeightField* hf=dynamic_cast<osg::HeightField*>(_object.get()); if (hf) { hf->ref(); _object=NULL; hf->unref_nodelete(); } return hf; }
30osg::Node* ReaderWriter::ReadResult::takeNode() { osg::Node* node=dynamic_cast<osg::Node*>(_object.get()); if (node) { node->ref(); _object=NULL; node->unref_nodelete(); } return node; }
31osgDB::Archive* ReaderWriter::ReadResult::takeArchive() { osgDB::Archive* archive=dynamic_cast<osgDB::Archive*>(_object.get()); if (archive) { archive->ref(); _object=NULL; archive->unref_nodelete(); } return archive; }
32osg::Shader* ReaderWriter::ReadResult::takeShader() { osg::Shader* shader=dynamic_cast<osg::Shader*>(_object.get()); if (shader) { shader->ref(); _object=NULL; shader->unref_nodelete(); } return shader; }
33
34ReaderWriter::~ReaderWriter()
35{
36}
37
38bool ReaderWriter::acceptsExtension(const std::string& extension) const
39{
40    // check for an exact match
41    std::string lowercase_ext = convertToLowerCase(extension);
42    if (_supportedExtensions.count(lowercase_ext)!=0) return true;
43   
44    // if plugin supports wildcard extension then passthrough all types
45    return (_supportedExtensions.count("*")!=0);
46}
47
48void ReaderWriter::supportsProtocol(const std::string& fmt, const std::string& description)
49{
50    _supportedProtocols[convertToLowerCase(fmt)] = description;
51}
52
53void ReaderWriter::supportsExtension(const std::string& fmt, const std::string& description)
54{
55    _supportedExtensions[convertToLowerCase(fmt)] = description;
56}
57
58void ReaderWriter::supportsOption(const std::string& fmt, const std::string& description)
59{
60    _supportedOptions[fmt] = description;
61}
Note: See TracBrowser for help on using the browser.