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

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...

#include <base.h>

Inheritance diagram for cgv::base::base:
cgv::data::ref_counted cgv::reflect::self_reflection_tag cgv::base::base_generator cgv::base::console cgv::base::factory cgv::base::named cgv::base::object_constructor cgv::base::test cgv::gui::base_provider cgv::gui::base_provider_generator cgv::gui::gui_driver cgv::gui::layout cgv::gui::trigger_server cgv::media::font::font cgv::media::font::font_face cgv::media::font::font_server cgv::media::image::abst_image_reader cgv::media::image::abst_image_writer cgv::media::image::image_reader cgv::media::image::image_writer cgv::media::image::reader_listener cgv::media::image::writer_listener cgv::media::video::abst_video_reader cgv::media::video::abst_video_writer cgv::media::video::video_reader cgv::media::video::video_reader_listener cgv::media::video::video_writer cgv::media::video::video_writer_listener cgv::render::render_config cgv::render::shader_config

Public Member Functions

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_type.
 
virtual std::string get_default_options () const
 overload to provide default options for registration
 
std::string get_name_or_type_name () const
 determine name of instance by checking cgv::base::named interface and in failure fallback to get_type_name()
 
virtual void on_register ()
 overload to handle register events that is sent after the instance has been registered
 
virtual void unregister ()
 overload to handle unregistration of instances
 
virtual bool on_exit_request ()
 overload to handle the appication exit request, return true if exiting is allowed and false otherwise
 
virtual void stream_stats (std::ostream &)
 overload to show the content of this object
 
virtual data::ref_ptr< named, trueget_named ()
 perform downcast to named
 
virtual data::ref_ptr< node, trueget_node ()
 perform downcast to node
 
virtual data::ref_ptr< group, trueget_group ()
 perform downcast to group
 
virtual data::ref_ptr< const named, trueget_named_const () const
 perform downcast to const named
 
virtual data::ref_ptr< const node, trueget_node_const () const
 perform downcast to const node
 
virtual data::ref_ptr< const group, trueget_group_const () const
 perform downcast to const group
 
template<class T >
data::ref_ptr< T, truecast ()
 cast to arbitrary class, but use the casts to named, node and group from the interface
 
template<class T >
data::ref_ptr< const T, truecast_const ()
 const cast to arbitrary class, but use the casts to named, node and group from the interface
 
template<class T >
Tget_interface ()
 use dynamic type cast to check for the given interface
 
template<class T >
const Tget_const_interface () const
 use dynamic type cast to check for the given interface
 
virtual void update ()
 this virtual update allows for example to ask a view to update the viewed value. The default implementation is empty.
 
virtual voidget_user_data () const
 this virtual method allows to pass application specific data for internal purposes
 
property interface
virtual bool self_reflect (cgv::reflect::reflection_handler &)
 used for simple self reflection
 
virtual std::string get_property_declarations ()
 return a semicolon separated list of property declarations
 
virtual bool set_void (const std::string &property, const std::string &value_type, const void *value_ptr)
 abstract interface for the setter of a dynamic property.
 
virtual void on_set (void *member_ptr)
 this callback is called when the set_void method has changed a member and can be overloaded in derived class
 
virtual bool get_void (const std::string &property, const std::string &value_type, void *value_ptr)
 abstract interface for the getter of a dynamic property.
 
virtual bool call_void (const std::string &method, const std::vector< std::string > &param_value_types, const std::vector< const void * > &param_value_ptrs, const std::string &result_type="", void *result_value_ptr=0)
 abstract interface to call an action
 
void set (const std::string &property, const char *value)
 specialization of set method to support const char* as strings
 
template<typename T >
void set (const std::string &property, const T &value)
 set a property of the element to the given value and perform standard conversions if necessary.
 
template<typename T >
T get (const std::string &property)
 query a property of the element and perform standard conversions if necessary.
 
void multi_set (const std::string &property_assignments, bool report_error=true)
 set several properties
 
bool is_property (const std::string &property_name, std::string *type_name=0)
 check if the given name specifies a property.
 
voidfind_member_ptr (const std::string &property_name, std::string *type_name=0)
 find a member pointer by name.
 
- Public Member Functions inherited from cgv::data::ref_counted
int get_ref_count () const
 read access to current count
 

Protected Member Functions

virtual ~base ()
 make destructor virtual and not accessible from outside
 
- Protected Member Functions inherited from cgv::data::ref_counted
 ref_counted ()
 constructor initializes the count to 0
 
void set_ref_count (int c) const
 write access is also const to allow ref counted pointers to const instances
 

Static Protected Member Functions

template<class T >
static data::ref_ptr< T, truecast_dynamic (base *b)
 use dynamic cast for upcast to given class
 

Friends

class data::ref_ptr_impl< base, true >
 give ref_ptr access to destructor
 
