3#include <cgv/base/base.h>
4#include <cgv/base/named.h>
5#include <cgv/utils/token.h>
6#include <cgv/type/info/type_name.h>
44extern void CGV_API
define_registration_order(
const std::string& partial_order,
bool before_contructor_execution =
false,
const std::string& when =
"always");
49 registration_order_definition(
const std::string& partial_order,
bool before_contructor_execution =
false,
const std::string& when =
"always");
122template <
class T,
typename CA>
139template <
class T,
typename CA1,
typename CA2>
170template <
class T,
typename CA>
183template <
class T,
typename CA1,
typename CA2>
241 virtual std::string get_object_options()
const;
243 const std::string& get_created_type_name()
const;
245 std::string get_property_declarations();
247 bool set_void(
const std::string&
property,
const std::string& value_type,
const void* value_ptr);
249 bool get_void(
const std::string&
property,
const std::string& value_type,
void* value_ptr);
251 bool is_singleton_factory()
const;
255 void release_singleton();
273template <
class T,
typename CA>
284template <
class T,
typename CA1,
typename CA2>
295extern std::string CGV_API guess_created_type_name(
const char* item_text);
296extern void CGV_API register_factory_object(
base_ptr fo,
const char* item_text,
char shortcut);
322template <
class T,
typename CA>
345template <
class T,
typename CA1,
typename CA2>
382 std::string get_type_name()
const;
384 std::string get_test_name()
const;
386 bool exec_test()
const;
390#define TEST_ASSERT(V) \
392 std::cerr << "\n" << __FILE__ << "(" << __LINE__ << ") : error: test failure" << std::endl; \
393 ++cgv::base::test::nr_failed; \
397#define TEST_ASSERT_EQ(V,Q) \
399 std::cerr << "\n" << __FILE__ << "(" << __LINE__ << ") : error: test failure " << (V) << "!=" << (Q) << std::endl; \
400 ++cgv::base::test::nr_failed; \
439extern CGV_API
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 =
"");
581extern CGV_API
void*
load_plugin(
const std::string& file_name);
592#include <cgv/config/lib_end.h>
base class for all classes that can be registered with support for dynamic properties (see also secti...
base_ptr construct_object() const
creation function
std::string get_type_name() const
return the type name of the object constructor class
std::string get_constructed_type_name() const
return the type name of the to be constructed object
base_ptr construct_object() const
creation function
std::string get_constructed_type_name() const
return the type name of the to be constructed object
std::string get_type_name() const
return the type name of the object constructor class
base_ptr construct_object() const
creation function
std::string get_type_name() const
return the type name of the object constructor class
std::string get_constructed_type_name() const
return the type name of the to be constructed object
complete implementation of method actions that only call one method when entering a node
structure used to register a test function
std::string test_name
name of test function
static int nr_failed
static counter for all tests
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
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
interface for objects that process unknown command line arguments
virtual void handle_args(std::vector< std::string > &args)=0
this function is called on registered objects with the list of unknown command line parameters
a structure to store an analized command
CommandType command_type
the command type
std::vector< cgv::utils::token > parameters
the parameters, one file name parameter for PLUGIN, CONFIG, GUI and two parameters (name/type,...
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...
virtual bool process_gui_file(const std::string &file_name)=0
process a gui file
abstract interface for observers of config files.
virtual void multi_observe(base_ptr bp, const std::string &property_assignments, size_t off)=0
to be implemented method that adds permanent registration for a list of property assignments
interfaces that add several listeners and objects.
implementation of factory for objects of type T using a constructor with one argument of type CA
base_ptr create_object_impl()
overload to create an object
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...
implementation of factory for objects of type T using a constructor with two arguments of types CA1 a...
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_ptr create_object_impl()
overload to create an object
implementation of factory for objects of type T using the standard constructor
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_ptr create_object_impl()
overload to create an object
convenience class to register a factory of the given class type that uses a constructor with one argu...
factory_registration_1(const std::string &_created_type_name, const CA &_ca, const std::string &_options="", bool _is_singleton=false, const std::string &_object_options="")
this registers an instance of a standard factory implementation
factory_registration_1(const char *item_text, char shortcut, const CA &_ca, bool is_singleton=false)
this constructor is only provided for downward compatibility and should not be used anymore.
convenience class to register a factory of the given class type that uses a constructor with one argu...
factory_registration_2(const std::string &_created_type_name, const CA1 &_ca1, const CA2 &_ca2, const std::string &_options="", bool _is_singleton=false, const std::string &_object_options="")
this registers an instance of a standard factory implementation
convenience class to register a factory of the given class type
factory_registration(const char *item_text, char shortcut, bool is_singleton=false)
this constructor is only provided for downward compatibility and should not be used anymore.
factory_registration(const std::string &_created_type_name, const std::string &_options="", bool _is_singleton=false, const std::string &_object_options="")
this registers an instance of the default factory implementation
interface for a factory that allows to create objects derived from cgv::base::base
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
std::string created_type_name
store the type name of the to be created objects
const std::string & get_created_type_name() const
overload to return the type name of the objects that the factory can create
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...
std::string get_type_name() const
return the type name of the object constructor class
virtual std::string get_constructed_type_name() const =0
return the type name of the to be constructed object
virtual base_ptr construct_object() const =0
creation function
convenience class to register an object of the given class type with one constructor argument
object_registration_1(const CA &arg, const std::string &options="")
pass information about the target registration listener in the options argument
convenience class to register an object of the given class type with two constructor arguments
object_registration_2(const CA1 &a1, const CA2 &a2, const std::string &options="")
pass information about the target registration listener in the options argument
convenience class to register an object of the given class type
object_registration(const std::string &options)
pass information about the target registration listener in the options argument
interfaces that allows to listen to registration events.
virtual void register_object(base_ptr object, const std::string &options="")=0
overload to handle registration events
virtual void unregister_object(base_ptr object, const std::string &options="")=0
overload to handle unregistration events
helper class whose constructor calls the define_registration_order() function
information registered with each resource file
std::string source_file
name of
const char * file_data
pointer to
unsigned int file_length
length of the resource file in bytes
unsigned int file_offset
at which location the resource file starts within the executable or dll
convenience class to register a resource file
convenience class to register a resource string
interfaces that add provides very basic functionality.
declare an instance of test_registration as static variable in order to register a test function in a...
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...
representation of a token in a text by two pointers begin and end, that point to the first character ...