]> git.mxchange.org Git - simgear.git/commitdiff
Implement current osgDB::ReaderWriters supportsExtension interface instead
authorfrohlich <frohlich>
Sat, 16 May 2009 18:05:21 +0000 (18:05 +0000)
committerTim Moore <timoore@redhat.com>
Tue, 19 May 2009 21:53:24 +0000 (23:53 +0200)
of the previous one.

Modified Files:
  model/SGReaderWriterXML.cxx model/SGReaderWriterXML.hxx
  tgdb/ReaderWriterSTG.cxx tgdb/ReaderWriterSTG.hxx
  tgdb/SGReaderWriterBTG.cxx tgdb/SGReaderWriterBTG.hxx

simgear/scene/model/SGReaderWriterXML.cxx
simgear/scene/model/SGReaderWriterXML.hxx
simgear/scene/tgdb/ReaderWriterSTG.cxx
simgear/scene/tgdb/ReaderWriterSTG.hxx
simgear/scene/tgdb/SGReaderWriterBTG.cxx
simgear/scene/tgdb/SGReaderWriterBTG.hxx

index 7a3660f6f35577b13016aa4183e165914dee2cf0..0f4cdb955fbfffe57750cc6ebfafdbac0590dbcc 100644 (file)
@@ -54,14 +54,19 @@ sgLoad3DModel_internal(const string &path,
                        osg::Node *(*load_panel)(SGPropertyNode *) = 0,
                        SGPropertyNode *overlay = 0);
 
-const char* SGReaderWriterXML::className() const
+
+SGReaderWriterXML::SGReaderWriterXML()
+{
+    supportsExtension("xml", "SimGear xml database format");
+}
+
+SGReaderWriterXML::~SGReaderWriterXML()
 {
-    return "XML database reader";
 }
 
-bool SGReaderWriterXML::acceptsExtension(const std::string& extension) const
+const char* SGReaderWriterXML::className() const
 {
-    return (osgDB::equalCaseInsensitive(extension, "xml"));
+    return "XML database reader";
 }
 
 osgDB::ReaderWriter::ReadResult
