4 #ifndef YARP_THRIFT_GENERATOR_STRUCT_Box3D 5 #define YARP_THRIFT_GENERATOR_STRUCT_Box3D 7 #include <yarp/os/Wire.h> 8 #include <yarp/os/idl/WireTypes.h> 9 #include <iCub/data3D/PointXYZ.h> 10 #include <yarp/sig/Matrix.h> 19 class iCub::data3D::Box3D :
public yarp::os::idl::WirePortable {
22 std::vector<PointXYZ> corners;
23 yarp::sig::Matrix orientation;
30 Box3D(
const std::vector<PointXYZ> & corners,
const yarp::sig::Matrix& orientation) : corners(corners), orientation(orientation) {
34 Box3D(
const Box3D& __alt) : WirePortable(__alt) {
35 this->corners = __alt.corners;
36 this->orientation = __alt.orientation;
40 const Box3D& operator = (
const Box3D& __alt) {
41 this->corners = __alt.corners;
42 this->orientation = __alt.orientation;
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);
53 bool write_corners(yarp::os::idl::WireWriter& writer);
54 bool nested_write_corners(yarp::os::idl::WireWriter& writer);
55 bool write_orientation(yarp::os::idl::WireWriter& writer);
56 bool nested_write_orientation(yarp::os::idl::WireWriter& writer);
57 bool read_corners(yarp::os::idl::WireReader& reader);
58 bool nested_read_corners(yarp::os::idl::WireReader& reader);
59 bool read_orientation(yarp::os::idl::WireReader& reader);
60 bool nested_read_orientation(yarp::os::idl::WireReader& reader);
64 yarp::os::ConstString toString();
67 typedef yarp::os::idl::Unwrapped<iCub::data3D::Box3D > unwrapped;
69 class Editor :
public yarp::os::Wire,
public yarp::os::PortWriter {
77 yarp().setOwner(*
this);
84 yarp().setOwner(*
this);
87 bool edit(Box3D& obj,
bool dirty =
true) {
88 if (obj_owned)
delete this->obj;
96 if (obj_owned)
delete obj;
99 bool isValid()
const {
103 Box3D& state() {
return *obj; }
105 void begin() { group++; }
109 if (group==0&&is_dirty) communicate();
111 void set_corners(
const std::vector<PointXYZ> & corners) {
113 obj->corners = corners;
114 mark_dirty_corners();
118 void set_corners(
int index,
const PointXYZ& elem) {
120 obj->corners[index] = elem;
121 mark_dirty_corners();
125 void set_orientation(
const yarp::sig::Matrix& orientation) {
126 will_set_orientation();
127 obj->orientation = orientation;
128 mark_dirty_orientation();
130 did_set_orientation();
132 const std::vector<PointXYZ> & get_corners() {
135 const yarp::sig::Matrix& get_orientation() {
136 return obj->orientation;
138 virtual bool will_set_corners() {
return true; }
139 virtual bool will_set_orientation() {
return true; }
140 virtual bool did_set_corners() {
return true; }
141 virtual bool did_set_orientation() {
return true; }
145 bool read(yarp::os::ConnectionReader& connection);
146 bool write(yarp::os::ConnectionWriter& connection);
155 if (group!=0)
return;
156 if (yarp().canWrite()) {
164 void mark_dirty_corners() {
165 if (is_dirty_corners)
return;
167 is_dirty_corners =
true;
170 void mark_dirty_orientation() {
171 if (is_dirty_orientation)
return;
173 is_dirty_orientation =
true;
176 void dirty_flags(
bool flag) {
178 is_dirty_corners = flag;
179 is_dirty_orientation = flag;
180 dirty_count = flag ? 2 : 0;
184 bool is_dirty_corners;
185 bool is_dirty_orientation;