grasp
All Data Structures Namespaces Functions Modules
PointXYZ.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_PointXYZ
5 #define YARP_THRIFT_GENERATOR_STRUCT_PointXYZ
6 
7 #include <yarp/os/Wire.h>
8 #include <yarp/os/idl/WireTypes.h>
9 
10 namespace iCub {
11  namespace data3D {
12  class PointXYZ;
13  }
14 }
15 
16 
17 class iCub::data3D::PointXYZ : public yarp::os::idl::WirePortable {
18 public:
19  // Fields
20  double x;
21  double y;
22  double z;
23 
24  // Default constructor
25  PointXYZ() : x(0), y(0), z(0) {
26  }
27 
28  // Constructor with field values
29  PointXYZ(const double x,const double y,const double z) : x(x), y(y), z(z) {
30  }
31 
32  // Copy constructor
33  PointXYZ(const PointXYZ& __alt) : WirePortable(__alt) {
34  this->x = __alt.x;
35  this->y = __alt.y;
36  this->z = __alt.z;
37  }
38 
39  // Assignment operator
40  const PointXYZ& operator = (const PointXYZ& __alt) {
41  this->x = __alt.x;
42  this->y = __alt.y;
43  this->z = __alt.z;
44  return *this;
45  }
46 
47  // read and write structure on a connection
48  bool read(yarp::os::idl::WireReader& reader);
49  bool read(yarp::os::ConnectionReader& connection);
50  bool write(yarp::os::idl::WireWriter& writer);
51  bool write(yarp::os::ConnectionWriter& connection);
52 
53 private:
54  bool write_x(yarp::os::idl::WireWriter& writer);
55  bool nested_write_x(yarp::os::idl::WireWriter& writer);
56  bool write_y(yarp::os::idl::WireWriter& writer);
57  bool nested_write_y(yarp::os::idl::WireWriter& writer);
58  bool write_z(yarp::os::idl::WireWriter& writer);
59  bool nested_write_z(yarp::os::idl::WireWriter& writer);
60  bool read_x(yarp::os::idl::WireReader& reader);
61  bool nested_read_x(yarp::os::idl::WireReader& reader);
62  bool read_y(yarp::os::idl::WireReader& reader);
63  bool nested_read_y(yarp::os::idl::WireReader& reader);
64  bool read_z(yarp::os::idl::WireReader& reader);
65  bool nested_read_z(yarp::os::idl::WireReader& reader);
66 
67 public:
68 
69  yarp::os::ConstString toString();
70 
71  // if you want to serialize this class without nesting, use this helper
72  typedef yarp::os::idl::Unwrapped<iCub::data3D::PointXYZ > unwrapped;
73 
74  class Editor : public yarp::os::Wire, public yarp::os::PortWriter {
75  public:
76 
77  Editor() {
78  group = 0;
79  obj_owned = true;
80  obj = new PointXYZ;
81  dirty_flags(false);
82  yarp().setOwner(*this);
83  }
84 
85  Editor(PointXYZ& obj) {
86  group = 0;
87  obj_owned = false;
88  edit(obj,false);
89  yarp().setOwner(*this);
90  }
91 
92  bool edit(PointXYZ& obj, bool dirty = true) {
93  if (obj_owned) delete this->obj;
94  this->obj = &obj;
95  obj_owned = false;
96  dirty_flags(dirty);
97  return true;
98  }
99 
100  virtual ~Editor() {
101  if (obj_owned) delete obj;
102  }
103 
104  bool isValid() const {
105  return obj!=0/*NULL*/;
106  }
107 
108  PointXYZ& state() { return *obj; }
109 
110  void begin() { group++; }
111 
112  void end() {
113  group--;
114  if (group==0&&is_dirty) communicate();
115  }
116  void set_x(const double x) {
117  will_set_x();
118  obj->x = x;
119  mark_dirty_x();
120  communicate();
121  did_set_x();
122  }
123  void set_y(const double y) {
124  will_set_y();
125  obj->y = y;
126  mark_dirty_y();
127  communicate();
128  did_set_y();
129  }
130  void set_z(const double z) {
131  will_set_z();
132  obj->z = z;
133  mark_dirty_z();
134  communicate();
135  did_set_z();
136  }
137  double get_x() {
138  return obj->x;
139  }
140  double get_y() {
141  return obj->y;
142  }
143  double get_z() {
144  return obj->z;
145  }
146  virtual bool will_set_x() { return true; }
147  virtual bool will_set_y() { return true; }
148  virtual bool will_set_z() { return true; }
149  virtual bool did_set_x() { return true; }
150  virtual bool did_set_y() { return true; }
151  virtual bool did_set_z() { return true; }
152  void clean() {
153  dirty_flags(false);
154  }
155  bool read(yarp::os::ConnectionReader& connection);
156  bool write(yarp::os::ConnectionWriter& connection);
157  private:
158 
159  PointXYZ *obj;
160 
161  bool obj_owned;
162  int group;
163 
164  void communicate() {
165  if (group!=0) return;
166  if (yarp().canWrite()) {
167  yarp().write(*this);
168  clean();
169  }
170  }
171  void mark_dirty() {
172  is_dirty = true;
173  }
174  void mark_dirty_x() {
175  if (is_dirty_x) return;
176  dirty_count++;
177  is_dirty_x = true;
178  mark_dirty();
179  }
180  void mark_dirty_y() {
181  if (is_dirty_y) return;
182  dirty_count++;
183  is_dirty_y = true;
184  mark_dirty();
185  }
186  void mark_dirty_z() {
187  if (is_dirty_z) return;
188  dirty_count++;
189  is_dirty_z = true;
190  mark_dirty();
191  }
192  void dirty_flags(bool flag) {
193  is_dirty = flag;
194  is_dirty_x = flag;
195  is_dirty_y = flag;
196  is_dirty_z = flag;
197  dirty_count = flag ? 3 : 0;
198  }
199  bool is_dirty;
200  int dirty_count;
201  bool is_dirty_x;
202  bool is_dirty_y;
203  bool is_dirty_z;
204  };
205 };
206 
207 #endif
208