grasp
All Data Structures Namespaces Functions Modules
RGBA.h
1 // This is an automatically-generated file.
2 // It could get re-generated if the ALLOW_IDL_GENERATION flag is on.
3 
4 #ifndef YARP_THRIFT_GENERATOR_STRUCT_RGBA
5 #define YARP_THRIFT_GENERATOR_STRUCT_RGBA
6 
7 #include <yarp/os/Wire.h>
8 #include <yarp/os/idl/WireTypes.h>
9 
10 namespace iCub {
11  namespace data3D {
12  class RGBA;
13  }
14 }
15 
16 
17 class iCub::data3D::RGBA : public yarp::os::idl::WirePortable {
18 public:
19  // Fields
20  int32_t rgba;
21 
22  // Default constructor
23  RGBA() : rgba(0) {
24  }
25 
26  // Constructor with field values
27  RGBA(const int32_t rgba) : rgba(rgba) {
28  }
29 
30  // Copy constructor
31  RGBA(const RGBA& __alt) : WirePortable(__alt) {
32  this->rgba = __alt.rgba;
33  }
34 
35  // Assignment operator
36  const RGBA& operator = (const RGBA& __alt) {
37  this->rgba = __alt.rgba;
38  return *this;
39  }
40 
41  // read and write structure on a connection
42  bool read(yarp::os::idl::WireReader& reader);
43  bool read(yarp::os::ConnectionReader& connection);
44  bool write(yarp::os::idl::WireWriter& writer);
45  bool write(yarp::os::ConnectionWriter& connection);
46 
47 private:
48  bool write_rgba(yarp::os::idl::WireWriter& writer);
49  bool nested_write_rgba(yarp::os::idl::WireWriter& writer);
50  bool read_rgba(yarp::os::idl::WireReader& reader);
51  bool nested_read_rgba(yarp::os::idl::WireReader& reader);
52 
53 public:
54 
55  yarp::os::ConstString toString();
56 
57  // if you want to serialize this class without nesting, use this helper
58  typedef yarp::os::idl::Unwrapped<iCub::data3D::RGBA > unwrapped;
59 
60  class Editor : public yarp::os::Wire, public yarp::os::PortWriter {
61  public:
62 
63  Editor() {
64  group = 0;
65  obj_owned = true;
66  obj = new RGBA;
67  dirty_flags(false);
68  yarp().setOwner(*this);
69  }
70 
71  Editor(RGBA& obj) {
72  group = 0;
73  obj_owned = false;
74  edit(obj,false);
75  yarp().setOwner(*this);
76  }
77 
78  bool edit(RGBA& obj, bool dirty = true) {
79  if (obj_owned) delete this->obj;
80  this->obj = &obj;
81  obj_owned = false;
82  dirty_flags(dirty);
83  return true;
84  }
85 
86  virtual ~Editor() {
87  if (obj_owned) delete obj;
88  }
89 
90  bool isValid() const {
91  return obj!=0/*NULL*/;
92  }
93 
94  RGBA& state() { return *obj; }
95 
96  void begin() { group++; }
97 
98  void end() {
99  group--;
100  if (group==0&&is_dirty) communicate();
101  }
102  void set_rgba(const int32_t rgba) {
103  will_set_rgba();
104  obj->rgba = rgba;
105  mark_dirty_rgba();
106  communicate();
107  did_set_rgba();
108  }
109  int32_t get_rgba() {
110  return obj->rgba;
111  }
112  virtual bool will_set_rgba() { return true; }
113  virtual bool did_set_rgba() { return true; }
114  void clean() {
115  dirty_flags(false);
116  }
117  bool read(yarp::os::ConnectionReader& connection);
118  bool write(yarp::os::ConnectionWriter& connection);
119  private:
120 
121  RGBA *obj;
122 
123  bool obj_owned;
124  int group;
125 
126  void communicate() {
127  if (group!=0) return;
128  if (yarp().canWrite()) {
129  yarp().write(*this);
130  clean();
131  }
132  }
133  void mark_dirty() {
134  is_dirty = true;
135  }
136  void mark_dirty_rgba() {
137  if (is_dirty_rgba) return;
138  dirty_count++;
139  is_dirty_rgba = true;
140  mark_dirty();
141  }
142  void dirty_flags(bool flag) {
143  is_dirty = flag;
144  is_dirty_rgba = flag;
145  dirty_count = flag ? 1 : 0;
146  }
147  bool is_dirty;
148  int dirty_count;
149  bool is_dirty_rgba;
150  };
151 };
152 
153 #endif
154