1#include <cgv/base/register.h>
2#include <cgv/utils/convert.h>
3#include <cgv/utils/tokenizer.h>
5#include <cgv/utils/file.h>
6#include <cgv/type/variant.h>
34 bool registration_enabled;
35 bool permanent_registration;
36 bool registration_event_cleanup;
37 unsigned int nr_events_before_disable;
40 registration_enabled =
false;
41 permanent_registration =
true;
42 registration_event_cleanup =
false;
43 nr_events_before_disable = 0;
49 std::string partial_order;
50 bool before_contructor_execution;
54 const std::string&
_when)
62 std::vector<base_ptr> objects;
65 objects.push_back(
object);
69 for (
unsigned int i = 0;
i < objects.size(); ++
i) {
70 if (
object == objects[
i]) {
71 objects.erase(objects.begin() +
i);
76 void unregister_all_objects()
78 while (objects.size() > 0) {
82 named_ptr find_object_by_name(
const std::string& name)
84 for (
unsigned int oi = 0;
oi < objects.size(); ++
oi) {
86 if (
np &&
np->get_name() == name)
91 base_ptr find_object_by_type(
const std::string& type_name)
93 for (
unsigned int oi = 0;
oi < objects.size(); ++
oi) {
95 if (type_name == bp->get_type_name())
100 bool request_exit_from_all_objects()
103 for(
unsigned int oi = 0;
oi < objects.size(); ++
oi) {
105 exit =
exit && bp->on_exit_request();
119std::vector<registration_order_info>& ref_registration_order_infos()
121 static std::vector<registration_order_info> roi;
127 static std::string prog_name;
149registration_info& ref_info()
151 static registration_info ri;
155std::vector<std::pair<base_ptr, std::string>>& ref_registration_events()
157 static std::vector<std::pair<base_ptr, std::string>> registration_events;
158 return registration_events;
161std::vector<base_ptr>& ref_listeners()
163 static std::vector<base_ptr> listeners;
169void show_split_lines(
const std::string& s)
173 std::vector<token> toks;
175 for (
unsigned i = 0; i < toks.size(); ++i)
176 std::cout <<
"\n " <<
to_string(toks[i]).c_str();
179bool& ref_registration_debugging_enabled()
181#if defined CGV_FORCE_STATIC && defined _DEBUG
182 static bool is_debug =
true;
184 static bool is_debug =
false;
193 std::cout <<
"<" << o->
get_named()->get_name() <<
">";
199 if (is_c || is_s || is_d || is_l) {
216 std::string
all_options =
object->get_default_options();
221 std::cout <<
"REG OBJECT ('" <<
all_options <<
"') ";
222 show_object_debug_info(
object);
223 std::cout << std::endl;
230 std::cerr <<
"ERROR: last object registered " <<
is_registered[&(*object)] <<
" times" << std::endl;
235 for (
unsigned i = 0;
i < ref_listeners().size(); ++
i)
240 ref_object_collection().add_object(
object);
242 object->on_register();
248 const std::string& when)
250 ref_registration_order_infos().push_back(
registration_order_info(partial_order, before_contructor_execution, when));
253void add_partially_ordered(
const std::vector<std::set<unsigned>>& combined_partial_order,
254 std::vector<unsigned>& permutation, std::vector<bool>& appended, std::vector<bool>& delayed,
258 std::cout <<
"REG ORDER cyclic dependency of registration event <"
259 << ref_registration_events()[i].first->get_type_name() <<
">" << std::endl;
264 for (
auto j : combined_partial_order[i]) {
266 add_partially_ordered(combined_partial_order, permutation, appended, delayed, j);
270 permutation.push_back(i);
273void sort_registration_events(
bool before_contructor_execution)
276 size_t N = ref_registration_events().size();
277 std::vector<std::set<unsigned>> combined_partial_order;
278 combined_partial_order.resize(N);
279 unsigned nr_partial_orders = 0;
282 for (
auto roi : ref_registration_order_infos()) {
284 if (roi.before_contructor_execution != before_contructor_execution)
288 if (roi.when ==
"plugins") {
292 else if (roi.when ==
"program") {
296 else if (roi.when !=
"always") {
302 std::vector<cgv::utils::token> toks;
306 std::vector<unsigned> event_indices;
307 unsigned nr_matched = 0;
308 for (
auto t : toks) {
310 for (
unsigned i = 0; i < N; ++i) {
311 std::string tn = ref_registration_events()[i].first->get_type_name();
313 event_indices.push_back(i);
320 std::cout <<
"REG ORDER: could not find event <" << t <<
">" << std::endl;
323 if (nr_matched < 2) {
324 std::cout <<
"REG ORDER: partial order <" << roi.partial_order <<
"> did match only " << nr_matched
325 <<
" object" << std::endl;
330 for (
unsigned i = 1; i < event_indices.size(); ++i)
331 combined_partial_order[event_indices[i]].insert(event_indices[i - 1]);
334 if (nr_partial_orders == 0)
338 std::vector<unsigned> permutation;
339 std::vector<bool> appended(N,
false);
340 std::vector<bool> delayed(N,
false);
342 for (i = 0; i < N; ++i) {
344 add_partially_ordered(combined_partial_order, permutation, appended, delayed, i);
346 if (permutation.size() != N) {
347 std::cerr <<
"ERROR: could not compute valid permutation of registration events" << std::endl;
352 std::vector<std::pair<base_ptr, std::string>> permuted_registration_events;
353 permuted_registration_events.resize(N);
354 for (i = 0; i < N; ++i)
355 permuted_registration_events[i] = ref_registration_events()[permutation[i]];
356 ref_registration_events() = permuted_registration_events;
359registration_order_definition::registration_order_definition(
const std::string& partial_order,
360 bool before_contructor_execution,
const std::string& when)
367 ref_registration_debugging_enabled() =
true;
372 ref_registration_debugging_enabled() =
false;
378 return ref_registration_debugging_enabled();
390 unsigned i,
i0 = ref_info().nr_events_before_disable;
392 sort_registration_events(
true);
395 for (
i =
i0;
i < ref_registration_events().size(); ++
i) {
396 base_ptr o = ref_registration_events()[
i].first;
400 std::cout <<
"REG CONSTRUCT " <<
obr->get_constructed_type_name() <<
"('"
401 << ref_registration_events()[
i].second <<
"')";
403 ref_registration_events()[
i].first =
obr->construct_object();
407 show_object_debug_info(ref_registration_events()[
i].first);
408 std::cout << std::endl;
413 sort_registration_events(
false);
416 const std::vector<base_ptr>& L = ref_listeners();
417 for (
i =
i0;
i < ref_registration_events().size(); ++
i) {
418 base_ptr object = ref_registration_events()[
i].first;
423 ref_listeners().push_back(
object);
427 for (
i =
i0;
i < ref_registration_events().size(); ++
i) {
428 base_ptr object = ref_registration_events()[
i].first;
433 ref_listeners().push_back(
object);
437 for (
i =
i0;
i < ref_registration_events().size(); ++
i) {
438 base_ptr object = ref_registration_events()[
i].first;
444 ref_listeners().push_back(
object);
448 for (
j = 0;
j <
i0; ++
j)
449 listener->register_object(ref_registration_events()[
j].first, ref_registration_events()[
j].
second);
451 for (
j =
i0;
j <
i; ++
j) {
455 listener->register_object(ref_registration_events()[
j].first, ref_registration_events()[
j].
second);
460 for (
i =
i0;
i < ref_registration_events().size(); ++
i) {
461 base_ptr object = ref_registration_events()[
i].first;
470 ref_registration_events().clear();
472 ref_info().nr_events_before_disable = (
unsigned)ref_registration_events().size();
473 ref_info().registration_enabled =
true;
488 ref_info().nr_events_before_disable = (
unsigned)ref_registration_events().size();
489 ref_info().registration_enabled =
false;
495 return ref_info().registration_enabled;
503 std::cout <<
"ENABLE PERMANENT REGISTRATION" << std::endl;
505 ref_info().permanent_registration =
true;
510 ref_object_collection().unregister_all_objects();
515 return ref_object_collection().request_exit_from_all_objects();
521 return (
unsigned)ref_object_collection().objects.size();
529 return ref_object_collection().objects[
i];
537 std::cout <<
"DISABLE PERMANENT REGISTRATION" << std::endl;
539 ref_info().permanent_registration =
false;
545 return ref_info().permanent_registration;
553 std::cout <<
"ENABLE REGISTRATION CLEANUP" << std::endl;
555 ref_info().registration_event_cleanup =
true;
557 ref_registration_events().clear();
559 ref_registration_events().erase(ref_registration_events().begin(),
560 ref_registration_events().begin() + ref_info().nr_events_before_disable);
561 ref_info().nr_events_before_disable = 0;
570 std::cout <<
"DISABLE REGISTRATION CLEANUP" << std::endl;
572 ref_info().registration_event_cleanup =
false;
577 return ref_info().registration_event_cleanup;
585 ref_registration_events().emplace_back(
object, options);
588 std::cout <<
"REG EVENT ('" << options <<
"') ";
589 show_object_debug_info(
object);
590 std::cout << std::endl;
599 object =
oc->construct_object();
604 ref_listeners().push_back(
object);
608 for (
unsigned i = 0;
i < ref_registration_events().size(); ++
i)
609 rl->register_object(ref_registration_events()[
i].first, ref_registration_events()[
i].second);
622 std::cout <<
"UNREG " <<
object.operator->() <<
", '" << options <<
"' ("
623 << ref_object_collection().objects.size() <<
")" << std::endl;
627 ref_object_collection().remove_object(
object);
630 for (
i = 0;
i < ref_registration_events().size(); ++
i)
631 if (ref_registration_events()[
i].first ==
object) {
632 ref_registration_events().erase(ref_registration_events().begin() +
i);
638 for (
i = 0;
i < ref_listeners().size(); ++
i) {
639 if (ref_listeners()[
i] ==
object) {
640 ref_listeners().erase(ref_listeners().begin() +
i);
646 for (
unsigned int i = 0;
i < ref_listeners().size(); ++
i)
650 object->unregister();
656 return ref_object_collection().find_object_by_name(name);
662 return ref_object_collection().find_object_by_type(type_name);
665std::string get_config_file_name(
const std::string& _file_name)
667 std::string file_name = _file_name;
668 if (file::get_extension(file_name) ==
"def") {
669 std::string fn = file::drop_extension(file_name) +
".cfg";
670 if (file::exists(fn))
678bool process_command_ext(
const command_info& info,
bool* persistent = 0, config_file_observer* cfo = 0,
679 const char* begin = 0);
681config_file_driver*& ref_config_file_driver()
683 static config_file_driver* driver = 0;
689 if (ref_config_file_driver())
690 std::cerr <<
"warning: registering more than one config_file_driver" << std::endl;
691 ref_config_file_driver() =
cfd;
694config_file_observer* find_config_file_observer(
const std::string& file_name,
const std::string& content)
696 if (!ref_config_file_driver()) {
697 std::cerr <<
"warning: attempt to use permanent registration without a registered config_file_driver"
704bool process_config_file_ext(
const std::string& _file_name,
bool* persistent = 0)
707 std::string file_name = get_config_file_name(_file_name);
708 if (file_name.empty())
712 if (!file::read(file_name, content,
true)) {
713 std::cerr <<
"couldn't read config file " << file_name.c_str() << std::endl;
721 config_file_observer* cfo = find_config_file_observer(file_name, content);
724 std::vector<line> lines;
729 std::string cfg_file_dir = cgv::utils::file::get_path(_file_name);
730 for (i = 0; i < lines.size(); ++i) {
733 const char* begin = lines[i].
begin;
734 const char* iter = begin;
735 while (iter < lines[i].end) {
737 iter = std::find(iter, lines[i].end,
'$');
738 if (iter == lines[i].end) {
739 if (begin > lines[i].begin)
740 line += std::string(begin, lines[i].end);
746 if (++jter < lines[i].end) {
749 std::string var_name;
750 while (++jter < lines[i].end && *jter !=
')') {
751 var_name.push_back(*jter);
753 if (jter < lines[i].end) {
756 if (var_name ==
"CFG_FILE_DIR")
757 value = cfg_file_dir;
759 value = std::string(getenv(var_name.c_str()));
768 line += std::string(begin, iter);
770 begin = iter = jter + 1;
777 process_command_ext(info, persistent, cfo, &content[0]);
793 return cfd->process_gui_file(file_name);
794 std::cerr <<
"attempt to process gui file without a config_file_driver registered" << std::endl;
837 return "create:bool";
845 cgv::type::get_variant(
do_create, value_type, value_ptr);
858 cgv::type::set_variant(
true, value_type, value_ptr);
896std::string guess_created_type_name(
const char*
item_text)
898 std::vector<token>
toks;
905void register_factory_object(
base_ptr fo,
const char* item_text,
char shortcut)
907 std::string options(
"menu_text=\"");
908 options += item_text;
909 options +=
"\";shortcut='Ctrl-";
931 const char* file_data,
const std::string& source_file)
942void show_implementation(
bool& implements_shown,
const std::string& type_name)
944 if (implements_shown)
947 std::cout <<
" implements ";
948 implements_shown =
true;
950 std::cout << type_name;
956 const std::vector<base_ptr>& objects = ref_object_collection().objects;
958 std::cout <<
"\n\n_______________ show all registered objects ______________________\n\n";
959 for (
unsigned int oi = 0;
oi < objects.size(); ++
oi) {
962 std::cout <<
"name(" <<
np->get_name().c_str() <<
"):" <<
np->get_type_name();
964 std::cout <<
"type(" << objects[
oi]->get_type_name() <<
")";
974 show_split_lines(objects[
oi]->get_property_declarations());
977 std::cout <<
"__________________________________________________________________\n" << std::endl;
985 info_ptr->command_type = cmd;
987 info_ptr->parameters.push_back(*args_tok_ptr);
1001 return update_info(
info_ptr, CT_EMPTY);
1005 return update_info(
info_ptr, CT_COMMENT);
1009 return update_info(
info_ptr, CT_SHOW);
1011 return update_info(
info_ptr, CT_PERSISTENT);
1013 return update_info(
info_ptr, CT_INITIAL);
1018 return update_info(
info_ptr, CT_UNKNOWN);
1042 std::vector<token>
toks;
1046 if (
toks.size() == 4 &&
toks[1] ==
"(" &&
toks[3] ==
")" && (
toks[0] ==
"name" ||
toks[0] ==
"type")) {
1053 return update_info(
info_ptr, CT_UNKNOWN);
1056bool process_command_ext(
const command_info& info,
bool* persistent, config_file_observer* cfo,
const char* begin)
1058 switch (info.command_type) {
1068 *persistent =
false;
1072 std::cout <<
"read plugin " << info.parameters[0] << std::endl;
1075 std::cerr <<
"error reading plugin " << info.parameters[0] << std::endl;
1080 if (process_config_file_ext(
to_string(info.parameters[0]), persistent)) {
1081 std::cout <<
"read config file " << get_config_file_name(
to_string(info.parameters[0])) << std::endl;
1084 std::cerr <<
"error reading config file " << info.parameters[0] << std::endl;
1088 std::cout <<
"read gui file " << info.parameters[0] << std::endl;
1091 std::cerr <<
"error reading gui file " << info.parameters[0] << std::endl;
1096 if (info.command_type == CT_NAME) {
1099 std::cout <<
"name(" << np->get_name().c_str() <<
")";
1103 std::cerr <<
"could not find object of name '" << info.parameters[0] <<
"'" << std::endl;
1108 std::cout <<
"type(" << bp->get_type_name() <<
")";
1110 std::cerr <<
"could not find object of type <" << info.parameters[0] <<
">" << std::endl;
1113 std::string args =
to_string(info.parameters[1]);
1115 for (
unsigned int x = 0; x < args.size(); ++x)
1116 if (args[x] ==
'\'')
1119 show_split_lines(args);
1120 std::cout <<
"\n" << std::endl;
1121 if (persistent && *persistent && cfo)
1122 cfo->multi_observe(bp, args, info.parameters[1].begin - begin);
1124 bp->multi_set(
to_string(info.parameters[1]),
true);
1271 return process_command_ext(info);
1278 return process_command_ext(info);
1286 for (
int ai = 1; ai <
argc; ++ai)
1295 unsigned int file_offset = (
unsigned char)
symbol[0];
1296 file_offset += ((
unsigned int)(
unsigned char)
symbol[1] << 8);
1297 file_offset += ((
unsigned int)(
unsigned char)
symbol[2] << 16);
1298 file_offset += ((
unsigned int)(
unsigned char)
symbol[3] << 24);
1301 ((
unsigned int)(
unsigned char)
symbol[2] << 16) +
1302 ((
unsigned int)(
unsigned char)
symbol[3] << 24);
1304 if (source_file.empty())
1314std::string extend_plugin_name(
const std::string&
fn)
1316 std::string n = cgv::utils::file::drop_extension(
fn);
1321#if defined(_WIN32) || !defined(CGV_NDEBUG)
1328#if defined(_MSC_VER) && _MSC_VER < 1500
1330#elif defined(_MSC_VER) && _MSC_VER < 1600
1332#elif defined(_MSC_VER) && _MSC_VER < 1700
1334#elif defined(_MSC_VER) && _MSC_VER < 1800
1336#elif defined(_MSC_VER) && _MSC_VER < 1900
1338#elif defined(_MSC_VER) && _MSC_VER < 1910
1340#elif defined(_MSC_VER) && _MSC_VER < 1920
1342#elif defined(_MSC_VER) && _MSC_VER < 1930
1344#elif defined(_MSC_VER)
1349 n = std::string(
"lib") + n +
".so";
1368void* load_plugin_platform(
const std::string& name)
1375 return LoadLibrary(name.c_str());
1378 return dlopen(name.c_str(), RTLD_NOW);
1382void record_error_platform(
const std::string& dll_name, std::vector<std::string>& errors)
1385 DWORD dw = GetLastError();
1387 FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
nullptr,
1388 dw, MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR)&lpMsgBuf, 0,
nullptr);
1389 auto error = dll_name +
": " + std::string(
static_cast<const char*
>(lpMsgBuf));
1390 LocalFree(lpMsgBuf);
1391 errors.push_back(error);
1393 auto errPtr = dlerror();
1394 auto error = std::string(errPtr) +
"\n";
1395 errors.emplace_back(error);
1401 std::vector<token>
names;
1408 void* result =
nullptr;
1409 std::vector<std::string>
errors = {};
1413 fn[1] = extend_plugin_name(
fn[0]);
1419 fn[0] = std::string(
"lib") +
fn[0] +
".dylib";
1422 fn[0] = std::string(
"lib") +
fn[0] +
".so";
1425 std::swap(
fn[0],
fn[1]);
1431 result = load_plugin_platform(
dll_name);
1444 if (result ==
nullptr && !
errors.empty()) {
1445 std::cerr <<
"failed to load plugin " << file_name << std::endl;
1447 std::cerr <<
" " <<
err;
More advanced text processing for splitting text into lines or tokens.
virtual bool end()
perform the leave part of the action on the current object
T * get_interface()
use dynamic type cast to check for the given interface
virtual data::ref_ptr< named, true > get_named()
perform downcast to named
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...
base class for all gui types
complete implementation of method actions that only call one method when entering a node
bool begin()
uses call_method of base class method_action to call the method refered to by the stored method point...
structure used to register a test function
std::string get_type_name() const
implementation of the type name function of the base class
std::string get_test_name() const
access to name of test function
bool exec_test() const
execute test and return whether this was successful
test(const std::string &_test_name, bool(*_test_func)())
constructor for a test structure
std::string test_name
name of test function
static int nr_failed
static counter for all tests
bool(* test_func)()
pointer to test function
void clear()
set to null pointer
the tokenizer allows to split text into tokens in a convenient way.
tokenizer & set_sep(const std::string &sep, bool merge)
set the list of separators and specify whether succeeding separators are merged into single tokens
tokenizer & set_ws(const std::string &ws)
set the list of white spaces, that separate tokens and are skipped
token bite()
bite away a single token from the front
tokenizer & set_skip(const std::string &open, const std::string &close)
set several character pairs that enclose tokens that are not split
void register_object_internal(base_ptr object, const std::string &options)
register an object and send event to all current registration ref_listeners()
unsigned get_nr_permanently_registered_objects()
access to number of permanently registered objects
void unregister_all_objects()
unregister all existing objects to clean up
bool process_command(const command_info &info)
process a command given by a command info structure, return whether command was processed correctly
std::string & ref_prog_path_prefix()
return a refence to the path prefix of the started executable, this can be prepended for example to d...
void enable_permanent_registration()
register a registration listener that stores pointers to all registered objects
data::ref_ptr< base, true > base_ptr
ref counted pointer to base
void enable_registration_event_cleanup()
Enable cleanup of registration events (default).
std::string & ref_plugin_name()
return a reference to the currently loaded plugin
void disable_registration()
if registration is disable, all registration events are stored and sent at the momement when registra...
base_ptr get_permanently_registered_object(unsigned i)
access to i-th permanently registered object
void enable_registration_debugging()
enable registration debugging
named_ptr find_object_by_name(const std::string &name)
in case permanent registration is active, look for a registered object by name
bool is_registration_event_cleanup_enabled()
return whether registration cleanup is enabled
CommandType analyze_command(const cgv::utils::token &cmd, bool eliminate_quotes, command_info *info_ptr)
parse a command and optionally store result in the command info, returns the command type
CommandType
enumerate type for all command types supported in configuration files
bool is_registration_enabled()
check whether registration is enabled
void register_config_file_driver(config_file_driver *cfd)
method to register a config_file_driver
void register_resource_file(const std::string &file_path, unsigned int file_offset, unsigned int file_length, const char *file_data, const std::string &source_file)
register a resource file
void disable_permanent_registration()
deregister registration listener and dereference pointers to registered objects
bool request_exit_from_all_objects()
calls the on_exit_request method for all registered objects and return true if exiting is allowed
bool is_registration_debugging_enabled()
check whether registration debugging is enabled
void register_prog_name(const char *_prog_name)
set the file name of the current program.
void show_all()
show information about all registered members
void unregister_object(base_ptr object, const std::string &options)
unregister an object and send event to all current registration ref_listeners()
void enable_registration()
enable registration and send all registration events that where emitted during disabled registration
void disable_registration_debugging()
disable registration debugging
void process_command_line_args(int argc, char **argv)
process the command line arguments: extract program name and load all plugins
std::map< std::string, resource_file_info > & ref_resource_file_map()
return a reference to a mapping of resource file names to resource file infos
data::ref_ptr< named, true > named_ptr
ref counted pointer to a node
bool process_gui_file(const std::string &file_name)
interpret a gui file
void * load_plugin(const std::string &file_name)
load a plugin or dll and return a handle to the plugin, or 0 if loading was not successful.
void register_resource_string(const std::string &string_name, const char *string_data)
register a resource string
void register_object(base_ptr object, const std::string &options)
register an object and send event to all current registration ref_listeners()
std::string & ref_prog_name()
return a refence to the name of the started executable
void define_registration_order(const std::string &partial_order, bool before_contructor_execution, const std::string &when)
specify a partial order of objects for registration
base_ptr find_object_by_type(const std::string &type_name)
in case permanent registration is active, look for a registered object by type name
bool is_permanent_registration_enabled()
check whether permanent registration is enabled
void disable_registration_event_cleanup()
disable cleanup of registration events (see enable_registration_event_cleanup).
bool process_config_file(const std::string &_file_name)
interpret a config file
bool unload_plugin(void *handle)
unload the plugin with the given handle
namespace that holds tools that dont fit any other namespace
std::string to_string(const std::string &v, unsigned int w, unsigned int p, bool)
specialization of conversion from string to strings
void split_to_lines(const char *global_begin, const char *global_end, std::vector< line > &lines, bool truncate_trailing_spaces)
this function splits a text range at the newline characters into single lines.
char to_lower(char c)
convert char to lower case
void bite_all(tokenizer &t, std::vector< token > &result)
bite all tokens into a token vector
char to_upper(char c)
convert char to upper case
std::wstring str2wstr(const std::string &s)
convert a 8-bit string to a 16-bit string
const char * cutoff_spaces(const char *begin, const char *end)
return new end pointer by cutting off spaces at the end
const char * skip_spaces(const char *begin, const char *end)
return new start pointer by skipping spaces at begin
a structure to store an analized command
abstract interface for a config file driver that handles permanent registration and gui config files.
virtual config_file_observer * find_config_file_observer(const std::string &file_name, const std::string &content)=0
create or find a config_file_observer from the given file name and the read content of the config fil...
interfaces that add several listeners and objects.
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.
base_ptr singleton
pointer to the single object created by the factory in case is_singleton is true
bool is_singleton
store whether the factory can only create one object
std::string object_options
store the options used for registering newly created objects
base_ptr create_object()
overload to create an object
std::string created_type_name
store the type name of the to be created objects
bool is_singleton_factory() const
return whether the factory can only generate one instance of the given type
std::string get_property_declarations()
support creation of object by setting create property to true
virtual std::string get_object_options() const
return the options string used for object registration
factory(const std::string &_created_type_name, bool _singleton=false, const std::string &_object_options="")
construct
bool get_void(const std::string &property, const std::string &value_type, void *value_ptr)
abstract interface for the getter of a dynamic property.
const std::string & get_created_type_name() const
overload to return the type name of the objects that the factory can create
base_ptr get_singleton() const
return pointer to singleton
void release_singleton()
release the singleton pointer
virtual base_ptr create_object_impl()=0
overload to create an object
abstract base class of helpers to perform delayed registration and creation of objects in case that t...
interfaces that allows to listen to registration events.
information registered with each resource file
resource_file_info(unsigned int _file_offset=0, unsigned int _file_length=0, const char *_file_data=0, const std::string &_source_file="")
construct resource file info
resource_file_registration(const char *file_data)
builds a resource file info and registers it with the register_resource_file function
resource_string_registration(const std::string &string_name, const char *string_data)
builds a resource file info and registers it with the register_resource_file function
interfaces that add provides very basic functionality.
test_registration(const std::string &_test_name, bool(*_test_func)())
the constructor creates a test structure and registeres the test
a line in a text is simply represented as a token
representation of a token in a text by two pointers begin and end, that point to the first character ...
bool empty() const
return whether the token is empty
const char * begin
pointers that define the range of characters