grasp
All Data Structures Namespaces Functions Modules
SurfaceMeshWithBoundingBox.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_SurfaceMeshWithBoundingBox
5 #define YARP_THRIFT_GENERATOR_STRUCT_SurfaceMeshWithBoundingBox
6 
7 #include <yarp/os/Wire.h>
8 #include <yarp/os/idl/WireTypes.h>
9 #include <iCub/data3D/Box3D.h>
10 #include <iCub/data3D/SurfaceMesh.h>
11 
12 namespace iCub {
13  namespace data3D {
14  class SurfaceMeshWithBoundingBox;
15  }
16 }
17 
18 
19 class iCub::data3D::SurfaceMeshWithBoundingBox : public yarp::os::idl::WirePortable {
20 public:
21  // Fields
22  SurfaceMesh mesh;
23  Box3D boundingBox;
24 
25  // Default constructor
26  SurfaceMeshWithBoundingBox() {
27  }
28 
29  // Constructor with field values
30  SurfaceMeshWithBoundingBox(const SurfaceMesh& mesh,const Box3D& boundingBox) : mesh(mesh), boundingBox(boundingBox) {
31  }
32 
33  // Copy constructor
34  SurfaceMeshWithBoundingBox(const SurfaceMeshWithBoundingBox& __alt) : WirePortable(__alt) {
35  this->mesh = __alt.mesh;
36  this->boundingBox = __alt.boundingBox;
37  }
38 
39  // Assignment operator
40  const SurfaceMeshWithBoundingBox& operator = (const SurfaceMeshWithBoundingBox& __alt) {
41  this->mesh = __alt.mesh;
42  this->boundingBox = __alt.boundingBox;
43  return *this;
44  }
45 
46  // read and write structure on a connection
47  bool read(yarp::os::idl::WireReader& reader);
48  bool read(yarp::os::ConnectionReader& connection);
49  bool write(yarp::os::idl::WireWriter& writer);
50  bool write(yarp::os::ConnectionWriter& connection);
51 
52 private:
53  bool write_mesh(yarp::os::idl::WireWriter& writer);
54  bool nested_write_mesh(yarp::os::idl::WireWriter& writer);
55  bool write_boundingBox(yarp::os::idl::WireWriter& writer);
56  bool nested_write_boundingBox(yarp::os::idl::WireWriter& writer);
57  bool read_mesh(yarp::os::idl::WireReader& reader);
58  bool nested_read_mesh(yarp::os::idl::WireReader& reader);
59  bool read_boundingBox(yarp::os::idl::WireReader& reader);
60  bool nested_read_boundingBox(yarp::os::idl::WireReader& reader);
61 
62 public:
63 
64  yarp::os::ConstString toString();
65 
66  // if you want to serialize this class without nesting, use this helper
67  typedef yarp::os::idl::Unwrapped<iCub::data3D::SurfaceMeshWithBoundingBox > unwrapped;
68 
69  class Editor : public yarp::os::Wire, public yarp::os::PortWriter {
70  public:
71 
72  Editor() {
73  group = 0;
74  obj_owned = true;
75  obj = new SurfaceMeshWithBoundingBox;
76  dirty_flags(false);
77  yarp().setOwner(*this);
78  }
79 
80  Editor(SurfaceMeshWithBoundingBox& obj) {
81  group = 0;
82  obj_owned = false;
83  edit(obj,false);
84  yarp().setOwner(*this);
85  }
86 
87  bool edit(SurfaceMeshWithBoundingBox& obj, bool dirty = true) {
88  if (obj_owned) delete this->obj;
89  this->obj = &obj;
90  obj_owned = false;
91  dirty_flags(dirty);
92  return true;
93  }
94 
95  virtual ~Editor() {
96  if (obj_owned) delete obj;
97  }
98 
99  bool isValid() const {
100  return obj!=0/*NULL*/;
101  }
102 
103  SurfaceMeshWithBoundingBox& state() { return *obj; }
104 
105  void begin() { group++; }
106 
107  void end() {
108  group--;
109  if (group==0&&is_dirty) communicate();
110  }
111  void set_mesh(const SurfaceMesh& mesh) {
112  will_set_mesh();
113  obj->mesh = mesh;
114  mark_dirty_mesh();
115  communicate();
116  did_set_mesh();
117  }
118  void set_boundingBox(const Box3D& boundingBox) {
119  will_set_boundingBox();
120  obj->boundingBox = boundingBox;
121  mark_dirty_boundingBox();
122  communicate();
123  did_set_boundingBox();
124  }
125  const SurfaceMesh& get_mesh() {
126  return obj->mesh;
127  }
128  const Box3D& get_boundingBox() {
129  return obj->boundingBox;
130  }
131  virtual bool will_set_mesh() { return true; }
132  virtual bool will_set_boundingBox() { return true; }
133  virtual bool did_set_mesh() { return true; }
134  virtual bool did_set_boundingBox() { return true; }
135  void clean() {
136  dirty_flags(false);
137  }
138  bool read(yarp::os::ConnectionReader& connection);
139  bool write(yarp::os::ConnectionWriter& connection);
140  private:
141 
142  SurfaceMeshWithBoundingBox *obj;
143 
144  bool obj_owned;
145  int group;
146 
147  void communicate() {
148  if (group!=0) return;
149  if (yarp().canWrite()) {
150  yarp().write(*this);
151  clean();
152  }
153  }
154  void mark_dirty() {
155  is_dirty = true;
156  }
157  void mark_dirty_mesh() {
158  if (is_dirty_mesh) return;
159  dirty_count++;
160  is_dirty_mesh = true;
161  mark_dirty();
162  }
163  void mark_dirty_boundingBox() {
164  if (is_dirty_boundingBox) return;
165  dirty_count++;
166  is_dirty_boundingBox = true;
167  mark_dirty();
168  }
169  void dirty_flags(bool flag) {
170  is_dirty = flag;
171  is_dirty_mesh = flag;
172  is_dirty_boundingBox = flag;
173  dirty_count = flag ? 2 : 0;
174  }
175  bool is_dirty;
176  int dirty_count;
177  bool is_dirty_mesh;
178  bool is_dirty_boundingBox;
179  };
180 };
181 
182 #endif
183