5#include <cgv/reflect/get_reflection_handler.h>
6#include <cgv/reflect/set_reflection_handler.h>
7#include <cgv/type/variant.h>
8#include <cgv/utils/tokenizer.h>
72 std::string property_declarations;
77 if (group_kind == GK_BASE_CLASS)
80 if (!property_declarations.empty())
81 property_declarations +=
';';
84 case GK_STRUCTURE : property_declarations += group_name+
':'+
group_type;
break;
85 case GK_ARRAY : property_declarations += group_name+
':'+
group_type+
'['+
to_string(grp_size)+
']';
break;
86 case GK_VECTOR : property_declarations += group_name+
":vector<"+
group_type+
">";
break;
87 case GK_POINTER: property_declarations += group_name+
":pointer("+
group_type+
")";
break;
95 if (!property_declarations.empty())
96 property_declarations +=
';';
104 if (!property_declarations.empty())
105 property_declarations +=
';';
109 property_declarations +=
',';
112 property_declarations +=
')';
114 property_declarations +=
':';
125 const std::string& method;
126 const std::vector<std::string>& param_value_types;
127 const std::vector<const void*>& param_value_ptrs;
128 const std::string& result_type;
129 void* result_value_ptr;
169 const std::vector<std::string>& param_value_types,
170 const std::vector<const void*>& param_value_ptrs,
171 const std::string& result_type,
172 void* result_value_ptr)
185 if (
ssrh.found_valid_target()) {
219 if (
gsrh.found_valid_target())
252 return std::string();
259 return n->get_name();
268 std::string declarations =
pdsrh.property_declarations;
290 std::vector<token>
toks;
293 for (
unsigned int i=0;
i<
toks.size(); ++
i) {
294 std::vector<token>
sides;
296 if (
sides.size() != 2) {
298 std::cerr <<
"property assignment >" <<
to_string(
toks[
i]).c_str() <<
"< does not match pattern lhs=rhs" << std::endl;
303 if (
rhs[0] ==
'"' ||
rhs[0] ==
'\'') {
304 unsigned int n = (
unsigned int) (
rhs.size()-1);
309 for (
unsigned i=1;
i<
rhs.size(); ++
i) {
310 if (
rhs[
i-1] ==
'\\' && (
rhs[
i] ==
'\\' ||
rhs[
i] == open))
315 else if (
rhs ==
"true" ||
rhs ==
"false") {
316 bool value =
rhs ==
"true";
324 double value =
atof(
rhs.c_str());
339 std::vector<token>
toks;
342 for (
unsigned int i=0;
i<
toks.size(); ++
i) {
343 std::vector<token>
ts;
364 if (!
fsrh.found_target())
368 return fsrh.get_member_ptr();
virtual ~base()
make destructor virtual and not accessible from outside
virtual void unregister()
overload to handle unregistration of instances
virtual void on_register()
overload to handle register events that is sent after the instance has been registered
virtual bool on_exit_request()
overload to handle the appication exit request, return true if exiting is allowed and false otherwise
virtual void update()
this virtual update allows for example to ask a view to update the viewed value. The default implemen...
virtual std::string get_property_declarations()
return a semicolon separated list of property declarations
virtual data::ref_ptr< const node, true > get_node_const() const
perform downcast to const node
virtual bool set_void(const std::string &property, const std::string &value_type, const void *value_ptr)
abstract interface for the setter of a dynamic property.
virtual bool call_void(const std::string &method, const std::vector< std::string > ¶m_value_types, const std::vector< const void * > ¶m_value_ptrs, const std::string &result_type="", void *result_value_ptr=0)
abstract interface to call an action
virtual data::ref_ptr< named, true > get_named()
perform downcast to named
virtual void on_set(void *member_ptr)
this callback is called when the set_void method has changed a member and can be overloaded in derive...
virtual std::string get_type_name() const
overload to return the type name of this object. By default the type interface is queried over get_ty...
virtual std::string get_default_options() const
overload to provide default options for registration
virtual data::ref_ptr< const group, true > get_group_const() const
perform downcast to const group
virtual void stream_stats(std::ostream &)
overload to show the content of this object
virtual bool self_reflect(cgv::reflect::reflection_handler &)
used for simple self reflection
virtual data::ref_ptr< node, true > get_node()
perform downcast to node
virtual data::ref_ptr< const named, true > get_named_const() const
perform downcast to const named
virtual data::ref_ptr< group, true > get_group()
perform downcast to group
void * find_member_ptr(const std::string &property_name, std::string *type_name=0)
find a member pointer by name.
bool is_property(const std::string &property_name, std::string *type_name=0)
check if the given name specifies a property.
virtual bool get_void(const std::string &property, const std::string &value_type, void *value_ptr)
abstract interface for the getter of a dynamic property.
std::string get_name_or_type_name() const
determine name of instance by checking cgv::base::named interface and in failure fallback to get_type...
virtual void * get_user_data() const
this virtual method allows to pass application specific data for internal purposes
void multi_set(const std::string &property_assignments, bool report_error=true)
set several properties
bool reflect_method_void(const std::string &method_name, method_interface *mi_ptr, abst_reflection_traits *return_traits, const std::vector< abst_reflection_traits * > ¶m_value_traits)
abstract interface to reflect a method, where return and parameter types are specified as strings.
bool reflect_member_void(const std::string &member_name, void *member_ptr, abst_reflection_traits *rt)
empty implementation
bool reflect_member_void(const std::string &member_name, void *, abst_reflection_traits *rt)
abstract interface to reflect a member variable, where the member type is specified as a string.
bool reflect_method_void(const std::string &method_name, method_interface *mi_ptr, abst_reflection_traits *return_traits, const std::vector< abst_reflection_traits * > ¶m_value_traits)
abstract interface to reflect a method, where return and parameter types are specified as strings.
int reflect_group_begin(GroupKind group_kind, const std::string &group_name, void *group_ptr, abst_reflection_traits *group_rt, unsigned grp_size)
abstract interface to start reflection of a group of members.
complete implementation of method actions that only call one method when entering a node
reference counted pointer, which can work together with types that are derived from ref_counted,...
The cgv::reflect::find_reflection_hander steers traversal to a specific member and calls the virtual ...
provides access to a member variable of an instance.
the self reflection handler is passed to the virtual self_reflect() method of cgv::base::base.
GroupKind
different support group types
the tokenizer allows to split text into tokens in a convenient way.
in this namespace reflection of types is implemented
namespace for templates that provide type information
namespace for compile time type information
namespace that holds tools that dont fit any other namespace
bool is_digit(char c)
check if char is a digit
std::string to_string(const std::string &v, unsigned int w, unsigned int p, bool)
specialization of conversion from string to strings
bool is_integer(const char *begin, const char *end, int &value)
check if the text range (begin,end( defines an integer value. If yes, store the value in the passed r...
void bite_all(tokenizer &t, std::vector< token > &result)
bite all tokens into a token vector
Helper functions to process strings.
abstract interface for type reflection with basic type management and optional string conversion
virtual const char * get_type_name() const =0
return the type name
abstract interface to call a method of a given instance.
traits class with a static function get_name() of type const char* that returns the type name of the ...
static const char * get_name()
return special name for standard types or type name from RTTI cleaned from keywords for all other typ...