From Alberto Farre, changed the cache hint option in read*() calls from being

a bool to a enum osgDB::Registru::CacheHintOptions to be used a bit mask flag.

From Robert Osfied, added osgDB::Registry::ReadFileCallback and
osgDB::Registry::WriteFileCallback to allow customizition of read and write
calls.
This commit is contained in:
Robert Osfield
2004-04-10 16:11:56 +00:00
parent ae7ceae631
commit 2a6e155d03
5 changed files with 208 additions and 49 deletions

View File

@@ -104,6 +104,20 @@ class InsertCallbacksVisitor : public osg::NodeVisitor
}
};
class MyReadFileCallback : public osgDB::Registry::ReadFileCallback
{
public:
virtual osgDB::ReaderWriter::ReadResult readNode(const std::string& fileName, osgDB::Registry::CacheHintOptions useObjectCache)
{
std::cout<<"before readNode"<<std::endl;
// note when calling the Registry to do the read you have to call readNodeImplementation NOT readNode, as this will
// cause on infinite recusive loop.
osgDB::ReaderWriter::ReadResult result = osgDB::Registry::instance()->readNodeImplementation(fileName,useObjectCache);
std::cout<<"after readNode"<<std::endl;
return result;
}
};
int main( int argc, char **argv )
{
// use an ArgumentParser object to manage the program arguments.
@@ -114,6 +128,9 @@ int main( int argc, char **argv )
arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ...");
arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
// set the osgDB::Registy the read file callback to catch all requests for reading files.
osgDB::Registry::instance()->setReadFileCallback(new MyReadFileCallback());
// initialize the viewer.
osgProducer::Viewer viewer(arguments);