cgv
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 
8 namespace cgv {
9  namespace gui {
10 
12 class CGV_API abst_view : public cgv::base::node
13 {
14 protected:
15  abst_view* next_in_list;
16  abst_view* prev_in_list;
17  const void* ptr;
18 public:
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 
33 extern CGV_API void update_views(void* member_ptr);
34 
37 
38 #if _MSC_VER >= 1400
39 CGV_TEMPLATE template class CGV_API data::ref_ptr<abst_view>;
40 #endif
41 
43 template <typename T>
44 class view : public abst_view
45 {
46 protected:
47  const T* value_ptr;
48 public:
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>
cgv::gui::abst_view::shows
virtual bool shows(const void *ptr) const =0
return whether the view edits the value pointed to by ptr
cgv::data::ref_ptr
Definition: ref_ptr.h:19
cgv::gui::view::shows
bool shows(const void *ptr) const
check whether the value viewed by this element is pointing to the given pointer
Definition: view.h:56
cgv::gui::view
class for gui elements that view values of the type specified in the template argument
Definition: view.h:45
cgv::gui::view_ptr
data::ref_ptr< abst_view > view_ptr
ref counted pointer to abst view
Definition: view.h:36
cgv::gui::abst_view
type independent &base class of all views
Definition: view.h:13
cgv
the cgv namespace
Definition: vr_calib.cxx:9
cgv::gui::view::get_value
const T & get_value() const
return the current value
Definition: view.h:54
cgv::base::node
Definition: node.h:17
cgv::gui::view::view
view(const std::string &_name, const T &_value)
construct abstract element from reference to value
Definition: view.h:50