struct cast_helper_base
 give cast_helper_base access to cast_dynamic
 

Detailed Description

base class for all classes that can be registered with support for dynamic properties (see also section Base Hierarchy of page Namespace cgv::base).

Definition at line 74 of file base.h.

Constructor & Destructor Documentation

◆ ~base()

cgv::base::base::~base ( )
protectedvirtual

make destructor virtual and not accessible from outside

Definition at line 21 of file base.cxx.

Member Function Documentation

◆ call_void()

bool cgv::base::base::call_void ( const std::string &  method,
const std::vector< std::string > &  param_value_types,
const std::vector< const void * > &  param_value_ptrs,
const std::string &  result_type = "",
void result_value_ptr = 0 
)
virtual

abstract interface to call an action

overload to implement the execution of a method based on the method name and the given parameters

, i.e. a class method based on the action name and the given parameters. The default implementation uses the self_reflect() method to dispatch this call. If not found, the get_void method returns false.

Definition at line 168 of file base.cxx.

References self_reflect().

◆ cast()

template<class T >
data::ref_ptr< T, true > cgv::base::base::cast ( )
inline

cast to arbitrary class, but use the casts to named, node and group from the interface

Definition at line 118 of file base.h.

◆ cast_const()

template<class T >
data::ref_ptr< const T, true > cgv::base::base::cast_const ( )
inline

const cast to arbitrary class, but use the casts to named, node and group from the interface

Definition at line 123 of file base.h.

◆ cast_dynamic()

template<class T >
static data::ref_ptr< T, true > cgv::base::base::cast_dynamic ( base b)
inlinestaticprotected

use dynamic cast for upcast to given class

Definition at line 85 of file base.h.

◆ find_member_ptr()

void * cgv::base::base::find_member_ptr ( const std::string &  property_name,
std::string *  type_name = 0 
)

find a member pointer by name.

If not found the null pointer is returned. If the type name string pointer is provided, the type of the property is copied to the referenced string.

Definition at line 360 of file base.cxx.

References self_reflect().

Referenced by cgv::gui::event_handler::add_key_control().

◆ get()

template<typename T >
T cgv::base::base::get ( const std::string &  property)
inline

query a property of the element and perform standard conversions if necessary.

This templated version simply extracts the type of the value from the reference and calls the set_void() method. Note that this only works if the template cgv::type::info::type_name<T> is overloaded for the value type.

Definition at line 192 of file base.h.

◆ get_const_interface()

template<class T >
const T * cgv::base::base::get_const_interface ( ) const
inline

use dynamic type cast to check for the given interface

Definition at line 133 of file base.h.

◆ get_default_options()

std::string cgv::base::base::get_default_options ( ) const
virtual

overload to provide default options for registration

Definition at line 250 of file base.cxx.

◆ get_group()

data::ref_ptr< group, true > cgv::base::base::get_group ( )
virtual

perform downcast to group

Reimplemented in cgv::base::group.

Definition at line 45 of file base.cxx.

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

◆ get_group_const()

data::ref_ptr< const group, true > cgv::base::base::get_group_const ( ) const
virtual

perform downcast to const group

Definition at line 57 of file base.cxx.

◆ get_interface()

template<class T >
T * cgv::base::base::get_interface ( )
inline

◆ get_name_or_type_name()

std::string cgv::base::base::get_name_or_type_name ( ) const

determine name of instance by checking cgv::base::named interface and in failure fallback to get_type_name()

Definition at line 255 of file base.cxx.

References get_named_const(), and get_type_name().

◆ get_named()

data::ref_ptr< named, true > cgv::base::base::get_named ( )
virtual

perform downcast to named

Reimplemented in cgv::base::named, and cgv::gui::base_provider.

Definition at line 37 of file base.cxx.

Referenced by cgv::gui::provider::get_gui_name(), and cgv::gui::base_provider::get_named().

◆ get_named_const()

data::ref_ptr< const named, true > cgv::base::base::get_named_const ( ) const
virtual

perform downcast to const named

Definition at line 49 of file base.cxx.

Referenced by get_name_or_type_name().

◆ get_node()

data::ref_ptr< node, true > cgv::base::base::get_node ( )
virtual

perform downcast to node

Reimplemented in cgv::base::node.

Definition at line 41 of file base.cxx.

◆ get_node_const()

data::ref_ptr< const node, true > cgv::base::base::get_node_const ( ) const
virtual

perform downcast to const node

Definition at line 53 of file base.cxx.

◆ get_property_declarations()

std::string cgv::base::base::get_property_declarations ( )
virtual

return a semicolon separated list of property declarations

return a semicolon separated list of property declarations of the form "name:type", by default an empty list is returned

