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);
28 void detach_from_reference();
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 }
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>
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
type independent &base class of all views
Definition view.h:13
virtual bool shows(const void *ptr) const =0
return whether the view edits the value pointed to by ptr
class for gui elements that view values of the type specified in the template argument
Definition view.h:45
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
data::ref_ptr< abst_view > view_ptr
ref counted pointer to abst view
Definition view.h:36
the cgv namespace
Definition print.h:11