cgv
Loading...
Searching...
No Matches
cgv::base Namespace Reference

the base namespace holds the base hierarchy, support for plugin registration and signals More...

Classes

struct  abst_property_access
 
class  action
 The action class is used in tree traversals together with the traverser. More...
 
struct  argument_handler
 interface for objects that process unknown command line arguments More...
 
class  attach_slot
 interface for an attachment slot that can store a base pointer More...
 
class  base
 base class for all classes that can be registered with support for dynamic properties (see also section Base Hierarchy of page Namespace cgv::base). More...
 
class  base_generator
 implements a dynamic object, that can be composed of independent variables, which are handled as properties of the base_generator and published through the property interface of the base class. More...
 
class  base_method_action
 base class for all actions that use methods of class X More...
 
class  call_reflection_handler
 
struct  cast_const_helper
 
struct  cast_const_helper< group >
 
struct  cast_const_helper< named >
 
struct  cast_const_helper< node >
 
struct  cast_const_helper_base
 
struct  cast_helper
 
struct  cast_helper< group >
 
struct  cast_helper< named >
 
struct  cast_helper< node >
 
struct  cast_helper_base
 
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
 interface to the console of the application with implementation of the property interface More...
 
struct  driver
 interfaces that add several listeners and objects. More...
 
struct  emulated_property_access
 
struct  extract_policy_struct
 
struct  extract_policy_struct< true, X >
 
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
 The group class is a node with children. More...
 
class  matched_method_action
 complete implementation of method actions that call a begin and end method when entering and leaving a node More...
 
class  method_action
 base class for all method actions that take a single argument of type T1 in their signature More...
 
class  method_action_2
 base class for all method actions that take a single argument of type T1 in their signature More...
 
class  named
 base class for all gui types More...
 
struct  no_handler
 
class  node
 The node class keeps a pointer to its parent. More...
 
struct  object_collection
 
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...
 
class  object_constructor_impl
 
class  object_constructor_impl_1
 
class  object_constructor_impl_2
 
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  property_access
 
struct  property_access< bool >
 
struct  property_access< cgv::type::int16_type >
 
struct  property_access< cgv::type::int32_type >
 
struct  property_access< cgv::type::int64_type >
 
struct  property_access< cgv::type::int8_type >
 
struct  property_access< cgv::type::uint16_type >
 
struct  property_access< cgv::type::uint32_type >
 
struct  property_access< cgv::type::uint64_type >
 
struct  property_access< cgv::type::uint8_type >
 
struct  property_access< double >
 
struct  property_access< float >
 
struct  property_access< std::string >
 
class  property_declaration_reflection_handler
 
struct  registration_info
 
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  registration_order_info
 
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
 complete implementation of method actions that only call one method when entering a node More...
 
class  single_method_action_2
 complete implementation of method actions that only call one method when entering a node More...
 
struct  standard_type_property_access
 
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...
 
struct  use_handler
 
struct  user_feedback
 function pointers implementing user feedback functionality of find_or_download_data_file() function More...
 

Typedefs

typedef data::ref_ptr< base, truebase_ptr
 ref counted pointer to base
 
typedef data::ref_ptr< const base, trueconst_base_ptr
 ref counted pointer to const base
 
typedef cgv::data::ref_ptr< console, trueconsole_ptr
 pointer to console
 
typedef data::ref_ptr< group, truegroup_ptr
 ref counted pointer to a node
 
typedef data::ref_ptr< const group, trueconst_group_ptr
 ref counted pointer to a node
 
typedef data::ref_ptr< named, truenamed_ptr
 ref counted pointer to a node
 
typedef data::ref_ptr< const named, trueconst_named_ptr
 ref counted pointer to a const node
 
typedef data::ref_ptr< node, truenode_ptr
 ref counted pointer to a node
 
typedef data::ref_ptr< const node, trueconst_node_ptr
 ref counted pointer to a const node
 

Enumerations

