OpenSceneGraph/include/osgIntrospection/ConstructorInfo

87 lines
2.8 KiB
Plaintext
Raw Normal View History

2006-07-18 23:21:48 +08:00
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
2005-04-29 18:06:50 +08:00
*
* 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) 2005 Marco Jez
#ifndef OSGINTROSPECTION_CONSTRUCTORINFO_
#define OSGINTROSPECTION_CONSTRUCTORINFO_
#include <osgIntrospection/Export>
#include <osgIntrospection/Type>
#include <osgIntrospection/ParameterInfo>
#include <osgIntrospection/CustomAttributeProvider>
namespace osgIntrospection
{
class OSGINTROSPECTION_EXPORT ConstructorInfo: public CustomAttributeProvider
{
public:
From David Callu: " the main problem is the wrapper generation: The PropertyInfo class use MethodInfo class to access to the value. When the property are define with the I_Property* macro, the MethodInfo use by the property to have access to the value are instancied in the I_Property* macro, but there are already instantied by the I_Method* macro before secondary problem: - the function used by the property could no be customized in the genwrapper.conf file - an array property can't insert a value - the std::map reflector (and indexedProperty in general) haven't remove method - about the help in wrapper ... why not ... solution : To use the function define by the I_Method, I add a MethodInfo variable in the I_Method0 macro old macro : #define I_Method0(ret, fn) (\ params.clear(),\ addMethod(new osgIntrospection::TypedMethodIn fo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params))) new macro : #define I_Method0(ret, fn, signature, briefHelp, detailedHelp) \ params.clear(); \ osgIntrospection::MethodInfo* signature = addMethod(new osgIntrospection::TypedMethodInfo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params, briefHelp, detailedHelp)); sink(signature) the osgIntrospection::MethodInfo* signature is used by the I_Property macro to define the MethodInfo that it use so for I_Property macro : old macro : #define I_PropertyWithReturnType(t, n, r) \ cap=addProperty(new osgIntrospection::PropertyInfo(osgIntrospection::Reflection::getType(typeid(reflected_type)), osgIntrospection::Reflection::getType(typeid(t)), #n, \ I_Method0(t, get##n), \ I_Method1(r, set##n, IN, t, value))) new macro: #define I_SimpleProperty(t, n, get, set) \ get, \ set)) The genwrapper has been modified in this way. The method signature is define by the prototype of the method For example, the "const char* libraryName();" have "__C5_char_P1__libraryName" for signature solution for secondary problem: The genwrapper accept new tokens in the configuration to custumize the property. The new PropertyInserter and the CustomPropertyInsertAttribute class has been defined The PropertyRemover has been added to the StdMapReflector The _briefHelp and _detailedHelp variable has been added in PropertyInfo, MethodInfo and ContructorInfo class modification: I have modify the genwrapper files Configuration.cpp Configuration.h add some tokens to custumize the property Doxyfile.template add the comment in the output xml genwrapper.conf customize some property in osg::Geometry RegistryBuilder.h RegistryBuilder.cpp add the process_help function (to extract help from xml) TypeRegister.cpp TypeRegister.h optimize the property detection TypeDesc.h TypeDesc.cpp modify FunctionDesc and PropertyDesc WrapperGenerator.h WrapperGenerator.cpp modify the output I also modify the fallowing osgIntrospection files: include/osgIntrospection/Attributes add the PropertyInserter and the CustomPropertyInsertAttribute class include/osgIntrospection/ConstructorInfo add the _briefHelp and _detailedHelp variable in the ConstructorInfo class add access function for the two new variables (_briefHelp and _detailedHelp) modify the constructor to define the two new variables (_briefHelp and _detailedHelp) include/osgIntrospection/MethodInfo add the _briefHelp and _detailedHelp variable in the MethodInfo class add access function for the two new variables (_briefHelp and _detailedHelp) modify the constructor to define the two new variables (_briefHelp and _detailedHelp) include/osgIntrospection/PropertyInfo add the _briefHelp and _detailedHelp variable in the PropertyInfo class add access function for the two new variables (_briefHelp and _detailedHelp) modify the constructor to define the two new variables (_briefHelp and _detailedHelp) include/osgIntrospection/ReflectionMacro remove unused I_Property* macro modify all I_Method macro to accept the help string modify all I_Method macro to define a MethodInfo signature include/osgIntrospection/Reflector add the PropertyInserter in StdVectorReflector and StdListReflector add the PropertyRemover in the StdMapReflector include/osgIntrospection/StaticMethodInfo modify all StaticMethodInfo* to accept the help in parameter include/osgIntrospection/TypedMethodInfo modify all TypedMethodInfo* to accept the help in parameter include/osgIntrospection/TypedConstructorInfo modify all TypedConstructorInfo* to accept the help in parameter include/osgIntrospection/Type add the _briefHelp and _detailedHelp variable in the Type class "
2006-10-17 23:17:06 +08:00
ConstructorInfo(const Type& decltype, const ParameterInfoList& params, std::string briefHelp = std::string(), std::string detailedHelp = std::string())
: _decltype(decltype),
_params(params),
_briefHelp(briefHelp),
_detailedHelp(detailedHelp)
{
}
virtual ~ConstructorInfo()
{
for (ParameterInfoList::iterator i=_params.begin(); i!=_params.end(); ++i)
delete *i;
}
From David Callu: " the main problem is the wrapper generation: The PropertyInfo class use MethodInfo class to access to the value. When the property are define with the I_Property* macro, the MethodInfo use by the property to have access to the value are instancied in the I_Property* macro, but there are already instantied by the I_Method* macro before secondary problem: - the function used by the property could no be customized in the genwrapper.conf file - an array property can't insert a value - the std::map reflector (and indexedProperty in general) haven't remove method - about the help in wrapper ... why not ... solution : To use the function define by the I_Method, I add a MethodInfo variable in the I_Method0 macro old macro : #define I_Method0(ret, fn) (\ params.clear(),\ addMethod(new osgIntrospection::TypedMethodIn fo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params))) new macro : #define I_Method0(ret, fn, signature, briefHelp, detailedHelp) \ params.clear(); \ osgIntrospection::MethodInfo* signature = addMethod(new osgIntrospection::TypedMethodInfo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params, briefHelp, detailedHelp)); sink(signature) the osgIntrospection::MethodInfo* signature is used by the I_Property macro to define the MethodInfo that it use so for I_Property macro : old macro : #define I_PropertyWithReturnType(t, n, r) \ cap=addProperty(new osgIntrospection::PropertyInfo(osgIntrospection::Reflection::getType(typeid(reflected_type)), osgIntrospection::Reflection::getType(typeid(t)), #n, \ I_Method0(t, get##n), \ I_Method1(r, set##n, IN, t, value))) new macro: #define I_SimpleProperty(t, n, get, set) \ get, \ set)) The genwrapper has been modified in this way. The method signature is define by the prototype of the method For example, the "const char* libraryName();" have "__C5_char_P1__libraryName" for signature solution for secondary problem: The genwrapper accept new tokens in the configuration to custumize the property. The new PropertyInserter and the CustomPropertyInsertAttribute class has been defined The PropertyRemover has been added to the StdMapReflector The _briefHelp and _detailedHelp variable has been added in PropertyInfo, MethodInfo and ContructorInfo class modification: I have modify the genwrapper files Configuration.cpp Configuration.h add some tokens to custumize the property Doxyfile.template add the comment in the output xml genwrapper.conf customize some property in osg::Geometry RegistryBuilder.h RegistryBuilder.cpp add the process_help function (to extract help from xml) TypeRegister.cpp TypeRegister.h optimize the property detection TypeDesc.h TypeDesc.cpp modify FunctionDesc and PropertyDesc WrapperGenerator.h WrapperGenerator.cpp modify the output I also modify the fallowing osgIntrospection files: include/osgIntrospection/Attributes add the PropertyInserter and the CustomPropertyInsertAttribute class include/osgIntrospection/ConstructorInfo add the _briefHelp and _detailedHelp variable in the ConstructorInfo class add access function for the two new variables (_briefHelp and _detailedHelp) modify the constructor to define the two new variables (_briefHelp and _detailedHelp) include/osgIntrospection/MethodInfo add the _briefHelp and _detailedHelp variable in the MethodInfo class add access function for the two new variables (_briefHelp and _detailedHelp) modify the constructor to define the two new variables (_briefHelp and _detailedHelp) include/osgIntrospection/PropertyInfo add the _briefHelp and _detailedHelp variable in the PropertyInfo class add access function for the two new variables (_briefHelp and _detailedHelp) modify the constructor to define the two new variables (_briefHelp and _detailedHelp) include/osgIntrospection/ReflectionMacro remove unused I_Property* macro modify all I_Method macro to accept the help string modify all I_Method macro to define a MethodInfo signature include/osgIntrospection/Reflector add the PropertyInserter in StdVectorReflector and StdListReflector add the PropertyRemover in the StdMapReflector include/osgIntrospection/StaticMethodInfo modify all StaticMethodInfo* to accept the help in parameter include/osgIntrospection/TypedMethodInfo modify all TypedMethodInfo* to accept the help in parameter include/osgIntrospection/TypedConstructorInfo modify all TypedConstructorInfo* to accept the help in parameter include/osgIntrospection/Type add the _briefHelp and _detailedHelp variable in the Type class "
2006-10-17 23:17:06 +08:00
/// Returns the brief help of the reflected construtor.
inline virtual const std::string& getBriefHelp() const
{
return _briefHelp;
}
/// Returns the detailed help of the reflected contructor.
inline virtual const std::string& getDetailedHelp() const
{
return _detailedHelp;
}
/// Returns the Type object associated to the type that
/// declares the reflected constructor.
inline const Type& getDeclaringType() const
{
return _decltype;
}
From David Callu: " the main problem is the wrapper generation: The PropertyInfo class use MethodInfo class to access to the value. When the property are define with the I_Property* macro, the MethodInfo use by the property to have access to the value are instancied in the I_Property* macro, but there are already instantied by the I_Method* macro before secondary problem: - the function used by the property could no be customized in the genwrapper.conf file - an array property can't insert a value - the std::map reflector (and indexedProperty in general) haven't remove method - about the help in wrapper ... why not ... solution : To use the function define by the I_Method, I add a MethodInfo variable in the I_Method0 macro old macro : #define I_Method0(ret, fn) (\ params.clear(),\ addMethod(new osgIntrospection::TypedMethodIn fo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params))) new macro : #define I_Method0(ret, fn, signature, briefHelp, detailedHelp) \ params.clear(); \ osgIntrospection::MethodInfo* signature = addMethod(new osgIntrospection::TypedMethodInfo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params, briefHelp, detailedHelp)); sink(signature) the osgIntrospection::MethodInfo* signature is used by the I_Property macro to define the MethodInfo that it use so for I_Property macro : old macro : #define I_PropertyWithReturnType(t, n, r) \ cap=addProperty(new osgIntrospection::PropertyInfo(osgIntrospection::Reflection::getType(typeid(reflected_type)), osgIntrospection::Reflection::getType(typeid(t)), #n, \ I_Method0(t, get##n), \ I_Method1(r, set##n, IN, t, value))) new macro: #define I_SimpleProperty(t, n, get, set) \ get, \ set)) The genwrapper has been modified in this way. The method signature is define by the prototype of the method For example, the "const char* libraryName();" have "__C5_char_P1__libraryName" for signature solution for secondary problem: The genwrapper accept new tokens in the configuration to custumize the property. The new PropertyInserter and the CustomPropertyInsertAttribute class has been defined The PropertyRemover has been added to the StdMapReflector The _briefHelp and _detailedHelp variable has been added in PropertyInfo, MethodInfo and ContructorInfo class modification: I have modify the genwrapper files Configuration.cpp Configuration.h add some tokens to custumize the property Doxyfile.template add the comment in the output xml genwrapper.conf customize some property in osg::Geometry RegistryBuilder.h RegistryBuilder.cpp add the process_help function (to extract help from xml) TypeRegister.cpp TypeRegister.h optimize the property detection TypeDesc.h TypeDesc.cpp modify FunctionDesc and PropertyDesc WrapperGenerator.h WrapperGenerator.cpp modify the output I also modify the fallowing osgIntrospection files: include/osgIntrospection/Attributes add the PropertyInserter and the CustomPropertyInsertAttribute class include/osgIntrospection/ConstructorInfo add the _briefHelp and _detailedHelp variable in the ConstructorInfo class add access function for the two new variables (_briefHelp and _detailedHelp) modify the constructor to define the two new variables (_briefHelp and _detailedHelp) include/osgIntrospection/MethodInfo add the _briefHelp and _detailedHelp variable in the MethodInfo class add access function for the two new variables (_briefHelp and _detailedHelp) modify the constructor to define the two new variables (_briefHelp and _detailedHelp) include/osgIntrospection/PropertyInfo add the _briefHelp and _detailedHelp variable in the PropertyInfo class add access function for the two new variables (_briefHelp and _detailedHelp) modify the constructor to define the two new variables (_briefHelp and _detailedHelp) include/osgIntrospection/ReflectionMacro remove unused I_Property* macro modify all I_Method macro to accept the help string modify all I_Method macro to define a MethodInfo signature include/osgIntrospection/Reflector add the PropertyInserter in StdVectorReflector and StdListReflector add the PropertyRemover in the StdMapReflector include/osgIntrospection/StaticMethodInfo modify all StaticMethodInfo* to accept the help in parameter include/osgIntrospection/TypedMethodInfo modify all TypedMethodInfo* to accept the help in parameter include/osgIntrospection/TypedConstructorInfo modify all TypedConstructorInfo* to accept the help in parameter include/osgIntrospection/Type add the _briefHelp and _detailedHelp variable in the Type class "
2006-10-17 23:17:06 +08:00
/// Returns a list of objects that describe the reflected
/// constructor's parameters.
inline const ParameterInfoList& getParameters() const
{
return _params;
}
From David Callu: " the main problem is the wrapper generation: The PropertyInfo class use MethodInfo class to access to the value. When the property are define with the I_Property* macro, the MethodInfo use by the property to have access to the value are instancied in the I_Property* macro, but there are already instantied by the I_Method* macro before secondary problem: - the function used by the property could no be customized in the genwrapper.conf file - an array property can't insert a value - the std::map reflector (and indexedProperty in general) haven't remove method - about the help in wrapper ... why not ... solution : To use the function define by the I_Method, I add a MethodInfo variable in the I_Method0 macro old macro : #define I_Method0(ret, fn) (\ params.clear(),\ addMethod(new osgIntrospection::TypedMethodIn fo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params))) new macro : #define I_Method0(ret, fn, signature, briefHelp, detailedHelp) \ params.clear(); \ osgIntrospection::MethodInfo* signature = addMethod(new osgIntrospection::TypedMethodInfo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params, briefHelp, detailedHelp)); sink(signature) the osgIntrospection::MethodInfo* signature is used by the I_Property macro to define the MethodInfo that it use so for I_Property macro : old macro : #define I_PropertyWithReturnType(t, n, r) \ cap=addProperty(new osgIntrospection::PropertyInfo(osgIntrospection::Reflection::getType(typeid(reflected_type)), osgIntrospection::Reflection::getType(typeid(t)), #n, \ I_Method0(t, get##n), \ I_Method1(r, set##n, IN, t, value))) new macro: #define I_SimpleProperty(t, n, get, set) \ get, \ set)) The genwrapper has been modified in this way. The method signature is define by the prototype of the method For example, the "const char* libraryName();" have "__C5_char_P1__libraryName" for signature solution for secondary problem: The genwrapper accept new tokens in the configuration to custumize the property. The new PropertyInserter and the CustomPropertyInsertAttribute class has been defined The PropertyRemover has been added to the StdMapReflector The _briefHelp and _detailedHelp variable has been added in PropertyInfo, MethodInfo and ContructorInfo class modification: I have modify the genwrapper files Configuration.cpp Configuration.h add some tokens to custumize the property Doxyfile.template add the comment in the output xml genwrapper.conf customize some property in osg::Geometry RegistryBuilder.h RegistryBuilder.cpp add the process_help function (to extract help from xml) TypeRegister.cpp TypeRegister.h optimize the property detection TypeDesc.h TypeDesc.cpp modify FunctionDesc and PropertyDesc WrapperGenerator.h WrapperGenerator.cpp modify the output I also modify the fallowing osgIntrospection files: include/osgIntrospection/Attributes add the PropertyInserter and the CustomPropertyInsertAttribute class include/osgIntrospection/ConstructorInfo add the _briefHelp and _detailedHelp variable in the ConstructorInfo class add access function for the two new variables (_briefHelp and _detailedHelp) modify the constructor to define the two new variables (_briefHelp and _detailedHelp) include/osgIntrospection/MethodInfo add the _briefHelp and _detailedHelp variable in the MethodInfo class add access function for the two new variables (_briefHelp and _detailedHelp) modify the constructor to define the two new variables (_briefHelp and _detailedHelp) include/osgIntrospection/PropertyInfo add the _briefHelp and _detailedHelp variable in the PropertyInfo class add access function for the two new variables (_briefHelp and _detailedHelp) modify the constructor to define the two new variables (_briefHelp and _detailedHelp) include/osgIntrospection/ReflectionMacro remove unused I_Property* macro modify all I_Method macro to accept the help string modify all I_Method macro to define a MethodInfo signature include/osgIntrospection/Reflector add the PropertyInserter in StdVectorReflector and StdListReflector add the PropertyRemover in the StdMapReflector include/osgIntrospection/StaticMethodInfo modify all StaticMethodInfo* to accept the help in parameter include/osgIntrospection/TypedMethodInfo modify all TypedMethodInfo* to accept the help in parameter include/osgIntrospection/TypedConstructorInfo modify all TypedConstructorInfo* to accept the help in parameter include/osgIntrospection/Type add the _briefHelp and _detailedHelp variable in the Type class "
2006-10-17 23:17:06 +08:00
/// Invokes the reflected constructor dynamically passing it the
/// arguments as a list of Value objects.
virtual Value createInstance(ValueList& args) const = 0;
protected:
virtual void getInheritedProviders(CustomAttributeProviderList& providers) const;
private:
const Type& _decltype;
ParameterInfoList _params;
From David Callu: " the main problem is the wrapper generation: The PropertyInfo class use MethodInfo class to access to the value. When the property are define with the I_Property* macro, the MethodInfo use by the property to have access to the value are instancied in the I_Property* macro, but there are already instantied by the I_Method* macro before secondary problem: - the function used by the property could no be customized in the genwrapper.conf file - an array property can't insert a value - the std::map reflector (and indexedProperty in general) haven't remove method - about the help in wrapper ... why not ... solution : To use the function define by the I_Method, I add a MethodInfo variable in the I_Method0 macro old macro : #define I_Method0(ret, fn) (\ params.clear(),\ addMethod(new osgIntrospection::TypedMethodIn fo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params))) new macro : #define I_Method0(ret, fn, signature, briefHelp, detailedHelp) \ params.clear(); \ osgIntrospection::MethodInfo* signature = addMethod(new osgIntrospection::TypedMethodInfo0<reflected_type, ret >(qualifyName(#fn), &reflected_type::fn, params, briefHelp, detailedHelp)); sink(signature) the osgIntrospection::MethodInfo* signature is used by the I_Property macro to define the MethodInfo that it use so for I_Property macro : old macro : #define I_PropertyWithReturnType(t, n, r) \ cap=addProperty(new osgIntrospection::PropertyInfo(osgIntrospection::Reflection::getType(typeid(reflected_type)), osgIntrospection::Reflection::getType(typeid(t)), #n, \ I_Method0(t, get##n), \ I_Method1(r, set##n, IN, t, value))) new macro: #define I_SimpleProperty(t, n, get, set) \ get, \ set)) The genwrapper has been modified in this way. The method signature is define by the prototype of the method For example, the "const char* libraryName();" have "__C5_char_P1__libraryName" for signature solution for secondary problem: The genwrapper accept new tokens in the configuration to custumize the property. The new PropertyInserter and the CustomPropertyInsertAttribute class has been defined The PropertyRemover has been added to the StdMapReflector The _briefHelp and _detailedHelp variable has been added in PropertyInfo, MethodInfo and ContructorInfo class modification: I have modify the genwrapper files Configuration.cpp Configuration.h add some tokens to custumize the property Doxyfile.template add the comment in the output xml genwrapper.conf customize some property in osg::Geometry RegistryBuilder.h RegistryBuilder.cpp add the process_help function (to extract help from xml) TypeRegister.cpp TypeRegister.h optimize the property detection TypeDesc.h TypeDesc.cpp modify FunctionDesc and PropertyDesc WrapperGenerator.h WrapperGenerator.cpp modify the output I also modify the fallowing osgIntrospection files: include/osgIntrospection/Attributes add the PropertyInserter and the CustomPropertyInsertAttribute class include/osgIntrospection/ConstructorInfo add the _briefHelp and _detailedHelp variable in the ConstructorInfo class add access function for the two new variables (_briefHelp and _detailedHelp) modify the constructor to define the two new variables (_briefHelp and _detailedHelp) include/osgIntrospection/MethodInfo add the _briefHelp and _detailedHelp variable in the MethodInfo class add access function for the two new variables (_briefHelp and _detailedHelp) modify the constructor to define the two new variables (_briefHelp and _detailedHelp) include/osgIntrospection/PropertyInfo add the _briefHelp and _detailedHelp variable in the PropertyInfo class add access function for the two new variables (_briefHelp and _detailedHelp) modify the constructor to define the two new variables (_briefHelp and _detailedHelp) include/osgIntrospection/ReflectionMacro remove unused I_Property* macro modify all I_Method macro to accept the help string modify all I_Method macro to define a MethodInfo signature include/osgIntrospection/Reflector add the PropertyInserter in StdVectorReflector and StdListReflector add the PropertyRemover in the StdMapReflector include/osgIntrospection/StaticMethodInfo modify all StaticMethodInfo* to accept the help in parameter include/osgIntrospection/TypedMethodInfo modify all TypedMethodInfo* to accept the help in parameter include/osgIntrospection/TypedConstructorInfo modify all TypedConstructorInfo* to accept the help in parameter include/osgIntrospection/Type add the _briefHelp and _detailedHelp variable in the Type class "
2006-10-17 23:17:06 +08:00
std::string _briefHelp;
std::string _detailedHelp;
};
}
#endif