of the form "name1:type1;name2:type2;...", by default an empty list is returned. The types should by consistent with the names returned by cgv::type::info::type_name::get_name. The default implementation extracts names and types from the self_reflect() method and the meta type information provided by the get_type() method.

Reimplemented in cgv::base::base_generator, cgv::base::console, cgv::base::factory, cgv::gui::key_control< T >, cgv::gui::key_control< bool >, cgv::gui::layout, cgv::gui::layout_table, cgv::media::image::image_reader, cgv::media::image::image_writer, cgv::media::video::video_reader, and cgv::media::video::video_writer.

Definition at line 264 of file base.cxx.

References self_reflect().

Referenced by cgv::gui::key_control< T >::get_property_declarations(), cgv::media::image::image_reader::get_property_declarations(), cgv::media::image::image_writer::get_property_declarations(), cgv::media::video::video_reader::get_property_declarations(), cgv::media::video::video_writer::get_property_declarations(), and is_property().

◆ get_type_name()

std::string cgv::base::base::get_type_name ( ) const
virtual

overload to return the type name of this object. By default the type interface is queried over get_type.

overload to return the type name of this object

Reimplemented in cgv::base::base_generator, cgv::base::console, cgv::base::group, cgv::base::named, cgv::base::node, cgv::base::object_constructor, cgv::base::object_constructor_impl< T >, cgv::base::object_constructor_impl_1< T, CA >, cgv::base::object_constructor_impl_2< T, CA1, CA2 >, cgv::base::factory_impl< T >, cgv::base::factory_impl_1< T, CA >, cgv::base::factory_impl_2< T, CA1, CA2 >, cgv::base::test, cgv::gui::base_provider, cgv::gui::base_provider_generator, cgv::gui::button, cgv::gui::gui_group, cgv::gui::key_control< T >, cgv::gui::key_control< bool >, cgv::gui::window, cgv::media::font::font_face, cgv::media::font::font, cgv::media::image::bmp_reader, cgv::media::image::bmp_writer, cgv::media::image::reader_listener, cgv::media::image::image_reader, cgv::media::image::writer_listener, cgv::media::image::image_writer, cgv::media::video::video_reader_listener, cgv::media::video::video_reader, cgv::media::video::video_writer_listener, cgv::media::video::video_writer, cgv::render::render_config, cgv::render::shader_config, cgv::app::navigator, vr_emulator, cgv::app::color_map_editor, cgv::app::color_map_legend, cgv::app::color_selector, cgv::app::gizmo, cgv::app::performance_monitor, and cgv::app::transformation_gizmo.

Definition at line 241 of file base.cxx.

References cgv::type::info::type_name< T >::get_name().

Referenced by cgv::gui::provider::get_gui_name(), get_name_or_type_name(), cgv::gui::base_provider::get_type_name(), cgv::media::image::image_reader::get_type_name(), cgv::media::image::image_writer::get_type_name(), cgv::media::video::video_reader::get_type_name(), and cgv::media::video::video_writer::get_type_name().

◆ get_user_data()

void * cgv::base::base::get_user_data ( ) const
virtual

this virtual method allows to pass application specific data for internal purposes

Reimplemented in config_view< T >, config_view< std::string >, config_view< bool >, and enum_config_view.

Definition at line 64 of file base.cxx.

◆ get_void()

bool cgv::base::base::get_void ( const std::string &  property,
const std::string &  value_type,
void value_ptr 
)
virtual

abstract interface for the getter of a dynamic property.

abstract interface for the getter, by default it simply returns false

The default implementation uses the self_reflect() method to find a member with the given property as name. If not found, the get_void method returns false.

Reimplemented in cgv::media::image::image_reader, cgv::media::image::image_writer, cgv::media::video::video_reader, cgv::media::video::video_writer, cgv::base::base_generator, cgv::base::console, cgv::base::factory, cgv::gui::key_control< T >, cgv::gui::key_control< bool >, cgv::gui::layout, and cgv::gui::layout_table.

Definition at line 215 of file base.cxx.

References self_reflect().

Referenced by cgv::media::image::image_reader::get_void(), cgv::media::image::image_writer::get_void(), cgv::media::video::video_reader::get_void(), cgv::media::video::video_writer::get_void(), cgv::gui::key_control< T >::get_void(), and cgv::gui::key_control< bool >::get_void().

◆ is_property()

bool cgv::base::base::is_property ( const std::string &  property_name,
std::string *  type_name = 0 
)

check if the given name specifies a property.

If the type name string pointer is provided, the type of the property is copied to the referenced string.

Definition at line 336 of file base.cxx.

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

◆ multi_set()

void cgv::base::base::multi_set ( const std::string &  property_assignments,
bool  report_error = true 
)

set several properties

set several properties, which are defined as colon separated assignments, where the types are derived automatically

, which are defined as colon separated assignments, where the types are derived automatically to bool, int, double or std::string.

