cgv
|
the base namespace holds the base hierarchy, support for plugin registration and signals More...
Classes | |
class | action |
struct | argument_handler |
interface for objects that process unknown command line arguments More... | |
class | attach_slot |
class | base |
class | base_generator |
class | base_method_action |
struct | command_info |
a structure to store an analized command More... | |
struct | config_file_driver |
abstract interface for a config file driver that handles permanent registration and gui config files. More... | |
struct | config_file_observer |
abstract interface for observers of config files. More... | |
class | console |
struct | driver |
interfaces that add several listeners and objects. More... | |
struct | factory |
interface for a factory that allows to create objects derived from cgv::base::base More... | |
struct | factory_impl |
implementation of factory for objects of type T using the standard constructor More... | |
struct | factory_impl_1 |
implementation of factory for objects of type T using a constructor with one argument of type CA More... | |
struct | factory_impl_2 |
implementation of factory for objects of type T using a constructor with two arguments of types CA1 and CA2 More... | |
struct | factory_registration |
convenience class to register a factory of the given class type More... | |
struct | factory_registration_1 |
convenience class to register a factory of the given class type that uses a constructor with one argument of type CA More... | |
struct | factory_registration_2 |
convenience class to register a factory of the given class type that uses a constructor with one argument of type CA More... | |
class | find_action |
simple action implementation that adds nodes implementing X to a results vector More... | |
class | group |
class | matched_method_action |
class | method_action |
class | method_action_2 |
class | named |
class | node |
struct | object_constructor |
abstract base class of helpers to perform delayed registration and creation of objects in case that the registration is currently disabled More... | |
struct | object_registration |
convenience class to register an object of the given class type More... | |
struct | object_registration_1 |
convenience class to register an object of the given class type with one constructor argument More... | |
struct | object_registration_2 |
convenience class to register an object of the given class type with two constructor arguments More... | |
struct | registration_listener |
interfaces that allows to listen to registration events. More... | |
struct | registration_order_definition |
helper class whose constructor calls the define_registration_order() function More... | |
struct | resource_file_info |
information registered with each resource file More... | |
struct | resource_file_registration |
convenience class to register a resource file More... | |
struct | resource_string_registration |
convenience class to register a resource string More... | |
struct | server |
interfaces that add provides very basic functionality. More... | |
class | single_method_action |
class | single_method_action_2 |
class | test |
structure used to register a test function More... | |
struct | test_registration |
declare an instance of test_registration as static variable in order to register a test function in a test plugin More... | |
class | traverse_callback_handler |
interface of a handler for traverse callbacks More... | |
class | traverse_policy |
nodes should inherit from this policy class to allow selective tree traversals More... | |
class | traverser |
class used to traverse a tree structure More... | |
Typedefs | |
typedef data::ref_ptr< base, true > | base_ptr |
ref counted pointer to base | |
typedef cgv::data::ref_ptr< console, true > | console_ptr |
pointer to console | |
typedef data::ref_ptr< group, true > | group_ptr |
ref counted pointer to a node | |
typedef data::ref_ptr< named, true > | named_ptr |
ref counted pointer to a node | |
typedef data::ref_ptr< node, true > | node_ptr |
ref counted pointer to a node | |
Enumerations | |
enum | TraversePolicy { , TP_ONLY_FOCUS, TP_FIRST_FOCUS, TP_AUTO_FOCUS, TP_STOP_ON_SUCCESS = 8, TP_STOP_ON_FAILURE = 16 } |
different traversal policies More... | |
enum | TraverseStrategy |
not yet implemented | |
Functions | |
template<typename T1 , class X , typename R > | |
single_method_action< X, R, T1 > | make_action (T1 _v1, R(X::*_on_begin)(T1), bool _default_result_begin=false, bool _default_result_end=false) |
helper function to construct an action from a signature and one method that is called when a node is entered | |
template<typename T1 , class X , typename R1 , typename R2 > | |
matched_method_action< X, R1, R2, T1 > | make_action (T1 _v1, R1(X::*_on_begin)(T1), R2(X::*_on_end)(T1), bool _default_result_begin=false, bool _default_result_end=false) |
helper function to construct an action from a signature and two methods that are called when a node is entered and when it is left again | |
template<typename T1 , typename T2 , class X , typename R > | |
single_method_action_2< X, R, T1, T2 > | make_action_2 (T1 _v1, T2 _v2, R(X::*_on_begin)(T1, T2), bool _default_result_begin=false, bool _default_result_end=false) |
helper function to construct an action from a signature and one method that is called when a node is entered | |
bool | attach (base_ptr slot_object, base_ptr attachment_object, void *user_data) |
function to attach an object to an object of type attach_slot. More... | |
base_ptr | get_attachment (base_ptr slot_object) |
query the attachment of an attach_slot object. More... | |
void * | get_attachment_data (base_ptr slot_object) |
query the user data of the attachment of an attach_slot object. More... | |
template<typename T > | |
bool | has_property (const std::string &options, const std::string &property, T &value, bool report_error=true) |
simple parsing support to access values of properties in a string of property assignment More... | |
bool | exec (base_ptr bp, const std::string &method) |
call a void method without parameters | |
template<typename R > | |
bool | eval (base_ptr bp, const std::string &method, R &r) |
call a void method with one parameter of type T | |
template<typename T1 > | |
bool | exec (base_ptr bp, const std::string &method, const T1 &v1) |
call a void method with one parameter of type T | |
template<typename R , typename T1 > | |
bool | eval (base_ptr bp, const std::string &method, const T1 &v1, R &r) |
call a void method with one parameter of type T | |
template<typename T1 , typename T2 > | |
bool | exec (base_ptr bp, const std::string &method, const T1 &v1, const T2 &v2) |
call a void method with one parameter of type T | |
template<typename R , typename T1 , typename T2 > | |
bool | eval (base_ptr bp, const std::string &method, const T1 &v1, const T2 &v2, R &r) |
call a void method with one parameter of type T | |
template<typename T1 , typename T2 , typename T3 > | |
bool | exec (base_ptr bp, const std::string &method, const T1 &v1, const T2 &v2, const T3 &v3) |
call a void method with one parameter of type T | |
template<typename R , typename T1 , typename T2 , typename T3 > | |
bool | eval (base_ptr bp, const std::string &method, const T1 &v1, const T2 &v2, const T3 &v3, R &r) |
call a void method with one parameter of type T | |
template<typename T1 , typename T2 , typename T3 , typename T4 > | |
bool | exec (base_ptr bp, const std::string &method, const T1 &v1, const T2 &v2, const T3 &v3, const T4 &v4) |
call a void method with one parameter of type T | |
template<typename R , typename T1 , typename T2 , typename T3 , typename T4 > | |
bool | eval (base_ptr bp, const std::string &method, const T1 &v1, const T2 &v2, const T3 &v3, const T4 &v4, R &r) |
call a void method with one parameter of type T | |
template<typename T1 , typename T2 , typename T3 , typename T4 , typename T5 > | |
bool | exec (base_ptr bp, const std::string &method, const T1 &v1, const T2 &v2, const T3 &v3, const T4 &v4, const T5 &v5) |
call a void method with one parameter of type T | |
template<typename R , typename T1 , typename T2 , typename T3 , typename T4 , typename T5 > | |
bool | eval (base_ptr bp, const std::string &method, const T1 &v1, const T2 &v2, const T3 &v3, const T4 &v4, const T5 &v5, R &r) |
call a void method with one parameter of type T | |
template<typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 > | |
bool | exec (base_ptr bp, const std::string &method, const T1 &v1, const T2 &v2, const T3 &v3, const T4 &v4, const T5 &v5, const T6 &v6) |
call a void method with one parameter of type T | |
template<typename R , typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 > | |
bool | eval (base_ptr bp, const std::string &method, const T1 &v1, const T2 &v2, const T3 &v3, const T4 &v4, const T5 &v5, const T6 &v6, R &r) |
call a void method with one parameter of type T | |
template<typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 , typename T7 > | |
bool | exec (base_ptr bp, const std::string &method, const T1 &v1, const T2 &v2, const T3 &v3, const T4 &v4, const T5 &v5, const T6 &v6, const T7 &v7) |
call a void method with one parameter of type T | |
template<typename R , typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 , typename T7 > | |
bool | eval (base_ptr bp, const std::string &method, const T1 &v1, const T2 &v2, const T3 &v3, const T4 &v4, const T5 &v5, const T6 &v6, const T7 &v7, R &r) |
call a void method with one parameter of type T | |
template<typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 , typename T7 , typename T8 > | |
bool | exec (base_ptr bp, const std::string &method, const T1 &v1, const T2 &v2, const T3 &v3, const T4 &v4, const T5 &v5, const T6 &v6, const T7 &v7, const T8 &v8) |
call a void method with one parameter of type T | |
template<typename R , typename T1 , typename T2 , typename T3 , typename T4 , typename T5 , typename T6 , typename T7 , typename T8 > | |
bool | eval (base_ptr bp, const std::string &method, const T1 &v1, const T2 &v2, const T3 &v3, const T4 &v4, const T5 &v5, const T6 &v6, const T7 &v7, const T8 &v8, R &r) |
call a void method with one parameter of type T | |
template<class X > | |
void | find_interface (base_ptr start, std::vector< X * > &result) |
collect all nodes that implement interface X | |
template<class X , typename T > | |
bool | ensure_by_find (X *start, T *&pointer, unsigned i=0) |
traverse the hierarchy to find the i-th instance of type T and set pointer to it but only in case pointer is the nullptr, returns false if pointer was nullptr and no instance of type T was found | |
std::string | find_data_file (const std::string &file_name, const std::string &strategy, const std::string &sub_directory, const std::string &master_path) |
std::vector< std::string > & | ref_data_path_list () |
return a reference to the data path list, which is constructed from the environment variable CGV_DATA | |
void | push_file_parent (const std::string &path_or_file_name) |
extract a valid path from the given argument and push it onto the stack of parent paths. This should always be paired with a call to pop_file_parent(). | |
void | pop_file_parent () |
pop the latestly pushed parent path from the parent path stack. | |
std::vector< std::string > & | ref_parent_file_stack () |
return a reference to the data path list, which is constructed from the environment variable CGV_DATA More... | |
FILE * | open_data_file (const std::string &file_name, const char *mode) |
open a file with fopen supporting resource files, that have the prefix "res://" | |
bool | read_data_file (const std::string &file_name, std::string &content, bool ascii) |
read ascii file into a string | |
unsigned int | data_file_size (const std::string &file_name) |
return the file size of a given file with support for resource files, that have the prefix "res://" | |
unsigned int | find_file_offset (const std::string &file_name, const char *data, unsigned int data_size) |
find the offset of the given data block in the given file | |
void | register_object_internal (base_ptr object, const std::string &options) |
register an object and send event to all current registration ref_listeners() | |
template<class X > | |
bool | grab_focus (X *instance) |
try to grab the focus in the path of this node to the root of the tree | |
resource file registration | |
enum | CommandType |
enumerate type for all command types supported in configuration files | |
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 | |
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 | register_resource_string (const std::string &string_name, const char *string_data) |
register a resource string | |
CommandType | analyze_command (const cgv::utils::token &cmd, bool eliminate_quotes=true, command_info *info_ptr=0) |
parse a command and optionally store result in the command info, returns the command type | |
bool | process_command (const command_info &info) |
process a command given by a command info structure, return whether command was processed correctly | |
the base namespace holds the base hierarchy, support for plugin registration and signals
different traversal policies
CGV_API bool cgv::base::attach | ( | base_ptr | slot_object, |
base_ptr | attachment_object, | ||
void * | user_data = 0 |
||
) |
function to attach an object to an object of type attach_slot.
Return whether the slot_object implements the attach_slot interface and could retreive the attachment.
void CGV_API cgv::base::define_registration_order | ( | const std::string & | partial_order, |
bool | before_contructor_execution = false , |
||
const std::string & | when = "always" |
||
) |
specify a partial order of objects for registration
partial_order
is a semicolon separated list of type names that can ignore name spaces. before_constructor_execution
tells whether the reordering should happen before constructors of delayed registration events are called. when
specifies in which call to enable_registration
the reordering should happen. Possible values are
void CGV_API cgv::base::enable_registration | ( | ) |
enable registration and send all registration events that where emitted during disabled registration
Enable registration (default is that registration is disabled).
If registration has been disabled before, send all registration events that where emitted during disabled registration.
void CGV_API cgv::base::enable_registration_event_cleanup | ( | ) |
Enable cleanup of registration events (default).
If registration event cleanup is disabled, registration events are not discarded as soon as objects have been registered. This makes objects available to listeners that are registered later.
CGV_API std::string cgv::base::find_data_file | ( | const std::string & | file_name, |
const std::string & | strategy, | ||
const std::string & | sub_directory = "" , |
||
const std::string & | master_path = "" |
||
) |
Find a file with the given strategy and return the file name extended by the necessary path. The strategy defines in which search paths the file should be looked for, whether the search paths should be searched recursively and in which order the search paths should be searched (see details below). Optional arguments are a sub_directory and a master_path. For all non recursive searches the sub_directory will be added to each search path and the file is first looked up in the sub_directory. The master_path just defines another search path that can be used by the search strategy.
The search strategy is a string containing one letter for each search command, which are processed in the order of the string. Each capital letter causes a recursive search. The following search commands are available:
query the attachment of an attach_slot object.
If the slot_object is not derived from the attach_slot interface, return an empty base_ptr.
CGV_API void * cgv::base::get_attachment_data | ( | base_ptr | slot_object | ) |
query the user data of the attachment of an attach_slot object.
If the slot_object is not derived from the attach_slot interface, return the null pointer.
bool cgv::base::has_property | ( | const std::string & | options, |
const std::string & | property, | ||
T & | value, | ||
bool | report_error = true |
||
) |
simple parsing support to access values of properties in a string of property assignment
Given an option string (first parameter) with name-value-pairs, i.e. "x=10.4;tooltip='help'" and a property name (second parameter), the function returns whether the option string contains an assignment of the queried property and if yes, the value is stored in the reference given in the third parameter. The type casts supported by the cgv::type::variant type are used when converting to the reference type.
Examples:
true == has_property("x=10.4;tooltip='help'", "x", dbl_var)" ==> dbl_var = 10.4 true == has_property("x=10.4;tooltip='help'", "x", str_var)" ==> str_var = "10.4" true == has_property("x=10.4;tooltip='help'", "tooltip", str_var)" ==> str_var = "help" false == has_property("x=10.4;tooltip='help'", "y", int_var)" ==> int_var ... not changed
CGV_API void * cgv::base::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.
During plugin loading the registration is always disabled in order to avoid deadlocks that can arise when a registered object triggers loading of another dll.
bool CGV_API cgv::base::process_command | ( | const std::string & | cmd, |
bool | eliminate_quotes = true |
||
) |
process a command given as string.
Return whether the command was processed correctly. If eliminate_quotes is set to true, quotes around the command arguments are eliminated. This feature is used for commands specified on the command line, where spaces in the command arguments would split one command into pieces. Quotes are used then to protect the command from splitting.
The following commands are supported:
The assigment list in the name and type commands are of the form:
member_name_1=value_1;member_name_2=value_2;...
CGV_API std::vector< std::string > & cgv::base::ref_parent_file_stack | ( | ) |
return a reference to the data path list, which is constructed from the environment variable CGV_DATA
return a reference to the parent file stack controlled with push_file_parent() and pop_file_parent(), where the last vector element is the latestly pushed one
void CGV_API cgv::base::register_object | ( | base_ptr | object, |
const std::string & | options = "" |
||
) |
register an object and send event to all current registration ref_listeners()
register an object.
This will send an event to all currently registered registration listeners. The options parameter can be used to select a specific listener.
CGV_API void cgv::base::register_prog_name | ( | const char * | prog_name | ) |
set the file name of the current program.
simply pass argv[0] in the main procedure. This is done automatically in the process_command_line_args function.
void CGV_API cgv::base::unregister_object | ( | base_ptr | object, |
const std::string & | options | ||
) |
unregister an object and send event to all current registration ref_listeners()
unregister an object and send event to all currently registered registration listeners