cgv
Loading...
Searching...
No Matches
view.h
1#pragma once
2
3#include <cgv/base/node.h>
4#include <cgv/signal/bool_signal.h>
5
6#include "lib_begin.h"
7
8namespace cgv {
9 namespace gui {
10
12class CGV_API abst_view : public cgv::base::node
13{
14protected:
15 abst_view* next_in_list;
16 abst_view* prev_in_list;
17 const void* ptr;
18public:
20 abst_view(const std::string& name);
22 ~abst_view();
24 virtual bool shows(const void* ptr) const = 0;
26 void attach_to_reference(const void* ptr);
30 void update_views();
31};
32
33extern CGV_API void update_views(void* member_ptr);
34
37
38#if _MSC_VER >= 1400
39CGV_TEMPLATE template class CGV_API data::ref_ptr<abst_view>;
40#endif
41
43template <typename T>
44class view : public abst_view
45{
46protected:
47 const T* value_ptr;
48public:
50 view(const std::string& _name, const T& _value) : abst_view(_name), value_ptr(&_value) {
51 attach_to_reference(value_ptr);
52 }
53
54 const T& get_value() const { return *value_ptr; }
56 bool shows(const void* ptr) const { return value_ptr == ptr; }
57};
58
59 }
60}
61
62#include <cgv/config/lib_end.h>
std::string name
store the name as a string
Definition named.h:25
The node class keeps a pointer to its parent.
Definition node.h:19
reference counted pointer, which can work together with types that are derived from ref_counted,...
Definition ref_ptr.h:160
void detach_from_reference()
detach view again
Definition control.cxx:83
abst_view(const std::string &name)
pass name on to node, careful the implementation of this is in the source file control....
Definition control.cxx:8
void update_views()
calls the update method of all other attached views
Definition control.cxx:125
virtual bool shows(const void *ptr) const =0
return whether the view edits the value pointed to by ptr
void attach_to_reference(const void *ptr)
links all views to a reference into a doubly linked list in order to allow controls of the reference ...
Definition control.cxx:63
const T & get_value() const
return the current value
Definition view.h:54
bool shows(const void *ptr) const
check whether the value viewed by this element is pointing to the given pointer
Definition view.h:56
view(const std::string &_name, const T &_value)
construct abstract element from reference to value
Definition view.h:50
namespace that holds the abstract gui interface
Definition vr_calib.cxx:10
data::ref_ptr< abst_view > view_ptr
ref counted pointer to abst view
Definition view.h:36
this header is dependency free
Definition print.h:11