15#ifndef OSGDB_OBJECTWRAPPER
16#define OSGDB_OBJECTWRAPPER
27 typedef std::vector< osg::ref_ptr<osg::Object> >
Parameters;
38 void setName(
const std::string& name ) { _name = name; }
39 const std::string&
getName()
const {
return _name; }
41 virtual bool compress( std::ostream&,
const std::string& ) = 0;
42 virtual bool decompress( std::istream&, std::string& ) = 0;
64 typedef std::vector< BaseSerializer::Type >
TypeList;
70 ObjectWrapper( CreateInstanceFunc* createInstanceFunc,
const std::string& name,
71 const std::string& associates );
72 ObjectWrapper( CreateInstanceFunc* createInstanceFunc,
const std::string& domain,
const std::string& name,
73 const std::string& associates );
79 const std::string&
getDomain()
const {
return _domain; }
80 const std::string&
getName()
const {
return _name; }
107 void resetSchema() {
if ( _backupSerializers.size()>0 ) _serializers = _backupSerializers; }
165 typedef std::map< std::string, osg::ref_ptr<ObjectWrapper> >
WrapperMap;
174 typedef std::map< std::string, osg::ref_ptr<BaseCompressor> >
CompressorMap;
199 IntLookupMap::iterator itr = _globalMap.find(group);
200 if ( itr!=_globalMap.end() )
return itr->second;
201 else return _globalMap[
"GL"];
214 const std::string& associates, AddPropFunc func );
228 const std::string& associates, AddPropFunc func );
236#define REGISTER_OBJECT_WRAPPER(NAME, CREATEINSTANCE, CLASS, ASSOCIATES) \
237 extern "C" void wrapper_serializer_##NAME(void) {} \
238 extern void wrapper_propfunc_##NAME(osgDB::ObjectWrapper*); \
239 static osg::Object* wrapper_createinstancefunc##NAME() { return CREATEINSTANCE; } \
240 static osgDB::RegisterWrapperProxy wrapper_proxy_##NAME( \
241 wrapper_createinstancefunc##NAME, #CLASS, ASSOCIATES, &wrapper_propfunc_##NAME); \
242 typedef CLASS MyClass; \
243 void wrapper_propfunc_##NAME(osgDB::ObjectWrapper* wrapper)
245#define REGISTER_OBJECT_WRAPPER2(NAME, CREATEINSTANCE, CLASS, CLASSNAME, ASSOCIATES) \
246 extern "C" void wrapper_serializer_##NAME(void) {} \
247 extern void wrapper_propfunc_##NAME(osgDB::ObjectWrapper*); \
248 static osg::Object* wrapper_createinstancefunc##NAME() { return CREATEINSTANCE; } \
249 static osgDB::RegisterWrapperProxy wrapper_proxy_##NAME( \
250 wrapper_createinstancefunc##NAME, CLASSNAME, ASSOCIATES, &wrapper_propfunc_##NAME); \
251 typedef CLASS MyClass; \
252 void wrapper_propfunc_##NAME(osgDB::ObjectWrapper* wrapper)
254#define REGISTER_CUSTOM_OBJECT_WRAPPER(DOMAIN, NAME, CREATEINSTANCE, CLASS, ASSOCIATES) \
255 extern "C" void wrapper_serializer_##NAME(void) {} \
256 extern void wrapper_propfunc_##NAME(const char*, osgDB::ObjectWrapper*); \
257 static osg::Object* wrapper_createinstancefunc##NAME() { return CREATEINSTANCE; } \
258 static osgDB::RegisterCustomWrapperProxy wrapper_proxy_##NAME( \
259 wrapper_createinstancefunc##NAME, #DOMAIN, #CLASS, ASSOCIATES, &wrapper_propfunc_##NAME); \
260 typedef CLASS MyClass; \
261 void wrapper_propfunc_##NAME(const char* domain, osgDB::ObjectWrapper* wrapper)
263#define REGISTER_CUSTOM_OBJECT_WRAPPER2(DOMAIN, NAME, CREATEINSTANCE, CLASS, CLASSNAME, ASSOCIATES) \
264 extern "C" void wrapper_serializer_##NAME(void) {} \
265 extern void wrapper_propfunc_##NAME(const char*, osgDB::ObjectWrapper*); \
266 static osg::Object* wrapper_createinstancefunc##NAME() { return CREATEINSTANCE; } \
267 static osgDB::RegisterCustomWrapperProxy wrapper_proxy_##NAME( \
268 wrapper_createinstancefunc##NAME, #DOMAIN, CLASSNAME, ASSOCIATES, &wrapper_propfunc_##NAME); \
269 typedef CLASS MyClass; \
270 void wrapper_propfunc_##NAME(const char* domain, osgDB::ObjectWrapper* wrapper)
282#define REGISTER_COMPRESSOR(NAME, CLASS) \
283 extern "C" void wrapper_compressor_##CLASS(void) {} \
284 static osgDB::RegisterCompressorProxy compressor_proxy_##CLASS(NAME, new CLASS);
Definition ReentrantMutex:24
Definition ObjectWrapper:35
BaseCompressor()
Definition ObjectWrapper:37
void setName(const std::string &name)
Definition ObjectWrapper:38
virtual bool decompress(std::istream &, std::string &)=0
virtual bool compress(std::ostream &, const std::string &)=0
const std::string & getName() const
Definition ObjectWrapper:39
std::string _name
Definition ObjectWrapper:45
Definition Serializer:141
virtual bool get(const osg::Object &, void *)
Definition Serializer:170
Type
Definition Serializer:145
int Value
Definition Serializer:42
Definition ObjectWrapper:157
IntLookup & findLookup(const std::string &group)
Definition ObjectWrapper:197
std::map< std::string, osg::ref_ptr< ObjectWrapper > > WrapperMap
Definition ObjectWrapper:165
ObjectWrapper * findWrapper(const std::string &name)
const std::string & getString(const std::string &group, IntLookup::Value value)
Definition ObjectWrapper:180
OpenThreads::ReentrantMutex _wrapperMutex
Definition ObjectWrapper:192
IntLookupMap & getLookupMap()
Definition ObjectWrapper:182
const CompressorMap & getCompressorMap() const
Definition ObjectWrapper:176
void addCompressor(BaseCompressor *compressor)
BaseCompressor * findCompressor(const std::string &name)
const IntLookupMap & getLookupMap() const
Definition ObjectWrapper:183
void removeWrapper(ObjectWrapper *wrapper)
CompressorMap & getCompressorMap()
Definition ObjectWrapper:175
CompressorMap _compressors
Definition ObjectWrapper:195
WrapperMap _wrappers
Definition ObjectWrapper:194
std::map< std::string, osg::ref_ptr< BaseCompressor > > CompressorMap
Definition ObjectWrapper:174
void removeCompressor(BaseCompressor *compressor)
IntLookupMap _globalMap
Definition ObjectWrapper:204
WrapperMap & getWrapperMap()
Definition ObjectWrapper:166
std::map< std::string, IntLookup > IntLookupMap
Definition ObjectWrapper:178
virtual ~ObjectWrapperManager()
void addWrapper(ObjectWrapper *wrapper)
IntLookup::Value getValue(const std::string &group, const std::string &str)
Definition ObjectWrapper:179
const WrapperMap & getWrapperMap() const
Definition ObjectWrapper:167
Definition ObjectWrapper:62
SerializerList _serializers
Definition ObjectWrapper:126
CreateInstanceFunc * _createInstanceFunc
Definition ObjectWrapper:122
void resetSchema()
Definition ObjectWrapper:107
const std::string & getName() const
Definition ObjectWrapper:80
TypeList _typeList
Definition ObjectWrapper:128
FinishedObjectReadCallbackList _finishedObjectReadCallbacks
Definition ObjectWrapper:129
void addSerializer(BaseSerializer *s, BaseSerializer::Type t=BaseSerializer::RW_UNDEFINED)
void setupAssociatesRevisionsInheritanceIfRequired()
SerializerList & getSerializerList()
Definition ObjectWrapper:84
bool readSchema(const StringList &properties, const TypeList &types)
std::vector< osg::ref_ptr< BaseSerializer > > SerializerList
Definition ObjectWrapper:65
bool write(OutputStream &, const osg::Object &)
ObjectWrapper(CreateInstanceFunc *createInstanceFunc, const std::string &domain, const std::string &name, const std::string &associates)
const SerializerList & getSerializerList() const
Definition ObjectWrapper:85
ObjectWrapper(CreateInstanceFunc *createInstanceFunc, const std::string &name, const std::string &associates)
TypeList & getTypeList()
Definition ObjectWrapper:87
const TypeList & getTypeList() const
Definition ObjectWrapper:88
RevisionAssociateList _associates
Definition ObjectWrapper:125
const RevisionAssociateList & getAssociates() const
Definition ObjectWrapper:82
void addMethodObject(const std::string &methodName, MethodObject *mo)
std::list< ObjectWrapperAssociate > RevisionAssociateList
Definition ObjectWrapper:67
const MethodObjectMap & getMethodObjectMap() const
Definition ObjectWrapper:114
const std::string & getDomain() const
Definition ObjectWrapper:79
void addFinishedObjectReadCallback(FinishedObjectReadCallback *forc)
Definition ObjectWrapper:100
osg::Object * createInstance() const
Definition ObjectWrapper:78
std::string _name
Definition ObjectWrapper:124
virtual ~ObjectWrapper()
Definition ObjectWrapper:120
BaseSerializer * getLastSerializer()
Definition ObjectWrapper:96
void writeSchema(StringList &properties, TypeList &types)
BaseSerializer * getSerializer(const std::string &name)
bool read(InputStream &, osg::Object &)
std::multimap< std::string, osg::ref_ptr< MethodObject > > MethodObjectMap
Definition ObjectWrapper:111
void markSerializerAsRemoved(const std::string &name)
std::string _domain
Definition ObjectWrapper:123
std::vector< BaseSerializer::Type > TypeList
Definition ObjectWrapper:64
osg::Object * CreateInstanceFunc()
Definition ObjectWrapper:68
std::vector< osg::ref_ptr< FinishedObjectReadCallback > > FinishedObjectReadCallbackList
Definition ObjectWrapper:66
int _version
Definition ObjectWrapper:131
int getUpdatedVersion() const
Definition ObjectWrapper:76
MethodObjectMap _methodObjectMap
Definition ObjectWrapper:130
void markAssociateAsRemoved(const std::string &name)
ObjectWrapper()
Definition ObjectWrapper:119
static void splitAssociates(const std::string &src, ObjectWrapper::RevisionAssociateList &list, char separator=' ')
void setUpdatedVersion(int ver)
Definition ObjectWrapper:75
SerializerList _backupSerializers
Definition ObjectWrapper:127
bool _isAssociatesRevisionsInheritanceDone
Definition ObjectWrapper:133
BaseSerializer * getSerializer(const std::string &name, BaseSerializer::Type &type)
MethodObjectMap & getMethodObjectMap()
Definition ObjectWrapper:113
void markAssociateAsAdded(const std::string &name)
Definition OutputStream:57
Definition ObjectWrapper:273
osg::ref_ptr< BaseCompressor > _compressor
Definition ObjectWrapper:279
~RegisterCompressorProxy()
RegisterCompressorProxy(const std::string &name, BaseCompressor *compressor)
Definition ObjectWrapper:223
RegisterCustomWrapperProxy(ObjectWrapper::CreateInstanceFunc *createInstanceFunc, const std::string &domain, const std::string &name, const std::string &associates, AddPropFunc func)
virtual ~RegisterCustomWrapperProxy()
osg::ref_ptr< ObjectWrapper > _wrapper
Definition ObjectWrapper:233
Definition ObjectWrapper:209
RegisterWrapperProxy(ObjectWrapper::CreateInstanceFunc *createInstanceFunc, const std::string &name, const std::string &associates, AddPropFunc func)
osg::ref_ptr< ObjectWrapper > _wrapper
Definition ObjectWrapper:219
virtual ~RegisterWrapperProxy()
Definition osgDB/Registry:54
std::vector< std::string > StringList
Definition Serializer:31
std::vector< osg::ref_ptr< osg::Object > > Parameters
Definition Callback:130
#define OSGDB_EXPORT
Definition osgDB/Export:39
Definition ObjectWrapper:49
virtual void objectRead(osgDB::InputStream &is, osg::Object &obj)=0
Definition ObjectWrapper:26
virtual ~MethodObject()
Definition ObjectWrapper:31
std::vector< osg::ref_ptr< osg::Object > > Parameters
Definition ObjectWrapper:27
virtual bool run(void *objectPtr, osg::Parameters &inputParameters, osg::Parameters &outputParameters) const =0
Definition ObjectWrapper:54
int _firstVersion
Definition ObjectWrapper:56
int _lastVersion
Definition ObjectWrapper:57
std::string _name
Definition ObjectWrapper:58
ObjectWrapperAssociate(std::string name)
Definition ObjectWrapper:55
Definition ObjectWrapper:138
UpdateWrapperVersionProxy(ObjectWrapper *w, int v)
Definition ObjectWrapper:139
int _lastVersion
Definition ObjectWrapper:151
~UpdateWrapperVersionProxy()
Definition ObjectWrapper:145
ObjectWrapper * _wrapper
Definition ObjectWrapper:150