OpenSceneGraph/include/osgIntrospection/PublicMemberAccessor
Robert Osfield 616097e465 From David Callu,
"bug fix to reflect the wchar_t in Value and Value.cpp I add the toWString() function.
in Type and Type.cpp I just add two function to get a map of propertyList and a map of methodList
i need this map in my editor a i think it's could be util to put this functionnality in osgIntrospection,
2006-09-01 12:52:15 +00:00

60 lines
1.6 KiB
C++

/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2005 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.
*/
//osgIntrospection - Copyright (C) 2006 David Callu
#ifndef OSGINTROSPECTION_PUBLICMEMBERACCESSOR_
#define OSGINTROSPECTION_PUBLICMEMBERACCESSOR_
#include <osgIntrospection/Export>
#include <osgIntrospection/Type>
#include <osgIntrospection/MethodInfo>
#include <osgIntrospection/PropertyInfo>
#include <osgIntrospection/Attributes>
#include <string>
#include <typeinfo>
#include <iosfwd>
#include <vector>
namespace osgIntrospection
{
template < typename C, typename P >
struct PublicMemberAccessor: public PropertyGetter, public PropertySetter
{
typedef P C::*MemberType;
PublicMemberAccessor(MemberType m)
: _m(m)
{}
virtual Value get(Value& instance) const
{
return getInstance<C>(instance).*_m;
}
virtual Value get(const Value& instance) const
{
return getInstance<C>(instance).*_m;
}
virtual void set(Value& instance, const Value& v) const
{
getInstance<C>(instance).*_m = variant_cast<const P& >(v);
}
P C::*_m;
};
}
#endif