Implement current osgDB::ReaderWriters supportsExtension interface instead

of the previous one.

Modified Files:
 	model/SGReaderWriterXML.cxx model/SGReaderWriterXML.hxx
 	tgdb/ReaderWriterSTG.cxx tgdb/ReaderWriterSTG.hxx
 	tgdb/SGReaderWriterBTG.cxx tgdb/SGReaderWriterBTG.hxx
This commit is contained in:
frohlich
2009-05-16 18:05:21 +00:00
committed by Tim Moore
parent e45912fd8a
commit 7cd149a4d8
6 changed files with 39 additions and 53 deletions

View File

@@ -54,26 +54,27 @@ sgLoad3DModel_internal(const string &path,
osg::Node *(*load_panel)(SGPropertyNode *) = 0,
SGPropertyNode *overlay = 0);
SGReaderWriterXML::SGReaderWriterXML()
{
supportsExtension("xml", "SimGear xml database format");
}
SGReaderWriterXML::~SGReaderWriterXML()
{
}
const char* SGReaderWriterXML::className() const
{
return "XML database reader";
}
bool SGReaderWriterXML::acceptsExtension(const std::string& extension) const
{
return (osgDB::equalCaseInsensitive(extension, "xml"));
}
osgDB::ReaderWriter::ReadResult
SGReaderWriterXML::readNode(const std::string& fileName,
const osgDB::ReaderWriter::Options* options) const
{
// 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);

View 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)

View File

@@ -33,17 +33,20 @@
using namespace simgear;
ReaderWriterSTG::ReaderWriterSTG()
{
supportsExtension("stg", "SimGear stg database format");
}
ReaderWriterSTG::~ReaderWriterSTG()
{
}
const char* ReaderWriterSTG::className() const
{
return "STG Database reader";
}
bool ReaderWriterSTG::acceptsExtension(const std::string& extension) const
{
return (osgDB::equalCaseInsensitive(extension, "gz")
|| osgDB::equalCaseInsensitive(extension, "stg"));
}
//#define SLOW_PAGER 1
#ifdef SLOW_PAGER
#include <unistd.h>
@@ -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);

View 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)

View File

@@ -31,31 +31,24 @@ using namespace simgear;
std::string SGReaderWriterBTGOptions::defaultOptions;
SGReaderWriterBTG::SGReaderWriterBTG()
{
supportsExtension("btg", "SimGear btg database format");
}
SGReaderWriterBTG::~SGReaderWriterBTG()
{
}
const char* SGReaderWriterBTG::className() const
{
return "BTG Database reader";
}
bool SGReaderWriterBTG::acceptsExtension(const std::string& extension) const
{
return (osgDB::equalCaseInsensitive(extension, "gz")
|| osgDB::equalCaseInsensitive(extension, "btg"));
}
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;

View File

@@ -23,10 +23,11 @@
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;