Added FinishedObjectReadCallback to ObjectWrapper which allows

wrappers to register their own handling of post processing of objects once they have been read.
This commit is contained in:
Robert Osfield 2010-10-28 14:04:07 +00:00
parent b622a99178
commit f1b660997b
2 changed files with 18 additions and 0 deletions

View File

@ -37,10 +37,16 @@ protected:
std::string _name;
};
struct FinishedObjectReadCallback : public osg::Referenced
{
virtual void objectRead(osgDB::InputStream& is, osg::Object& obj) = 0;
};
class OSGDB_EXPORT ObjectWrapper : public osg::Referenced
{
public:
typedef std::vector< osg::ref_ptr<BaseSerializer> > SerializerList;
typedef std::vector< osg::ref_ptr<FinishedObjectReadCallback> > FinishedObjectReadCallbackList;
ObjectWrapper( osg::Object* proto, const std::string& name,
const std::string& associates );
@ -50,6 +56,9 @@ public:
const StringList& getAssociates() const { return _associates; }
void addSerializer( BaseSerializer* s ) { _serializers.push_back(s); }
void addFinishedObjectReadCallback ( FinishedObjectReadCallback* forc) { _finishedObjectReadCallbacks.push_back(forc); }
bool read( InputStream&, osg::Object& );
bool write( OutputStream&, const osg::Object& );
@ -67,6 +76,7 @@ protected:
StringList _associates;
SerializerList _serializers;
SerializerList _backupSerializers;
FinishedObjectReadCallbackList _finishedObjectReadCallbacks;
};
class Registry;

View File

@ -102,6 +102,14 @@ bool ObjectWrapper::read( InputStream& is, osg::Object& obj )
<< _name << "::" << (*itr)->getName() << std::endl;
readOK = false;
}
for ( FinishedObjectReadCallbackList::iterator itr=_finishedObjectReadCallbacks.begin();
itr!=_finishedObjectReadCallbacks.end();
++itr )
{
(*itr)->objectRead(is, obj);
}
return readOK;
}