enum  TraversePolicy {
  TP_ALL , 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 { TS_DEPTH_FIRST , TS_BREADTH_FIRST }
 not yet implemented More...
 

Functions

template<typename T1 , class X , typename R >
single_method_action< X, R, T1make_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, T1make_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, T2make_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.
 
bool attach (base_ptr slot_object, base_ptr attachment_object, int user_data)
 
base_ptr get_attachment (base_ptr slot_object)
 query the attachment of an attach_slot object.
 
voidget_attachment_data (base_ptr slot_object)
 query the user data of the attachment of an attach_slot object.
 
int get_attachment_data_int (base_ptr slot_object)
 
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
 
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_rec (const std::string &path, const std::string &file_name)
 
std::string find_data_file_1 (const std::string &base_path, const std::string &sub_path, const std::string &file_name, bool recurse)
 
std::string 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.
 
void stdout_message (const std::string &text)
 std::cout based implementation of the message function for first argument to the user_feedback constructor
 
void stderr_message (const std::string &text)
 std::cerr based implementation of the message function for first argument to the user_feedback constructor
 
int std_query (const std::string &text, const std::string &answers, int default_answer)
 std::cout and std::cin based implementation of the query function for second argument to the user_feedback constructor
 
std::string std_ask_dir (const std::string &text, const std::string &path)
 std::cout and std::cin based implementation of the ask_dir function for third argument to the user_feedback constructor
 
std::string find_or_download_data_file (const std::string &file_name, const std::string &find_strategy, const std::string &url, const std::string &cache_strategy, const std::string &producer, const std::string &sub_directory="", const std::string &master_path="", user_feedback uf=user_feedback())
 same as find_data_file() but in case file is not found, it is downloaded from the provided url and stored in a directory searched for with the parameter cache_strategy.
 
std::string clean_data_path (const std::string &data_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
 
bool find_and_extend_system_path (std::string &file_name)
 
FILEopen_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
 
object_collectionref_object_collection ()
 
std::vector< registration_order_info > & ref_registration_order_infos ()
 
registration_inforef_info ()
 
std::vector< std::pair< base_ptr, std::string > > & ref_registration_events ()
 
std::vector< base_ptr > & ref_listeners ()
 
void show_split_lines (const std::string &s)
 
boolref_registration_debugging_enabled ()
 
void show_object_debug_info (cgv::base::base_ptr o)
 
void register_object_internal (base_ptr object, const std::string &options)
 register an object and send event to all current registration ref_listeners()
 
void add_partially_ordered (const std::vector< std::set< unsigned > > &combined_partial_order, std::vector< unsigned > &permutation, std::vector< bool > &appended, std::vector< bool > &delayed, unsigned i)
 
void sort_registration_events (bool before_contructor_execution)
 
std::string get_config_file_name (const std::string &_file_name)
 
bool process_command_ext (const command_info &info, bool *persistent=0, config_file_observer *cfo=0, const char *begin=0)
 
config_file_driver *& ref_config_file_driver ()
 
config_file_observerfind_config_file_observer (const std::string &file_name, const std::string &content)
 
bool process_config_file_ext (const std::string &_file_name, bool *persistent=0)
 
void show_implementation (bool &implements_shown, const std::string &type_name)
 
CommandType update_info (command_info *info_ptr, CommandType cmd, cgv::utils::token *args_tok_ptr=0)
 
std::string extend_plugin_name (const std::string &fn)
 
voidload_plugin_platform (const std::string &name)
 
void record_error_platform (const std::string &dll_name, std::vector< std::string > &errors)
 
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
 
processing of command line arguments
std::string & ref_prog_name ()
 return a refence to the name of the started executable
 
std::string & ref_prog_path_prefix ()
 return a refence to the path prefix of the started executable, this can be prepended for example to dll names
 
void register_prog_name (const char *prog_name)
 set the file name of the current program.
 
void process_command_line_args (int argc, char **argv)
 process the command line arguments: extract program name and load all plugins
 
loading of plugins
std::string & ref_plugin_name ()
 return a reference to the currently loaded plugin
 
voidload_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.
 
bool unload_plugin (void *handle)
 unload the plugin with the given handle
 
control over the registration process
void 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
 
void enable_registration_debugging ()
 enable registration debugging
 
void disable_registration_debugging ()
 disable registration debugging
 
bool is_registration_debugging_enabled ()
 check whether registration debugging is enabled
 
void enable_registration ()
 enable registration and send all registration events that where emitted during disabled registration
 
void disable_registration ()
 if registration is disable, all registration events are stored and sent at the momement when registration is enabled again. This feature is used when loading dlls
 
bool is_registration_enabled ()
 check whether registration is enabled
 
void enable_permanent_registration ()
 register a registration listener that stores pointers to all registered objects
 
void unregister_all_objects ()
 unregister all existing objects to clean up
 
bool request_exit_from_all_objects ()
 calls the on_exit_request method for all registered objects and return true if exiting is allowed
 
unsigned get_nr_permanently_registered_objects ()
 access to number of permanently registered objects
 
base_ptr get_permanently_registered_object (unsigned i)
 access to i-th permanently registered object
 
void disable_permanent_registration ()
 deregister registration listener and dereference pointers to registered objects
 
bool is_permanent_registration_enabled ()
 check whether permanent registration is enabled
 
void enable_registration_event_cleanup ()
 Enable cleanup of registration events (default).
 
void disable_registration_event_cleanup ()
 disable cleanup of registration events (see enable_registration_event_cleanup).
 
bool is_registration_event_cleanup_enabled ()
 return whether registration cleanup is enabled
 
object registration
void register_object (base_ptr object, const std::string &options)
 register an object and send event to all current registration ref_listeners()
 
void unregister_object (base_ptr object, const std::string &options)
 unregister an object and send event to all current registration ref_listeners()
 
configuration and gui files
named_ptr find_object_by_name (const std::string &name)
 in case permanent registration is active, look for a registered object by name
 
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
 
void register_config_file_driver (config_file_driver *cfd)
 method to register a config_file_driver
 
bool process_config_file (const std::string &file_name)
 interpret a config file
 
bool process_gui_file (const std::string &file_name)
 interpret a gui file
 
support for driver, listener and factory registration
std::string guess_created_type_name (const char *item_text)
 
void register_factory_object (base_ptr fo, const char *item_text, char shortcut)
 
processing of commands
void show_all ()
 show information about all registered members
 
bool process_command (const std::string &cmd, bool eliminate_quotes=true)
 process a command given as string.
 

Variables

class CGV_API traverse_policy
 
class CGV_API base
 
class CGV_API named
 
class CGV_API node
 
class CGV_API group
 

resource file registration

enum  CommandType {
  CT_UNKNOWN , CT_EMPTY , CT_COMMENT , CT_SHOW ,
  CT_PERSISTENT , CT_INITIAL , CT_PLUGIN , CT_CONFIG ,
  CT_GUI , CT_NAME , CT_TYPE
}
 enumerate type for all command types supported in configuration files More...
 
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
 

Detailed Description

the base namespace holds the base hierarchy, support for plugin registration and signals

Typedef Documentation

◆ base_ptr

ref counted pointer to base

Definition at line 37 of file base.h.

◆ console_ptr

pointer to console

Definition at line 14 of file console.h.

◆ const_base_ptr

ref counted pointer to const base

Definition at line 40 of file base.h.

◆ const_group_ptr

ref counted pointer to a node

Definition at line 16 of file group.h.

◆ const_named_ptr

ref counted pointer to a const node

Definition at line 16 of file named.h.

◆ const_node_ptr

ref counted pointer to a const node

Definition at line 15 of file node.h.

◆ group_ptr

ref counted pointer to a node

Definition at line 14 of file group.h.

◆ named_ptr

ref counted pointer to a node

Definition at line 13 of file named.h.

◆ node_ptr

ref counted pointer to a node

Definition at line 13 of file node.h.

Enumeration Type Documentation

◆ CommandType

enumerate type for all command types supported in configuration files

Definition at line 469 of file register.h.

◆ TraversePolicy

different traversal policies

Enumerator
TP_ONLY_FOCUS 

traverse all children

TP_FIRST_FOCUS 

traverse only the focused child

TP_AUTO_FOCUS 

first traverse focused and then the remaining children

TP_STOP_ON_SUCCESS 

like previous but change focus to the child, where traversal succeeded

TP_STOP_ON_FAILURE 

this is an optional flag for traversals with methods that return a bool. If the returned bool is true, traversal stops if this flag is set

Definition at line 13 of file traverser.h.

◆ TraverseStrategy

not yet implemented

Definition at line 94 of file traverser.h.

Function Documentation

◆ add_partially_ordered()

void cgv::base::add_partially_ordered ( const std::vector< std::set< unsigned > > &  combined_partial_order,
std::vector< unsigned > &  permutation,
std::vector< bool > &  appended,
std::vector< bool > &  delayed,
unsigned  i 
)

Definition at line 253 of file register.cxx.

◆ analyze_command()

CommandType CGV_API cgv::base::analyze_command ( const cgv::utils::token cmd,
bool  eliminate_quotes,
command_info info_ptr 
)

◆ attach() [1/2]

CGV_API bool cgv::base::attach ( base_ptr  slot_object,
base_ptr  attachment_object,
int  user_data 
)

Definition at line 47 of file attach_slot.cxx.

◆ attach() [2/2]

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.

Definition at line 38 of file attach_slot.cxx.

◆ clean_data_path()

std::string cgv::base::clean_data_path ( const std::string &  data_path)

Definition at line 263 of file import.cxx.

◆ data_file_size()

CGV_API unsigned int cgv::base::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://"

Definition at line 413 of file import.cxx.

References ref_resource_file_map().

Referenced by read_data_file().

◆ define_registration_order()

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

  • "always"
  • "program" only once for the enable event of the executed program
  • "plugins" for enable events of all loaded plugins
  • <plugin_name> only for the enable event of the plugin with the given name If several partial orders are defined for an enable call, a combined partial order is computed and used to find the order closest to the actual registration order that is in accordance to the combined partial order.

Definition at line 247 of file register.cxx.

◆ disable_permanent_registration()

void CGV_API cgv::base::disable_permanent_registration ( )

deregister registration listener and dereference pointers to registered objects

Definition at line 532 of file register.cxx.

References is_permanent_registration_enabled(), and is_registration_debugging_enabled().

◆ disable_registration()

void CGV_API cgv::base::disable_registration ( )

if registration is disable, all registration events are stored and sent at the momement when registration is enabled again. This feature is used when loading dlls

Definition at line 480 of file register.cxx.

References is_registration_debugging_enabled(), is_registration_enabled(), ref_plugin_name(), and ref_prog_name().

Referenced by load_plugin().

◆ disable_registration_debugging()

void CGV_API cgv::base::disable_registration_debugging ( )

disable registration debugging

Definition at line 370 of file register.cxx.

◆ disable_registration_event_cleanup()

void CGV_API cgv::base::disable_registration_event_cleanup ( )

disable cleanup of registration events (see enable_registration_event_cleanup).

Definition at line 565 of file register.cxx.

References is_registration_debugging_enabled(), and is_registration_event_cleanup_enabled().

◆ enable_permanent_registration()

void CGV_API cgv::base::enable_permanent_registration ( )

register a registration listener that stores pointers to all registered objects

Definition at line 498 of file register.cxx.

References is_permanent_registration_enabled(), and is_registration_debugging_enabled().

◆ enable_registration()

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.

Definition at line 381 of file register.cxx.

References cgv::base::base::get_interface(), is_registration_debugging_enabled(), is_registration_enabled(), is_registration_event_cleanup_enabled(), ref_plugin_name(), ref_prog_name(), and register_object_internal().

Referenced by load_plugin().

◆ enable_registration_debugging()

void CGV_API cgv::base::enable_registration_debugging ( )

enable registration debugging

Definition at line 365 of file register.cxx.

◆ enable_registration_event_cleanup()

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.

Definition at line 548 of file register.cxx.

References is_registration_debugging_enabled(), is_registration_enabled(), and is_registration_event_cleanup_enabled().

◆ ensure_by_find()

template<class X , typename T >
bool cgv::base::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

Definition at line 45 of file find_action.h.

◆ extend_plugin_name()

std::string cgv::base::extend_plugin_name ( const std::string &  fn)

Definition at line 1314 of file register.cxx.

◆ find_and_extend_system_path()

bool cgv::base::find_and_extend_system_path ( std::string &  file_name)

Definition at line 327 of file import.cxx.

◆ find_config_file_observer()

config_file_observer * cgv::base::find_config_file_observer ( const std::string &  file_name,
const std::string &  content 
)

Definition at line 694 of file register.cxx.

◆ find_data_file()

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:

  • r/R ... search resource files (no recursive search necessary as resource files do not have paths) and if found add the prefix "res://" to the file_name
  • c/C ... search current directory (here no path prefix is used)
  • m/M ... search master path
  • d/D ... search all data paths registered in the environment variable CGV_DATA
  • p/P ... search the path of the parent on the parent path stack that is controlled with push_file_parent() and pop_file_parent()
  • a/A ... search all anchester paths of the all parents on the parent path stack that is controlled with push_file_parent() and pop_file_parent() As an example the strategy "cpmD" first looks in the current directory, then in the parent directory, then in the master path and finally recursively in each of the registered data paths.

Definition at line 59 of file import.cxx.

References ref_data_path_list(), ref_parent_file_stack(), and ref_resource_file_map().

Referenced by find_or_download_data_file(), vr::get_vrmesh_render_info(), cgv::render::gl::mesh_drawable::read_mesh(), and cgv::media::mesh::obj_reader_base::read_mtl().

◆ find_data_file_1()

std::string cgv::base::find_data_file_1 ( const std::string &  base_path,
const std::string &  sub_path,
const std::string &  file_name,
bool  recurse 
)

Definition at line 40 of file import.cxx.

◆ find_data_file_rec()

std::string cgv::base::find_data_file_rec ( const std::string &  path,
const std::string &  file_name 
)

Definition at line 21 of file import.cxx.

◆ find_file_offset()

CGV_API unsigned int cgv::base::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

Definition at line 421 of file import.cxx.

Referenced by open_data_file().

◆ find_interface()

template<class X >
void cgv::base::find_interface ( base_ptr  start,
std::vector< X * > &  result 
)

collect all nodes that implement interface X

Definition at line 38 of file find_action.h.

References cgv::base::traverser::traverse().

◆ find_object_by_name()

named_ptr CGV_API cgv::base::find_object_by_name ( const std::string &  name)

in case permanent registration is active, look for a registered object by name

Definition at line 654 of file register.cxx.

◆ find_object_by_type()

base_ptr CGV_API cgv::base::find_object_by_type ( const std::string &  type_name)

in case permanent registration is active, look for a registered object by type name

Definition at line 660 of file register.cxx.

◆ find_or_download_data_file()

CGV_API std::string cgv::base::find_or_download_data_file ( const std::string &  file_name,
const std::string &  find_strategy,
const std::string &  url,
const std::string &  cache_strategy,
const std::string &  producer,
const std::string &  sub_directory = "",
const std::string &  master_path = "",
user_feedback  uf = user_feedback() 
)

same as find_data_file() but in case file is not found, it is downloaded from the provided url and stored in a directory searched for with the parameter cache_strategy.

One can use letters as in the strategy parameter to find_data_file() but recursion and ressources are ignored. With the user_feedback argument one can control how messages, queries and asking for a path is cast on to the user. By default an empty user feedback is used. To use std in and out you could use the following as the last parameter:

cgv::base::user_feedback(&cgv::base::stdout_message, &cgv::base::std_query, &cgv::base::std_ask_dir)

If a gui driver is available one can use the following alternative after including <cgv/gui/dialog.h> and <cgv/gui/file_dialog.h>

cgv::base::user_feedback(&cgv::gui::message, &cgv::gui::question, &cgv::gui::directory_save_dialog)

Definition at line 159 of file import.cxx.

References find_data_file(), ref_data_path_list(), and ref_parent_file_stack().

◆ get_attachment()

CGV_API base_ptr cgv::base::get_attachment ( base_ptr  slot_object)

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.

Definition at line 53 of file attach_slot.cxx.

◆ get_attachment_data()

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.

Definition at line 62 of file attach_slot.cxx.

◆ get_attachment_data_int()

CGV_API int cgv::base::get_attachment_data_int ( base_ptr  slot_object)

Definition at line 70 of file attach_slot.cxx.

◆ get_config_file_name()

std::string cgv::base::get_config_file_name ( const std::string &  _file_name)

Definition at line 665 of file register.cxx.

◆ get_nr_permanently_registered_objects()

unsigned CGV_API cgv::base::get_nr_permanently_registered_objects ( )

access to number of permanently registered objects

Definition at line 519 of file register.cxx.

Referenced by get_permanently_registered_object().

◆ get_permanently_registered_object()

base_ptr CGV_API cgv::base::get_permanently_registered_object ( unsigned  i)

access to i-th permanently registered object

Definition at line 525 of file register.cxx.

References get_nr_permanently_registered_objects().

◆ grab_focus()

template<class X >
bool cgv::base::grab_focus ( X *  instance)

◆ guess_created_type_name()

std::string CGV_API cgv::base::guess_created_type_name ( const char item_text)

Definition at line 896 of file register.cxx.

◆ has_property()

template<typename T >
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

Definition at line 130 of file base_generator.h.

Referenced by cgv::gui::provider::begin_tree_node_void().

◆ is_permanent_registration_enabled()

bool CGV_API cgv::base::is_permanent_registration_enabled ( )

check whether permanent registration is enabled

Definition at line 543 of file register.cxx.

Referenced by disable_permanent_registration(), enable_permanent_registration(), and register_object_internal().

◆ is_registration_debugging_enabled()

bool CGV_API cgv::base::is_registration_debugging_enabled ( )

◆ is_registration_enabled()

◆ is_registration_event_cleanup_enabled()

bool CGV_API cgv::base::is_registration_event_cleanup_enabled ( )

return whether registration cleanup is enabled

Definition at line 575 of file register.cxx.

Referenced by disable_registration_event_cleanup(), enable_registration(), enable_registration_event_cleanup(), and register_object().

◆ load_plugin()

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.

Definition at line 1399 of file register.cxx.

References cgv::utils::bite_all(), disable_registration(), enable_registration(), is_registration_enabled(), ref_plugin_name(), cgv::utils::to_lower(), and cgv::utils::to_string().

◆ load_plugin_platform()

void * cgv::base::load_plugin_platform ( const std::string &  name)

Definition at line 1368 of file register.cxx.

◆ make_action() [1/2]

template<typename T1 , class X , typename R >
single_method_action< X, R, T1 > cgv::base::make_action ( T1  _v1,
R(X::*)(T1 _on_begin,
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

Definition at line 146 of file action.h.

◆ make_action() [2/2]

template<typename T1 , class X , typename R1 , typename R2 >
matched_method_action< X, R1, R2, T1 > cgv::base::make_action ( T1  _v1,
R1(X::*)(T1 _on_begin,
R2(X::*)(T1 _on_end,
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

Definition at line 152 of file action.h.

◆ make_action_2()

template<typename T1 , typename T2 , class X , typename R >
single_method_action_2< X, R, T1, T2 > cgv::base::make_action_2 ( T1  _v1,
T2  _v2,
R(X::*)(T1, T2 _on_begin,
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

Definition at line 203 of file action.h.

◆ open_data_file()

CGV_API FILE * cgv::base::open_data_file ( const std::string &  file_name,
const char mode 
)

open a file with fopen supporting resource files, that have the prefix "res://"

Definition at line 350 of file import.cxx.

References find_file_offset(), ref_prog_name(), ref_prog_path_prefix(), and ref_resource_file_map().

Referenced by cgv::media::image::bmp_reader::open(), and read_data_file().

◆ pop_file_parent()

CGV_API void cgv::base::pop_file_parent ( )

pop the latestly pushed parent path from the parent path stack.

Definition at line 314 of file import.cxx.

References ref_parent_file_stack().

◆ process_command() [1/2]

bool CGV_API cgv::base::process_command ( const command_info info)

process a command given by a command info structure, return whether command was processed correctly

Definition at line 1269 of file register.cxx.

Referenced by process_command_line_args().

◆ process_command() [2/2]

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:

  • show all ... print out information on all registered objects
  • plugin:file_name ... read a plugin
  • config:file_name ... read a config file
  • gui:file_name ... read a gui description file
  • name(xxx):assignment list ... find registered object by name xxx and process assignments on them
  • type(yyy):assignment list ... find registered object by type yyy and process assignments on them

The assigment list in the name and type commands are of the form:

member_name_1=value_1;member_name_2=value_2;...

Definition at line 1274 of file register.cxx.

References analyze_command().

◆ process_command_ext()

bool cgv::base::process_command_ext ( const command_info info,
bool persistent = 0,
config_file_observer cfo = 0,
const char begin = 0 
)

Definition at line 1056 of file register.cxx.

◆ process_command_line_args()

CGV_API void cgv::base::process_command_line_args ( int  argc,
char **  argv 
)

process the command line arguments: extract program name and load all plugins

Definition at line 1283 of file register.cxx.

References process_command(), and register_prog_name().

◆ process_config_file()

bool CGV_API cgv::base::process_config_file ( const std::string &  _file_name)

interpret a config file

Definition at line 783 of file register.cxx.

◆ process_config_file_ext()

bool cgv::base::process_config_file_ext ( const std::string &  _file_name,
bool persistent = 0 
)

Definition at line 704 of file register.cxx.

◆ process_gui_file()

bool CGV_API cgv::base::process_gui_file ( const std::string &  file_name)

interpret a gui file

Definition at line 789 of file register.cxx.

◆ push_file_parent()

CGV_API void cgv::base::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().

Definition at line 295 of file import.cxx.

References ref_parent_file_stack().

◆ read_data_file()

CGV_API bool cgv::base::read_data_file ( const std::string &  file_name,
std::string &  content,
bool  ascii 
)

◆ record_error_platform()

void cgv::base::record_error_platform ( const std::string &  dll_name,
std::vector< std::string > &  errors 
)

Definition at line 1382 of file register.cxx.

◆ ref_config_file_driver()

config_file_driver *& cgv::base::ref_config_file_driver ( )

Definition at line 681 of file register.cxx.

◆ ref_data_path_list()

CGV_API std::vector< std::string > & cgv::base::ref_data_path_list ( )

return a reference to the data path list, which is constructed from the environment variable CGV_DATA

Definition at line 274 of file import.cxx.

References cgv::utils::bite_all(), and cgv::utils::to_string().

Referenced by find_data_file(), and find_or_download_data_file().

◆ ref_info()

registration_info & cgv::base::ref_info ( )

Definition at line 149 of file register.cxx.

◆ ref_listeners()

std::vector< base_ptr > & cgv::base::ref_listeners ( )

Definition at line 161 of file register.cxx.

◆ ref_object_collection()

object_collection & cgv::base::ref_object_collection ( )

Definition at line 113 of file register.cxx.

◆ ref_parent_file_stack()

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

Definition at line 321 of file import.cxx.

Referenced by find_data_file(), find_or_download_data_file(), pop_file_parent(), and push_file_parent().

◆ ref_plugin_name()

CGV_API std::string & cgv::base::ref_plugin_name ( )

return a reference to the currently loaded plugin

Definition at line 137 of file register.cxx.

Referenced by disable_registration(), enable_registration(), load_plugin(), and cgv::base::resource_file_registration::resource_file_registration().

◆ ref_prog_name()

CGV_API std::string & cgv::base::ref_prog_name ( )

◆ ref_prog_path_prefix()

CGV_API std::string & cgv::base::ref_prog_path_prefix ( )

return a refence to the path prefix of the started executable, this can be prepended for example to dll names

Definition at line 131 of file register.cxx.

Referenced by open_data_file(), and register_prog_name().

◆ ref_registration_debugging_enabled()

bool & cgv::base::ref_registration_debugging_enabled ( )

Definition at line 179 of file register.cxx.

◆ ref_registration_events()

std::vector< std::pair< base_ptr, std::string > > & cgv::base::ref_registration_events ( )

Definition at line 155 of file register.cxx.

◆ ref_registration_order_infos()

std::vector< registration_order_info > & cgv::base::ref_registration_order_infos ( )

Definition at line 119 of file register.cxx.

◆ ref_resource_file_map()

CGV_API std::map< std::string, resource_file_info > & cgv::base::ref_resource_file_map ( )

return a reference to a mapping of resource file names to resource file infos

Definition at line 143 of file register.cxx.

Referenced by data_file_size(), find_data_file(), cgv::render::shader_code::find_file(), open_data_file(), read_data_file(), register_resource_file(), and register_resource_string().

◆ register_config_file_driver()

CGV_API void cgv::base::register_config_file_driver ( config_file_driver cfd)

method to register a config_file_driver

Definition at line 687 of file register.cxx.

◆ register_factory_object()

void CGV_API cgv::base::register_factory_object ( base_ptr  fo,
const char item_text,
char  shortcut 
)

Definition at line 905 of file register.cxx.

◆ register_object()

◆ register_object_internal()

void cgv::base::register_object_internal ( base_ptr  object,
const std::string &  options 
)

register an object and send event to all current registration ref_listeners()

Definition at line 214 of file register.cxx.

References cgv::base::action::end(), is_permanent_registration_enabled(), is_registration_debugging_enabled(), and register_object().

Referenced by enable_registration(), and register_object().

◆ register_prog_name()

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.

Definition at line 915 of file register.cxx.

References ref_prog_name(), and ref_prog_path_prefix().

Referenced by process_command_line_args().

◆ register_resource_file()

CGV_API void cgv::base::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

Definition at line 930 of file register.cxx.

References ref_resource_file_map().

Referenced by cgv::base::resource_file_registration::resource_file_registration().

◆ register_resource_string()

CGV_API void cgv::base::register_resource_string ( const std::string &  string_name,
const char string_data 
)

register a resource string

Definition at line 936 of file register.cxx.

References ref_resource_file_map().

Referenced by cgv::base::resource_string_registration::resource_string_registration().

◆ request_exit_from_all_objects()

bool CGV_API cgv::base::request_exit_from_all_objects ( )

calls the on_exit_request method for all registered objects and return true if exiting is allowed

Definition at line 513 of file register.cxx.

◆ show_all()

void CGV_API cgv::base::show_all ( )

show information about all registered members

Definition at line 954 of file register.cxx.

◆ show_implementation()

void cgv::base::show_implementation ( bool implements_shown,
const std::string &  type_name 
)

Definition at line 942 of file register.cxx.

◆ show_object_debug_info()

void cgv::base::show_object_debug_info ( cgv::base::base_ptr  o)

Definition at line 189 of file register.cxx.

◆ show_split_lines()

void cgv::base::show_split_lines ( const std::string &  s)

Definition at line 169 of file register.cxx.

◆ sort_registration_events()

void cgv::base::sort_registration_events ( bool  before_contructor_execution)

Definition at line 273 of file register.cxx.

◆ std_ask_dir()

CGV_API std::string cgv::base::std_ask_dir ( const std::string &  text,
const std::string &  path 
)

std::cout and std::cin based implementation of the ask_dir function for third argument to the user_feedback constructor

Definition at line 150 of file import.cxx.

◆ std_query()

CGV_API int cgv::base::std_query ( const std::string &  text,
const std::string &  answers,
int  default_answer 
)

std::cout and std::cin based implementation of the query function for second argument to the user_feedback constructor

Definition at line 136 of file import.cxx.

References cgv::utils::tokenizer::set_ws().

◆ stderr_message()

CGV_API void cgv::base::stderr_message ( const std::string &  text)

std::cerr based implementation of the message function for first argument to the user_feedback constructor

Definition at line 131 of file import.cxx.

◆ stdout_message()

CGV_API void cgv::base::stdout_message ( const std::string &  text)

std::cout based implementation of the message function for first argument to the user_feedback constructor

Definition at line 126 of file import.cxx.

◆ unload_plugin()

CGV_API bool cgv::base::unload_plugin ( void handle)

unload the plugin with the given handle

Definition at line 1454 of file register.cxx.

◆ unregister_all_objects()

void CGV_API cgv::base::unregister_all_objects ( )

unregister all existing objects to clean up

Definition at line 508 of file register.cxx.

◆ unregister_object()

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

Definition at line 617 of file register.cxx.

References is_registration_debugging_enabled(), and unregister_object().

Referenced by cgv::gui::help_menu_entry::on_register(), unregister_object(), and cgv::gui::base_provider_generator::unregister_object().

◆ update_info()

CommandType cgv::base::update_info ( command_info info_ptr,
CommandType  cmd,
cgv::utils::token args_tok_ptr = 0 
)

Definition at line 981 of file register.cxx.

Variable Documentation

◆ base

Definition at line 31 of file base.h.

◆ group

Definition at line 34 of file base.h.

◆ named

Definition at line 32 of file base.h.

◆ node

Definition at line 33 of file base.h.

◆ traverse_policy

Definition at line 12 of file action.h.