diff --git a/src/osgPlugins/lua/GeodeMethods.cpp b/src/osgPlugins/lua/GeodeMethods.cpp deleted file mode 100644 index 4247afd1a..000000000 --- a/src/osgPlugins/lua/GeodeMethods.cpp +++ /dev/null @@ -1,82 +0,0 @@ -/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2013 Robert Osfield - * - * This library is open source and may be redistributed and/or modified under - * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or - * (at your option) any later version. The full license is in LICENSE file - * included with this distribution, and on the openscenegraph.org website. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * OpenSceneGraph Public License for more details. -*/ - -#include -#include -#include "MethodObject.h" - -struct GeodeGetNumDrawables : public osgDB::MethodObject -{ - virtual bool run(void* objectPtr, osg::Parameters& inputParameters, osg::Parameters& outputParameters) const - { - osg::Geode* geode = reinterpret_cast(objectPtr); - outputParameters.push_back(new osg::UIntValueObject("return", geode->getNumDrawables())); - return true; - } -}; - - -struct GeodeGetDrawable : public osgDB::MethodObject -{ - virtual bool run(void* objectPtr, osg::Parameters& inputParameters, osg::Parameters& outputParameters) const - { - if (inputParameters.empty()) return false; - - osg::Object* indexObject = inputParameters[0].get(); - osg::UIntValueObject* uivo = dynamic_cast(indexObject); - if (!uivo) return false; - - osg::Geode* geode = reinterpret_cast(objectPtr); - outputParameters.push_back(geode->getDrawable(uivo->getValue())); - - return true; - } -}; - -struct GeodeAddDrawable : public osgDB::MethodObject -{ - virtual bool run(void* objectPtr, osg::Parameters& inputParameters, osg::Parameters& outputParameters) const - { - if (inputParameters.empty()) return false; - - osg::Drawable* child = dynamic_cast(inputParameters[0].get()); - if (!child) return false; - - osg::Geode* geode = reinterpret_cast(objectPtr); - geode->addDrawable(child); - - return true; - } -}; - - -struct GeodeRemoveDrawable : public osgDB::MethodObject -{ - virtual bool run(void* objectPtr, osg::Parameters& inputParameters, osg::Parameters& outputParameters) const - { - if (inputParameters.empty()) return false; - - osg::Drawable* child = dynamic_cast(inputParameters[0].get()); - if (!child) return false; - - osg::Geode* geode = reinterpret_cast(objectPtr); - geode->removeDrawable(child); - - return true; - } -}; - -static osgDB::RegisterMethodObjectProxy s_getNumDrawables("osg::Geode","getNumDrawables",new GeodeGetNumDrawables()); -static osgDB::RegisterMethodObjectProxy s_getNumDrawable("osg::Geode","getDrawable",new GeodeGetDrawable()); -static osgDB::RegisterMethodObjectProxy s_getAddDrawable("osg::Geode","addDrawable",new GeodeAddDrawable()); -static osgDB::RegisterMethodObjectProxy s_getRemoveDrawable("osg::Geode","removeDrawable",new GeodeRemoveDrawable()); diff --git a/src/osgPlugins/lua/GroupMethods.cpp b/src/osgPlugins/lua/GroupMethods.cpp deleted file mode 100644 index c1130ed51..000000000 --- a/src/osgPlugins/lua/GroupMethods.cpp +++ /dev/null @@ -1,91 +0,0 @@ -/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2013 Robert Osfield - * - * This library is open source and may be redistributed and/or modified under - * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or - * (at your option) any later version. The full license is in LICENSE file - * included with this distribution, and on the openscenegraph.org website. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * OpenSceneGraph Public License for more details. -*/ - -#include -#include - -#include "MethodObject.h" - -using namespace osgDB; - -struct GroupGetNumChildren : public osgDB::MethodObject -{ - virtual bool run(void* objectPtr, osg::Parameters& inputParameters, osg::Parameters& outputParameters) const - { - osg::Group* group = reinterpret_cast(objectPtr); - outputParameters.push_back(new osg::UIntValueObject("return", group->getNumChildren())); - return true; - } -}; - -struct GroupGetChild : public osgDB::MethodObject -{ - virtual bool run(void* objectPtr, osg::Parameters& inputParameters, osg::Parameters& outputParameters) const - { - if (inputParameters.empty()) return false; - - osg::Object* indexObject = inputParameters[0].get(); - OSG_NOTICE<<"GroupGetChild "<className()<(indexObject); - if (dvo) index = static_cast(dvo->getValue()); - else - { - osg::UIntValueObject* uivo = dynamic_cast(indexObject); - if (uivo) index = uivo->getValue(); - } - osg::Group* group = reinterpret_cast(objectPtr); - outputParameters.push_back(group->getChild(index)); - - return true; - } -}; - -struct GroupAddChild : public osgDB::MethodObject -{ - virtual bool run(void* objectPtr, osg::Parameters& inputParameters, osg::Parameters& outputParameters) const - { - if (inputParameters.empty()) return false; - - osg::Node* child = dynamic_cast(inputParameters[0].get()); - if (!child) return false; - - osg::Group* group = reinterpret_cast(objectPtr); - group->addChild(child); - - return true; - } -}; - - -struct GroupRemoveChild : public osgDB::MethodObject -{ - virtual bool run(void* objectPtr, osg::Parameters& inputParameters, osg::Parameters& outputParameters) const - { - if (inputParameters.empty()) return false; - - osg::Node* child = dynamic_cast(inputParameters[0].get()); - if (!child) return false; - - osg::Group* group = reinterpret_cast(objectPtr); - group->removeChild(child); - - return true; - } -}; - -static osgDB::RegisterMethodObjectProxy s_getNumChildren("osg::Group","getNumChildren",new GroupGetNumChildren()); -static osgDB::RegisterMethodObjectProxy s_getNumChild("osg::Group","getChild",new GroupGetChild()); -static osgDB::RegisterMethodObjectProxy s_getAddChild("osg::Group","addChild",new GroupAddChild()); -static osgDB::RegisterMethodObjectProxy s_getRemoveChild("osg::Group","removeChild",new GroupRemoveChild()); diff --git a/src/osgPlugins/lua/MethodObject.cpp b/src/osgPlugins/lua/MethodObject.cpp deleted file mode 100644 index 218c28d05..000000000 --- a/src/osgPlugins/lua/MethodObject.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2013 Robert Osfield - * - * This library is open source and may be redistributed and/or modified under - * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or - * (at your option) any later version. The full license is in LICENSE file - * included with this distribution, and on the openscenegraph.org website. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * OpenSceneGraph Public License for more details. -*/ - -#include "MethodObject.h" -#include - -using namespace osgDB; - - -void MethodsObject::add(const std::string& methodName, MethodObject* mo) -{ - methodMap.insert(MethodMap::value_type(methodName, mo)); -} - -bool MethodsObject::run(void* objectPtr, const std::string& methodName, osg::Parameters& inputParameters, osg::Parameters& outputParameters) const -{ - MethodMap::const_iterator itr = methodMap.find(methodName); - while (itr != methodMap.end()) - { - if (itr->first==methodName) - { - OSG_NOTICE<<"Calling methodObject for "<second->run(objectPtr, inputParameters, outputParameters)) return true; - } - ++itr; - } - OSG_NOTICE<<"No matching methodObject found for "<& MethodsObjectManager::instance() -{ - static osg::ref_ptr s_MethodsObjectManager = new MethodsObjectManager; - return s_MethodsObjectManager; -} - -void MethodsObjectManager::add(const std::string& compoundClassName, const std::string& methodName, MethodObject* mo) -{ - MethodsObjectMap::iterator itr = methodsObjects.find( compoundClassName ); - if (itr==methodsObjects.end()) - { - methodsObjects[compoundClassName] = new MethodsObject; - itr = methodsObjects.find( compoundClassName ); - } - itr->second->add(methodName, mo); -} - -bool MethodsObjectManager::run(void* objectPtr, const std::string& compoundClassName, const std::string& methodName, osg::Parameters& inputParameters, osg::Parameters& outputParameters) const -{ - MethodsObjectMap::const_iterator itr = methodsObjects.find( compoundClassName ); - if (itr!=methodsObjects.end()) - { - return itr->second->run(objectPtr, methodName, inputParameters, outputParameters); - } - OSG_NOTICE<<"No matching methodObject found for class "<second->hasMethod(methodName); - } - return false; - -} diff --git a/src/osgPlugins/lua/MethodObject.h b/src/osgPlugins/lua/MethodObject.h deleted file mode 100644 index c3265bab6..000000000 --- a/src/osgPlugins/lua/MethodObject.h +++ /dev/null @@ -1,75 +0,0 @@ -/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2013 Robert Osfield - * - * This library is open source and may be redistributed and/or modified under - * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or - * (at your option) any later version. The full license is in LICENSE file - * included with this distribution, and on the openscenegraph.org website. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * OpenSceneGraph Public License for more details. -*/ - -#ifndef METHODSOBJECT_H -#define METHODSOBJECT_H - -#include -#include - -namespace osgDB -{ - -#if 0 -struct MethodObject : public osg::Referenced -{ - typedef std::vector< osg::ref_ptr > Parameters; - - virtual bool run(void* objectPtr, osg::Parameters& inputParameters, osg::Parameters& outputParameters) const = 0; - virtual ~MethodObject() {} -}; -#endif - -struct MethodsObject : public osg::Referenced -{ - MethodsObject() {} - virtual ~MethodsObject() {} - - void add(const std::string& methodName, MethodObject* mo); - - bool run(void* objectPtr, const std::string& methodName, osg::Parameters& inputParameters, osg::Parameters& outputParameters) const; - - bool hasMethod(const std::string& methodName) const; - - typedef std::multimap< std::string, osg::ref_ptr > MethodMap; - MethodMap methodMap; -}; - -struct MethodsObjectManager : public osg::Referenced -{ - MethodsObjectManager() {} - virtual ~MethodsObjectManager() {} - - static osg::ref_ptr& instance(); - - void add(const std::string& compoundClassName, const std::string& methodName, MethodObject* mo); - - bool run(void* objectPtr, const std::string& compoundClassName, const std::string& methodName, osg::Parameters& inputParameters, osg::Parameters& outputParameters) const; - - bool hasMethod(const std::string& compoundClassName, const std::string& methodName) const; - - typedef std::map< std::string, osg::ref_ptr > MethodsObjectMap; - MethodsObjectMap methodsObjects; -}; - -struct RegisterMethodObjectProxy -{ - RegisterMethodObjectProxy(const std::string& compoundClassName, const std::string& methodName, MethodObject* mo) - { - MethodsObjectManager::instance()->add(compoundClassName, methodName, mo); - } -}; - -} - -#endif