5#include <cgv/utils/file.h>
6#include <cgv/utils/tokenizer.h>
7#include <cgv/base/register.h>
8#include <cgv/reflect/find_reflection_handler.h>
9#include <cgv/reflect/reflect_enum.h>
27 std::string file_name;
29 std::vector<config_file_view> views;
30 unsigned nr_out_of_date;
39 std::sort(views.begin(), views.end());
41 void inc_out_of_date_count() {
47 for (
unsigned i=0;
i<views.size(); ++
i)
48 if (views[
i].view == v) {
49 if (!views[
i].out_of_date) {
50 views[
i].out_of_date =
true;
51 inc_out_of_date_count();
55 void update_config_file()
60 for (
unsigned i=0;
i<views.size(); ++
i) {
61 std::string new_value((
const char*)views[
i].view->get_user_data());
62 std::size_t
new_len = new_value.length();
65 off = views[
i].pos+views[
i].len;
69 views[
i].out_of_date =
false;
92 return const_cast<char*
>(last_value.c_str());
157 std::vector<token>
toks;
160 for (
size_t i=0;
i<
toks.size(); ++
i) {
161 std::vector<token>
sides;
163 if (
sides.size() != 2) {
164 std::cerr <<
"property assignment >" <<
to_string(
toks[
i]).c_str() <<
"< does not match pattern lhs=rhs" << std::endl;
171 void* member_ptr = 0;
172 if (
rsrh.found_target()) {
173 member_ptr =
rsrh.get_member_ptr();
176 cfv.out_of_date =
false;
177 switch (
rsrh.get_reflection_traits()->get_type_id()) {
197 std::cerr <<
"could not create config view for permanent attribute " <<
lhs << std::endl;
203 cfv.view->attach_to_reference(member_ptr);
207 std::cout <<
"did not find reference to member " <<
lhs << std::endl;
212 cfv.out_of_date =
true;
213 this->inc_out_of_date_count();
216 else if (
rhs[0] ==
'"' ||
rhs[0] ==
'\'') {
217 size_t n =
rhs.size()-1;
222 for (
size_t i=1;
i<
rhs.size(); ++
i) {
223 if (
rhs[
i-1] ==
'\\' && (
rhs[
i] ==
'\\' ||
rhs[
i] == open))
228 else if (
rhs ==
"true" ||
rhs ==
"false") {
229 bool value =
rhs ==
"true";
238 double value =
atof(
rhs.c_str());
251 static std::map<std::string,config_file_observer*>& ref_config_file_observer_map()
253 static std::map<std::string,config_file_observer*>
cfom;
260 if (ref_config_file_observer_map().find(file_name) == ref_config_file_observer_map().end()) {
262 ref_config_file_observer_map()[file_name] =
cfo;
265 cfo = ref_config_file_observer_map()[file_name];
273 return d->process_gui_file(file_name);
286#include "lib_begin.h"
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 self_reflect(cgv::reflect::reflection_handler &)
used for simple self reflection
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,...
class for gui elements that view values of the type specified in the template argument
const T & get_value() const
return the current value
The cgv::reflect::find_reflection_hander steers traversal to a specific member and calls the virtual ...
the tokenizer allows to split text into tokens in a convenient way.
void update()
this virtual update allows for example to ask a view to update the viewed value. The default implemen...
void * get_user_data() const
this virtual method allows to pass application specific data for internal purposes
void update()
this virtual update allows for example to ask a view to update the viewed value. The default implemen...
void * get_user_data() const
this virtual method allows to pass application specific data for internal purposes
void update()
this virtual update allows for example to ask a view to update the viewed value. The default implemen...
void * get_user_data() const
this virtual method allows to pass application specific data for internal purposes
void * get_user_data() const
this virtual method allows to pass application specific data for internal purposes
void update()
this virtual update allows for example to ask a view to update the viewed value. The default implemen...
bool process_gui_file(const std::string &file_name)
process a gui file
config_file_observer * find_config_file_observer(const std::string &file_name, const std::string &content)
create or find a config_file_observer from the given file name and the read content of the config fil...
void multi_observe(base_ptr bp, const std::string &property_assignments, size_t off)
to be implemented method that adds permanent registration for a list of property assignments
the base namespace holds the base hierarchy, support for plugin registration and signals
void register_config_file_driver(config_file_driver *cfd)
method to register a config_file_driver
gui_driver_ptr get_gui_driver()
return the currently registered gui driver or an empty pointer if non has been registered
in this namespace reflection of types is implemented
@ TI_INT16
signed integer stored in 8 bits
@ TI_INT32
signed integer stored in 16 bits
@ TI_STRING
wide character type
@ TI_FLT32
floating point type stored in 16 bits
@ TI_UINT32
unsigned integer stored in 16 bits
@ TI_UINT8
signed integer stored in 64 bits
@ TI_INT64
signed integer stored in 32 bits
@ TI_UINT16
unsigned integer stored in 8 bits
@ TI_FLT64
floating point type stored in 32 bits
@ TI_UINT64
unsigned integer stored in 32 bits
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 a config file driver that handles permanent registration and gui config files.
abstract interface for observers of config files.
type independent functionality for all enum fallback implementations
std::string get_enum_name(unsigned i) const
return the name of the i-th enum item