Definition at line 287 of file base.cxx.

References cgv::utils::bite_all(), cgv::utils::is_digit(), cgv::utils::is_integer(), set_void(), and cgv::utils::to_string().

Referenced by cgv::render::texture::write_to_file().

◆ on_exit_request()

bool cgv::base::base::on_exit_request ( )
virtual

overload to handle the appication exit request, return true if exiting is allowed and false otherwise

Definition at line 33 of file base.cxx.

◆ on_register()

void cgv::base::base::on_register ( )
virtual

overload to handle register events that is sent after the instance has been registered

Reimplemented in cgv::gui::help_menu_entry.

Definition at line 27 of file base.cxx.

◆ on_set()

void cgv::base::base::on_set ( void member_ptr)
virtual

this callback is called when the set_void method has changed a member and can be overloaded in derived class

Reimplemented in cgv::gui::base_provider_generator, cgv::gui::key_control< T >, cgv::app::navigator, cgv::app::overlay, vr_test, vr_emulator, and cgv::app::canvas_overlay.

Definition at line 210 of file base.cxx.

Referenced by cgv::gui::event_handler::add_key_control(), cgv::gui::provider::add_member_control(), cgv::gui::provider::begin_tree_node_void(), and set_void().

◆ self_reflect()

bool cgv::base::base::self_reflect ( cgv::reflect::reflection_handler )
virtual

used for simple self reflection

is used by default implementation of set_void, get_void and get_property_declarations

The overloaded implementation is used by the default implementations of set_void, get_void and get_property_declarations with corresponding reflection handlers. The default implementation of self_reflect is empty.

Reimplemented in cgv::app::navigator, cgv::app::overlay, cgv::gui::base_provider, cgv::gui::base_provider_generator, cgv::gui::key_control< T >, cgv::render::render_config, cgv::render::shader_config, and vr_emulator.

Definition at line 161 of file base.cxx.

Referenced by call_void(), find_member_ptr(), get_property_declarations(), get_void(), gui_config_file_observer::multi_observe(), and set_void().

◆ set() [1/2]

void cgv::base::base::set ( const std::string &  property,
const char value 
)
inline

specialization of set method to support const char* as strings

Definition at line 180 of file base.h.

◆ set() [2/2]

template<typename T >
void cgv::base::base::set ( const std::string &  property,
const T value 
)
inline

set a property of the element to the given value and perform standard conversions if necessary.

This templated version simply extracts the type of the value from the reference and calls the set_void() method. Note that this only works if the template cgv::type::info::type_name<T> is overloaded for the value type.

Definition at line 186 of file base.h.

◆ set_void()

bool cgv::base::base::set_void ( const std::string &  property,
const std::string &  value_type,
const void value_ptr 
)
virtual

abstract interface for the setter of a dynamic property.

abstract interface for the setter, by default it simply returns false

The default implementation uses the self_reflect() method to find a member with the given property as name. If not found, the set_void method returns false.

Reimplemented in cgv::media::image::image_reader, cgv::media::image::image_writer, cgv::media::video::video_reader, cgv::media::video::video_writer, cgv::base::base_generator, cgv::base::console, cgv::base::factory, cgv::gui::key_control< T >, cgv::gui::key_control< bool >, cgv::gui::layout, and cgv::gui::layout_table.

Definition at line 181 of file base.cxx.

References on_set(), and self_reflect().

Referenced by gui_config_file_observer::multi_observe(), multi_set(), cgv::media::image::image_reader::set_void(), cgv::media::image::image_writer::set_void(), cgv::media::video::video_reader::set_void(), cgv::media::video::video_writer::set_void(), and cgv::gui::key_control< T >::set_void().

◆ stream_stats()

void cgv::base::base::stream_stats ( std::ostream &  )
virtual

overload to show the content of this object

Reimplemented in vr_emulator.

Definition at line 24 of file base.cxx.

◆ unregister()

void cgv::base::base::unregister ( )
virtual

overload to handle unregistration of instances

Reimplemented in cgv::gui::help_menu_entry.

Definition at line 30 of file base.cxx.

◆ update()

void cgv::base::base::update ( )
virtual

this virtual update allows for example to ask a view to update the viewed value. The default implementation is empty.

Reimplemented in config_view< T >, config_view< std::string >, config_view< bool >, enum_config_view, cgv::gui::layout, cgv::gui::layout_inline, and cgv::gui::layout_table.

Definition at line 61 of file base.cxx.

Referenced by cgv::gui::abst_view::update_views().

Friends And Related Symbol Documentation

◆ cast_helper_base

give cast_helper_base access to cast_dynamic

Definition at line 82 of file base.h.

◆ data::ref_ptr_impl< base, true >

give ref_ptr access to destructor

Definition at line 66 of file base.h.


The documentation for this class was generated from the following files: