Refactored the DotOsgWrapper support in osgDB::Registry so it's now provided by the osgDB::DeprecatedDotOsgWrapperManager.
This commit is contained in:
@@ -370,6 +370,7 @@ Registry::Registry()
|
||||
registerProtocol("http");
|
||||
|
||||
_objectWrapperManager = new ObjectWrapperManager;
|
||||
_deprecatedDotOsgWrapperManager = new DeprecatedDotOsgWrapperManager;
|
||||
}
|
||||
|
||||
|
||||
@@ -490,104 +491,6 @@ void Registry::readCommandLine(osg::ArgumentParser& arguments)
|
||||
}
|
||||
}
|
||||
|
||||
void Registry::addDotOsgWrapper(DotOsgWrapper* wrapper)
|
||||
{
|
||||
if (wrapper==0L) return;
|
||||
|
||||
//notify(INFO) << "osg::Registry::addDotOsgWrapper("<<wrapper->getName()<<")"<< std::endl;
|
||||
const DotOsgWrapper::Associates& assoc = wrapper->getAssociates();
|
||||
|
||||
for(DotOsgWrapper::Associates::const_iterator itr=assoc.begin();
|
||||
itr!=assoc.end();
|
||||
++itr)
|
||||
{
|
||||
//notify(INFO) << " ("<<*itr<<")"<< std::endl;
|
||||
}
|
||||
|
||||
const std::string& name = wrapper->getName();
|
||||
const osg::Object* proto = wrapper->getPrototype();
|
||||
|
||||
_objectWrapperMap[name] = wrapper;
|
||||
if (wrapper->getReadWriteMode()==DotOsgWrapper::READ_AND_WRITE) _classNameWrapperMap[name] = wrapper;
|
||||
|
||||
if (proto)
|
||||
{
|
||||
std::string libraryName = proto->libraryName();
|
||||
std::string compositeName = libraryName + "::" + name;
|
||||
|
||||
_objectWrapperMap[compositeName] = wrapper;
|
||||
if (wrapper->getReadWriteMode()==DotOsgWrapper::READ_AND_WRITE) _classNameWrapperMap[compositeName] = wrapper;
|
||||
|
||||
if (dynamic_cast<const Image*>(proto))
|
||||
{
|
||||
_imageWrapperMap[name] = wrapper;
|
||||
_imageWrapperMap[compositeName] = wrapper;
|
||||
}
|
||||
if (dynamic_cast<const Drawable*>(proto))
|
||||
{
|
||||
_drawableWrapperMap[name] = wrapper;
|
||||
_drawableWrapperMap[compositeName] = wrapper;
|
||||
}
|
||||
if (dynamic_cast<const StateAttribute*>(proto))
|
||||
{
|
||||
_stateAttrWrapperMap[name] = wrapper;
|
||||
_stateAttrWrapperMap[compositeName] = wrapper;
|
||||
}
|
||||
if (dynamic_cast<const Uniform*>(proto))
|
||||
{
|
||||
_uniformWrapperMap[name] = wrapper;
|
||||
_uniformWrapperMap[compositeName] = wrapper;
|
||||
}
|
||||
if (dynamic_cast<const Node*>(proto))
|
||||
{
|
||||
_nodeWrapperMap[name] = wrapper;
|
||||
_nodeWrapperMap[compositeName] = wrapper;
|
||||
}
|
||||
if (dynamic_cast<const Shader*>(proto))
|
||||
{
|
||||
_shaderWrapperMap[name] = wrapper;
|
||||
_shaderWrapperMap[compositeName] = wrapper;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// need to change to delete all instances of wrapper, since we
|
||||
// now can have a wrapper entered twice with the addition of the
|
||||
// library::class composite name.
|
||||
void Registry::eraseWrapper(DotOsgWrapperMap& wrappermap,DotOsgWrapper* wrapper)
|
||||
{
|
||||
typedef std::vector<DotOsgWrapperMap::iterator> EraseList;
|
||||
EraseList eraseList;
|
||||
for(DotOsgWrapperMap::iterator witr=wrappermap.begin();
|
||||
witr!=wrappermap.end();
|
||||
++witr)
|
||||
{
|
||||
if (witr->second==wrapper) eraseList.push_back(witr);
|
||||
}
|
||||
for(EraseList::iterator eitr=eraseList.begin();
|
||||
eitr!=eraseList.end();
|
||||
++eitr)
|
||||
{
|
||||
wrappermap.erase(*eitr);
|
||||
}
|
||||
}
|
||||
|
||||
void Registry::removeDotOsgWrapper(DotOsgWrapper* wrapper)
|
||||
{
|
||||
if (wrapper==0L) return;
|
||||
|
||||
eraseWrapper(_objectWrapperMap,wrapper);
|
||||
eraseWrapper(_classNameWrapperMap,wrapper);
|
||||
eraseWrapper(_imageWrapperMap,wrapper);
|
||||
eraseWrapper(_drawableWrapperMap,wrapper);
|
||||
eraseWrapper(_uniformWrapperMap,wrapper);
|
||||
eraseWrapper(_stateAttrWrapperMap,wrapper);
|
||||
eraseWrapper(_nodeWrapperMap,wrapper);
|
||||
eraseWrapper(_shaderWrapperMap,wrapper);
|
||||
}
|
||||
|
||||
void Registry::addReaderWriter(ReaderWriter* rw)
|
||||
{
|
||||
if (rw==0L) return;
|
||||
@@ -863,6 +766,7 @@ ReaderWriter* Registry::getReaderWriterForMimeType(const std::string& mimeType)
|
||||
NULL;
|
||||
}
|
||||
|
||||
#if 0
|
||||
struct concrete_wrapper: basic_type_wrapper
|
||||
{
|
||||
virtual ~concrete_wrapper() {}
|
||||
@@ -873,567 +777,7 @@ struct concrete_wrapper: basic_type_wrapper
|
||||
}
|
||||
const osg::Object *myobj_;
|
||||
};
|
||||
|
||||
osg::Object* Registry::readObjectOfType(const osg::Object& compObj,Input& fr)
|
||||
{
|
||||
return readObjectOfType(concrete_wrapper(&compObj), fr);
|
||||
}
|
||||
|
||||
osg::Object* Registry::readObjectOfType(const basic_type_wrapper &btw,Input& fr)
|
||||
{
|
||||
const char *str = fr[0].getStr();
|
||||
if (str==NULL) return NULL;
|
||||
|
||||
if (fr[0].matchWord("Use"))
|
||||
{
|
||||
if (fr[1].isString())
|
||||
{
|
||||
Object* obj = fr.getObjectForUniqueID(fr[1].getStr());
|
||||
if (obj && btw.matches(obj))
|
||||
{
|
||||
fr+=2;
|
||||
return obj;
|
||||
}
|
||||
}
|
||||
else return NULL;
|
||||
|
||||
}
|
||||
|
||||
std::string name = str;
|
||||
DotOsgWrapperMap::iterator itr = _objectWrapperMap.find(name);
|
||||
if (itr==_objectWrapperMap.end())
|
||||
{
|
||||
// not found so check if a library::class composite name.
|
||||
std::string token = fr[0].getStr();
|
||||
std::string::size_type posDoubleColon = token.rfind("::");
|
||||
if (posDoubleColon != std::string::npos)
|
||||
{
|
||||
// we have a composite name so now strip off the library name
|
||||
// are try to load it, and then retry the readObject to see
|
||||
// if we can recognize the objects.
|
||||
std::string libraryName = std::string(token,0,posDoubleColon);
|
||||
|
||||
// first try the standard nodekit library.
|
||||
std::string nodeKitLibraryName = createLibraryNameForNodeKit(libraryName);
|
||||
if (loadLibrary(nodeKitLibraryName)==LOADED) return readObjectOfType(btw,fr);
|
||||
|
||||
// otherwise try the osgdb_ plugin library.
|
||||
std::string pluginLibraryName = createLibraryNameForExtension(std::string("deprecated_")+libraryName);
|
||||
if (loadLibrary(pluginLibraryName)==LOADED) return readObjectOfType(btw,fr);
|
||||
|
||||
// otherwise try the osgdb_ plugin library.
|
||||
pluginLibraryName = createLibraryNameForExtension(libraryName);
|
||||
if (loadLibrary(pluginLibraryName)==LOADED) return readObjectOfType(btw,fr);
|
||||
}
|
||||
}
|
||||
else if (fr[1].isOpenBracket())
|
||||
{
|
||||
DotOsgWrapper* wrapper = itr->second.get();
|
||||
const osg::Object* proto = wrapper->getPrototype();
|
||||
if (proto==NULL)
|
||||
{
|
||||
osg::notify(osg::WARN)<<"Token "<<fr[0].getStr()<<" read, but has no prototype, cannot load."<< std::endl;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!btw.matches(proto))
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// record the number of nested brackets move the input iterator
|
||||
// over the name { tokens.
|
||||
int entry = fr[0].getNoNestedBrackets();
|
||||
fr+=2;
|
||||
|
||||
const DotOsgWrapper::Associates& assoc = wrapper->getAssociates();
|
||||
osg::Object* obj = proto->cloneType();
|
||||
|
||||
while(!fr.eof() && fr[0].getNoNestedBrackets()>entry)
|
||||
{
|
||||
bool iteratorAdvanced = false;
|
||||
if (fr[0].matchWord("UniqueID") && fr[1].isString())
|
||||
{
|
||||
fr.registerUniqueIDForObject(fr[1].getStr(),obj);
|
||||
fr += 2;
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
|
||||
// read the local data by iterating through the associate
|
||||
// list, mapping the associate names to DotOsgWrapper's which
|
||||
// in turn have the appropriate functions.
|
||||
for(DotOsgWrapper::Associates::const_iterator aitr=assoc.begin();
|
||||
aitr!=assoc.end();
|
||||
++aitr)
|
||||
{
|
||||
DotOsgWrapperMap::iterator mitr = _objectWrapperMap.find(*aitr);
|
||||
if (mitr==_objectWrapperMap.end())
|
||||
{
|
||||
// not found so check if a library::class composite name.
|
||||
std::string token = *aitr;
|
||||
std::string::size_type posDoubleColon = token.rfind("::");
|
||||
if (posDoubleColon != std::string::npos)
|
||||
{
|
||||
// we have a composite name so now strip off the library name
|
||||
// and try to load it, and then retry the find to see
|
||||
// if we can recognize the objects.
|
||||
std::string libraryName = std::string(token,0,posDoubleColon);
|
||||
|
||||
// first try the standard nodekit library.
|
||||
std::string nodeKitLibraryName = createLibraryNameForNodeKit(libraryName);
|
||||
if (loadLibrary(nodeKitLibraryName)==LOADED)
|
||||
{
|
||||
mitr = _objectWrapperMap.find(*aitr);
|
||||
if (mitr==_objectWrapperMap.end())
|
||||
{
|
||||
// otherwise try the osgdb_ plugin library.
|
||||
std::string pluginLibraryName = createLibraryNameForExtension(libraryName);
|
||||
if (loadLibrary(pluginLibraryName)==LOADED)
|
||||
{
|
||||
mitr = _objectWrapperMap.find(*aitr);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mitr!=_objectWrapperMap.end())
|
||||
{
|
||||
// get the function to read the data...
|
||||
DotOsgWrapper::ReadFunc rf = mitr->second->getReadFunc();
|
||||
if (rf && (*rf)(*obj,fr)) iteratorAdvanced = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!iteratorAdvanced) fr.advanceOverCurrentFieldOrBlock();
|
||||
}
|
||||
++fr; // step over trailing '}'
|
||||
|
||||
return obj;
|
||||
|
||||
}
|
||||
return 0L;
|
||||
}
|
||||
|
||||
//
|
||||
// read object from input iterator.
|
||||
//
|
||||
osg::Object* Registry::readObject(DotOsgWrapperMap& dowMap,Input& fr)
|
||||
{
|
||||
const char *str = fr[0].getStr();
|
||||
if (str==NULL) return NULL;
|
||||
|
||||
std::string name = str;
|
||||
DotOsgWrapperMap::iterator itr = dowMap.find(name);
|
||||
if (itr==dowMap.end())
|
||||
{
|
||||
// not found so check if a library::class composite name.
|
||||
std::string token = fr[0].getStr();
|
||||
std::string::size_type posDoubleColon = token.rfind("::");
|
||||
if (posDoubleColon != std::string::npos)
|
||||
{
|
||||
// we have a composite name so now strip off the library name
|
||||
// are try to load it, and then retry the readObject to see
|
||||
// if we can recognize the objects.
|
||||
|
||||
std::string libraryName = std::string(token,0,posDoubleColon);
|
||||
|
||||
// first try the standard nodekit library.
|
||||
std::string nodeKitLibraryName = createLibraryNameForNodeKit(libraryName);
|
||||
if (loadLibrary(nodeKitLibraryName)==LOADED) return readObject(dowMap,fr);
|
||||
|
||||
// otherwise try the osgdb_ plugin library.
|
||||
std::string pluginLibraryName = createLibraryNameForExtension(libraryName);
|
||||
if (loadLibrary(pluginLibraryName)==LOADED) return readObject(dowMap,fr);
|
||||
}
|
||||
}
|
||||
else if (fr[1].isOpenBracket())
|
||||
{
|
||||
|
||||
DotOsgWrapper* wrapper = itr->second.get();
|
||||
const osg::Object* proto = wrapper->getPrototype();
|
||||
if (proto==NULL)
|
||||
{
|
||||
osg::notify(osg::WARN)<<"Token "<<fr[0].getStr()<<" read, but has no prototype, cannot load."<< std::endl;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
// record the number of nested brackets move the input iterator
|
||||
// over the name { tokens.
|
||||
int entry = fr[0].getNoNestedBrackets();
|
||||
fr+=2;
|
||||
|
||||
const DotOsgWrapper::Associates& assoc = wrapper->getAssociates();
|
||||
osg::Object* obj = proto->cloneType();
|
||||
|
||||
while(!fr.eof() && fr[0].getNoNestedBrackets()>entry)
|
||||
{
|
||||
bool iteratorAdvanced = false;
|
||||
if (fr[0].matchWord("UniqueID") && fr[1].isString())
|
||||
{
|
||||
fr.registerUniqueIDForObject(fr[1].getStr(),obj);
|
||||
fr += 2;
|
||||
iteratorAdvanced = true;
|
||||
}
|
||||
|
||||
// read the local data by iterating through the associate
|
||||
// list, mapping the associate names to DotOsgWrapper's which
|
||||
// in turn have the appropriate functions.
|
||||
for(DotOsgWrapper::Associates::const_iterator aitr=assoc.begin();
|
||||
aitr!=assoc.end();
|
||||
++aitr)
|
||||
{
|
||||
DotOsgWrapperMap::iterator mitr = _objectWrapperMap.find(*aitr);
|
||||
if (mitr==_objectWrapperMap.end())
|
||||
{
|
||||
// not found so check if a library::class composite name.
|
||||
std::string token = *aitr;
|
||||
std::string::size_type posDoubleColon = token.rfind("::");
|
||||
if (posDoubleColon != std::string::npos)
|
||||
{
|
||||
|
||||
// we have a composite name so now strip off the library name
|
||||
// are try to load it, and then retry the find to see
|
||||
// if we can recognize the objects.
|
||||
|
||||
std::string libraryName = std::string(token,0,posDoubleColon);
|
||||
|
||||
// first try the standard nodekit library.
|
||||
std::string nodeKitLibraryName = createLibraryNameForNodeKit(libraryName);
|
||||
if (loadLibrary(nodeKitLibraryName)==LOADED)
|
||||
{
|
||||
mitr = _objectWrapperMap.find(*aitr);
|
||||
}
|
||||
|
||||
if (mitr==_objectWrapperMap.end())
|
||||
{
|
||||
// otherwise try the osgdb_ plugin library.
|
||||
std::string pluginLibraryName = createLibraryNameForExtension(libraryName);
|
||||
if (loadLibrary(pluginLibraryName)==LOADED)
|
||||
{
|
||||
mitr = _objectWrapperMap.find(*aitr);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (mitr!=_objectWrapperMap.end())
|
||||
{
|
||||
// get the function to read the data...
|
||||
DotOsgWrapper::ReadFunc rf = mitr->second->getReadFunc();
|
||||
if (rf && (*rf)(*obj,fr)) iteratorAdvanced = true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!iteratorAdvanced) fr.advanceOverCurrentFieldOrBlock();
|
||||
}
|
||||
++fr; // step over trailing '}'
|
||||
|
||||
return obj;
|
||||
|
||||
}
|
||||
|
||||
return 0L;
|
||||
}
|
||||
|
||||
//
|
||||
// read object from input iterator.
|
||||
//
|
||||
Object* Registry::readObject(Input& fr)
|
||||
{
|
||||
if (fr[0].matchWord("Use"))
|
||||
{
|
||||
if (fr[1].isString())
|
||||
{
|
||||
Object* obj = fr.getObjectForUniqueID(fr[1].getStr());
|
||||
if (obj) fr+=2;
|
||||
return obj;
|
||||
}
|
||||
else return NULL;
|
||||
|
||||
}
|
||||
|
||||
return readObject(_objectWrapperMap,fr);
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// read image from input iterator.
|
||||
//
|
||||
Image* Registry::readImage(Input& fr)
|
||||
{
|
||||
if (fr[0].matchWord("Use"))
|
||||
{
|
||||
if (fr[1].isString())
|
||||
{
|
||||
Image* image = dynamic_cast<Image*>(fr.getObjectForUniqueID(fr[1].getStr()));
|
||||
if (image) fr+=2;
|
||||
return image;
|
||||
}
|
||||
else return NULL;
|
||||
|
||||
}
|
||||
|
||||
osg::Object* obj = readObject(_imageWrapperMap,fr);
|
||||
osg::Image* image = dynamic_cast<Image*>(obj);
|
||||
if (image) return image;
|
||||
else if (obj) obj->unref();
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// read drawable from input iterator.
|
||||
//
|
||||
Drawable* Registry::readDrawable(Input& fr)
|
||||
{
|
||||
if (fr[0].matchWord("Use"))
|
||||
{
|
||||
if (fr[1].isString())
|
||||
{
|
||||
Drawable* drawable = dynamic_cast<Drawable*>(fr.getObjectForUniqueID(fr[1].getStr()));
|
||||
if (drawable) fr+=2;
|
||||
return drawable;
|
||||
}
|
||||
else return NULL;
|
||||
|
||||
}
|
||||
|
||||
osg::Object* obj = readObject(_drawableWrapperMap,fr);
|
||||
osg::Drawable* drawable = dynamic_cast<Drawable*>(obj);
|
||||
if (drawable) return drawable;
|
||||
else if (obj) obj->unref();
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//
|
||||
// read drawable from input iterator.
|
||||
//
|
||||
StateAttribute* Registry::readStateAttribute(Input& fr)
|
||||
{
|
||||
|
||||
if (fr[0].matchWord("Use"))
|
||||
{
|
||||
if (fr[1].isString())
|
||||
{
|
||||
StateAttribute* attribute = dynamic_cast<StateAttribute*>(fr.getObjectForUniqueID(fr[1].getStr()));
|
||||
if (attribute) fr+=2;
|
||||
return attribute;
|
||||
}
|
||||
else return NULL;
|
||||
|
||||
}
|
||||
|
||||
return dynamic_cast<StateAttribute*>(readObject(_stateAttrWrapperMap,fr));
|
||||
}
|
||||
|
||||
//
|
||||
// read drawable from input iterator.
|
||||
//
|
||||
Uniform* Registry::readUniform(Input& fr)
|
||||
{
|
||||
|
||||
if (fr[0].matchWord("Use"))
|
||||
{
|
||||
if (fr[1].isString())
|
||||
{
|
||||
Uniform* attribute = dynamic_cast<Uniform*>(fr.getObjectForUniqueID(fr[1].getStr()));
|
||||
if (attribute) fr+=2;
|
||||
return attribute;
|
||||
}
|
||||
else return NULL;
|
||||
|
||||
}
|
||||
|
||||
return dynamic_cast<Uniform*>(readObject(_uniformWrapperMap,fr));
|
||||
}
|
||||
|
||||
//
|
||||
// read node from input iterator.
|
||||
//
|
||||
Node* Registry::readNode(Input& fr)
|
||||
{
|
||||
if (fr[0].matchWord("Use"))
|
||||
{
|
||||
if (fr[1].isString())
|
||||
{
|
||||
Node* node = dynamic_cast<Node*>(fr.getObjectForUniqueID(fr[1].getStr()));
|
||||
if (node) fr+=2;
|
||||
return node;
|
||||
}
|
||||
else return NULL;
|
||||
|
||||
}
|
||||
|
||||
osg::Object* obj = readObject(_nodeWrapperMap,fr);
|
||||
osg::Node* node = dynamic_cast<Node*>(obj);
|
||||
if (node) return node;
|
||||
else if (obj) obj->unref();
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//
|
||||
// read image from input iterator.
|
||||
//
|
||||
Shader* Registry::readShader(Input& fr)
|
||||
{
|
||||
if (fr[0].matchWord("Use"))
|
||||
{
|
||||
if (fr[1].isString())
|
||||
{
|
||||
Shader* shader = dynamic_cast<Shader*>(fr.getObjectForUniqueID(fr[1].getStr()));
|
||||
if (shader) fr+=2;
|
||||
return shader;
|
||||
}
|
||||
else return NULL;
|
||||
|
||||
}
|
||||
|
||||
osg::Object* obj = readObject(_shaderWrapperMap,fr);
|
||||
osg::Shader* shader = dynamic_cast<Shader*>(obj);
|
||||
if (shader) return shader;
|
||||
else if (obj) obj->unref();
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//
|
||||
// Write object to output
|
||||
//
|
||||
bool Registry::writeObject(const osg::Object& obj,Output& fw)
|
||||
{
|
||||
|
||||
if (obj.referenceCount()>1)
|
||||
{
|
||||
std::string uniqueID;
|
||||
if (fw.getUniqueIDForObject(&obj,uniqueID))
|
||||
{
|
||||
fw.writeUseID( uniqueID );
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
const std::string classname( obj.className() );
|
||||
const std::string libraryName( obj.libraryName() );
|
||||
const std::string compositeName( libraryName + "::" + classname );
|
||||
|
||||
// try composite name first
|
||||
DotOsgWrapperMap::iterator itr = _classNameWrapperMap.find(compositeName);
|
||||
|
||||
if (itr==_classNameWrapperMap.end())
|
||||
{
|
||||
// first try the standard nodekit library.
|
||||
std::string nodeKitLibraryName = createLibraryNameForNodeKit(libraryName);
|
||||
if (loadLibrary(nodeKitLibraryName)==LOADED) return writeObject(obj,fw);
|
||||
|
||||
// otherwise try the osgdb_ plugin library.
|
||||
std::string pluginLibraryName = createLibraryNameForExtension(libraryName);
|
||||
if (loadLibrary(pluginLibraryName)==LOADED) return writeObject(obj,fw);
|
||||
|
||||
// otherwise try simple class name
|
||||
if (itr == _classNameWrapperMap.end())
|
||||
itr = _classNameWrapperMap.find(classname);
|
||||
}
|
||||
|
||||
if (itr!=_classNameWrapperMap.end())
|
||||
{
|
||||
DotOsgWrapper* wrapper = itr->second.get();
|
||||
const DotOsgWrapper::Associates& assoc = wrapper->getAssociates();
|
||||
|
||||
if (libraryName=="osg")
|
||||
{
|
||||
// member of the core osg, so no need to have composite library::class name.
|
||||
fw.writeBeginObject( wrapper->getName() );
|
||||
}
|
||||
else
|
||||
{
|
||||
// member of the node kit so must use composite library::class name.
|
||||
std::string::size_type posDoubleColon = wrapper->getName().find("::");
|
||||
if (posDoubleColon != std::string::npos)
|
||||
{
|
||||
fw.writeBeginObject( wrapper->getName() );
|
||||
}
|
||||
else
|
||||
{
|
||||
fw.writeBeginObject( libraryName + "::" + wrapper->getName() );
|
||||
}
|
||||
}
|
||||
fw.moveIn();
|
||||
|
||||
|
||||
// write out the unique ID if required.
|
||||
if (obj.referenceCount()>1)
|
||||
{
|
||||
std::string uniqueID;
|
||||
fw.createUniqueIDForObject(&obj,uniqueID);
|
||||
fw.registerUniqueIDForObject(&obj,uniqueID);
|
||||
fw.writeUniqueID( uniqueID );
|
||||
}
|
||||
|
||||
// read the local data by iterating through the associate
|
||||
// list, mapping the associate names to DotOsgWrapper's which
|
||||
// in turn have the appropriate functions.
|
||||
for(DotOsgWrapper::Associates::const_iterator aitr=assoc.begin();
|
||||
aitr!=assoc.end();
|
||||
++aitr)
|
||||
{
|
||||
DotOsgWrapperMap::iterator mitr = _objectWrapperMap.find(*aitr);
|
||||
if (mitr==_objectWrapperMap.end())
|
||||
{
|
||||
// not found so check if a library::class composite name.
|
||||
std::string token = *aitr;
|
||||
std::string::size_type posDoubleColon = token.rfind("::");
|
||||
if (posDoubleColon != std::string::npos)
|
||||
{
|
||||
|
||||
// we have a composite name so now strip off the library name
|
||||
// are try to load it, and then retry the find to see
|
||||
// if we can recognize the objects.
|
||||
|
||||
std::string libraryName = std::string(token,0,posDoubleColon);
|
||||
|
||||
// first try the standard nodekit library.
|
||||
std::string nodeKitLibraryName = createLibraryNameForNodeKit(libraryName);
|
||||
if (loadLibrary(nodeKitLibraryName)==LOADED)
|
||||
{
|
||||
mitr = _objectWrapperMap.find(*aitr);
|
||||
}
|
||||
|
||||
if (mitr==_objectWrapperMap.end())
|
||||
{
|
||||
// otherwise try the osgdb_ plugin library.
|
||||
std::string pluginLibraryName = createLibraryNameForExtension(libraryName);
|
||||
if (loadLibrary(pluginLibraryName)==LOADED)
|
||||
{
|
||||
mitr = _objectWrapperMap.find(*aitr);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
if (mitr!=_objectWrapperMap.end())
|
||||
{
|
||||
// get the function to read the data...
|
||||
DotOsgWrapper::WriteFunc wf = mitr->second->getWriteFunc();
|
||||
if (wf) (*wf)(obj,fw);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fw.moveOut();
|
||||
fw.writeEndObject();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user