@@ -70,10 +75,6 @@ SGReaderWriterXML::readNode(const std::string& fileName,
 {
     // SG_LOG(SG_GENERAL, SG_ALERT, "SGReaderWriterXML::readNode(" << fileName << ")");
 
-    std::string ext = osgDB::getLowerCaseFileExtension(fileName);
-    if (!acceptsExtension(ext))
-        return ReadResult::FILE_NOT_HANDLED;
-
     const SGReaderWriterXMLOptions* xmlOptions
     = dynamic_cast<const SGReaderWriterXMLOptions*>(options);
 
index 2d92c3efecdb3eca528a859e2b9990363e188412..afa5925d73da4e98964652f51768d13bf349a368 100644 (file)
@@ -27,9 +27,10 @@ namespace simgear
 class SGReaderWriterXML : public osgDB::ReaderWriter
 {
 public:
-    virtual const char* className() const;
+    SGReaderWriterXML();
+    virtual ~SGReaderWriterXML();
 
-    virtual bool acceptsExtension(const std::string& extension) const;
+    virtual const char* className() const;
 
     virtual ReadResult readNode(const std::string& fileName,
                                 const osgDB::ReaderWriter::Options* options)
index 8e7fd2a28eca6f96f50f75b1e308589f59c3ca96..57da979bf05babdcb26959c34b36bd4fb0585546 100644 (file)
 
 using namespace simgear;
 
-const char* ReaderWriterSTG::className() const
+ReaderWriterSTG::ReaderWriterSTG()
+{
+    supportsExtension("stg", "SimGear stg database format");
+}
+
+ReaderWriterSTG::~ReaderWriterSTG()
 {
-    return "STG Database reader";
 }
 
-bool ReaderWriterSTG::acceptsExtension(const std::string& extension) const
+const char* ReaderWriterSTG::className() const
 {
-    return (osgDB::equalCaseInsensitive(extension, "gz")
-            || osgDB::equalCaseInsensitive(extension, "stg"));
+    return "STG Database reader";
 }
 
 //#define SLOW_PAGER 1
@@ -53,22 +56,8 @@ osgDB::ReaderWriter::ReadResult
 ReaderWriterSTG::readNode(const std::string& fileName,
                           const osgDB::ReaderWriter::Options* options) const
 {
-    std::string ext = osgDB::getLowerCaseFileExtension(fileName);
-    if(!acceptsExtension(ext))
-        return ReadResult::FILE_NOT_HANDLED;
-    std::string stgFileName;
-    if (osgDB::equalCaseInsensitive(ext, "gz")) {
-        stgFileName = osgDB::getNameLessExtension(fileName);
-        if (!acceptsExtension(
-                osgDB::getLowerCaseFileExtension(stgFileName))) {
-            return ReadResult::FILE_NOT_HANDLED;
-        }
-    } else {
-        stgFileName = fileName;
-    }
-    osg::Node* result
-        = TileEntry::loadTileByName(osgDB::getNameLessExtension(stgFileName),
-                                      options);
+    std::string tileName = osgDB::getNameLessExtension(fileName);
+    osg::Node* result = TileEntry::loadTileByName(tileName, options);
     // For debugging race conditions
 #ifdef SLOW_PAGER
     sleep(5);
index 7f53f65a1665dda253efd435629bdc2802fa3f43..7c571ccf78462e51dea2e8a0f649c69ebf673096 100644 (file)
@@ -28,9 +28,10 @@ namespace simgear {
 
 class ReaderWriterSTG : public osgDB::ReaderWriter {
 public:
-    virtual const char* className() const;
+    ReaderWriterSTG();
+    virtual ~ReaderWriterSTG();
 
-    virtual bool acceptsExtension(const std::string& extension) const;
+    virtual const char* className() const;
 
     virtual ReadResult readNode(const std::string& fileName,
                                 const osgDB::ReaderWriter::Options* options)
index a93bfceca18c92ab95af31afc1928df919c70675..1fa3e9818ac47c9aa09d864f40782de654d1e1c7 100644 (file)
@@ -31,31 +31,24 @@ using namespace simgear;
 
 std::string SGReaderWriterBTGOptions::defaultOptions;
 
-const char* SGReaderWriterBTG::className() const
+SGReaderWriterBTG::SGReaderWriterBTG()
 {
-    return "BTG Database reader";
+    supportsExtension("btg", "SimGear btg database format");
 }
 
-bool SGReaderWriterBTG::acceptsExtension(const std::string& extension) const
+SGReaderWriterBTG::~SGReaderWriterBTG()
 {
-    return (osgDB::equalCaseInsensitive(extension, "gz")
-            || osgDB::equalCaseInsensitive(extension, "btg"));
+}
+
+const char* SGReaderWriterBTG::className() const
+{
+    return "BTG Database reader";
 }
 
 osgDB::ReaderWriter::ReadResult
 SGReaderWriterBTG::readNode(const std::string& fileName,
                             const osgDB::ReaderWriter::Options* options) const
 {
-    std::string ext = osgDB::getLowerCaseFileExtension(fileName);
-    if(!acceptsExtension(ext))
-        return ReadResult::FILE_NOT_HANDLED;
-    if (osgDB::equalCaseInsensitive(ext, "gz")) {
-        std::string btgFileName = osgDB::getNameLessExtension(fileName);
-        if (!acceptsExtension(
-                osgDB::getLowerCaseFileExtension(btgFileName))) {
-            return ReadResult::FILE_NOT_HANDLED;
-        }
-    }
     SGMaterialLib* matlib = 0;
     bool calcLights = false;
     bool useRandomObjects = false;
index 3c0ccc80f507f4d2eeded75d7a3e1a46640a0015..ca5f4a73f20fa61f69b7d459e30f09b6b79f2075 100644 (file)
 
 class SGReaderWriterBTG : public osgDB::ReaderWriter {
 public:
+    SGReaderWriterBTG();
+    virtual ~SGReaderWriterBTG();
+
     virtual const char* className() const;
  
-    virtual bool acceptsExtension(const std::string& extension) const;
-
     virtual ReadResult readNode(const std::string& fileName,
                                 const osgDB::ReaderWriter::Options* options)
         const;