Permalink
Browse files

Added createObject() interface

  • Loading branch information...
1 parent 9f5ebf8 commit 3a176fe22e3668cafd85e0192b23cf601dae35bb @osg-training-guest osg-training-guest committed Oct 4, 2013
Showing with 11 additions and 1 deletion.
  1. +5 −1 include/osgDB/PropertyInterface
  2. +6 −0 src/osgDB/PropertyInterface.cpp
View
6 include/osgDB/PropertyInterface
@@ -126,6 +126,10 @@ public:
bool areTypesCompatible(osgDB::BaseSerializer::Type lhs, osgDB::BaseSerializer::Type rhs) const;
+ /** create an object of specified type for provided compound class name in the form libraryName::className. */
+ osg::Object* createObject(const std::string& compounClassdName) const;
+
+
/// template method for getting property data, return true if property available and the type is compatible, otherwise returns false.
template<typename T>
bool getProperty(const osg::Object* object, const std::string& propertyName, T& value);
@@ -212,4 +216,4 @@ bool PropertyInterface::setProperty(osg::Object* object, const std::string& prop
}
-#endif
+#endif
View
6 src/osgDB/PropertyInterface.cpp
@@ -282,6 +282,12 @@ osgDB::BaseSerializer* PropertyInterface::getSerializer(const osg::Object* objec
return ow ? ow->getSerializer(propertyName, type) : 0;
}
+osg::Object* PropertyInterface::createObject(const std::string& compoundClassName) const
+{
+ osgDB::ObjectWrapper* ow = osgDB::Registry::instance()->getObjectWrapperManager()->findWrapper(compoundClassName);
+ return (ow!=0) ? ow->createInstance() : 0;
+}
+
bool PropertyInterface::copyPropertyDataFromObject(const osg::Object* object, const std::string& propertyName, void* valuePtr, unsigned int valueSize, osgDB::BaseSerializer::Type valueType)
{
_poi->flush();

0 comments on commit 3a176fe

Please sign in to comment.