Skip to content

Commit 40e14bc

Browse files
Simplify the type erasure poly
1 parent e5f06eb commit 40e14bc

File tree

6 files changed

+42
-36
lines changed

6 files changed

+42
-36
lines changed

tesseract_command_language/include/tesseract_command_language/poly/cartesian_waypoint_poly.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -48,20 +48,16 @@ TESSERACT_COMMON_IGNORE_WARNINGS_POP
4848
using C##InstanceBase = tesseract_common:: \
4949
TypeErasureInstance<C, tesseract_planning::detail_cartesian_waypoint::CartesianWaypointInterface>; \
5050
using C##Instance = tesseract_planning::detail_cartesian_waypoint::CartesianWaypointInstance<C>; \
51-
using C##InstanceWrapper = tesseract_common::TypeErasureInstanceWrapper<C##Instance>; \
5251
} \
5352
BOOST_CLASS_EXPORT_KEY(N::C##InstanceBase) \
5453
BOOST_CLASS_EXPORT_KEY(N::C##Instance) \
55-
BOOST_CLASS_EXPORT_KEY(N::C##InstanceWrapper) \
5654
BOOST_CLASS_TRACKING(N::C##InstanceBase, boost::serialization::track_never) \
57-
BOOST_CLASS_TRACKING(N::C##Instance, boost::serialization::track_never) \
58-
BOOST_CLASS_TRACKING(N::C##InstanceWrapper, boost::serialization::track_never)
55+
BOOST_CLASS_TRACKING(N::C##Instance, boost::serialization::track_never)
5956

6057
/** @brief If shared library, this must go in the cpp after the implicit instantiation of the serialize function */
6158
#define TESSERACT_CARTESIAN_WAYPOINT_EXPORT_IMPLEMENT(inst) \
6259
BOOST_CLASS_EXPORT_IMPLEMENT(inst##InstanceBase) \
63-
BOOST_CLASS_EXPORT_IMPLEMENT(inst##Instance) \
64-
BOOST_CLASS_EXPORT_IMPLEMENT(inst##InstanceWrapper)
60+
BOOST_CLASS_EXPORT_IMPLEMENT(inst##Instance)
6561

6662
/**
6763
* @brief This should not be used within shared libraries use the two above.
@@ -194,6 +190,11 @@ struct CartesianWaypointInstance : tesseract_common::TypeErasureInstance<T, Cart
194190
const std::string& getName() const final { return this->get().getName(); }
195191
void print(const std::string& prefix) const final { this->get().print(prefix); }
196192

193+
std::unique_ptr<tesseract_common::TypeErasureInterface> clone() const final
194+
{
195+
return std::make_unique<CartesianWaypointInstance<T>>(this->get());
196+
}
197+
197198
private:
198199
friend class boost::serialization::access;
199200
friend struct tesseract_common::Serialization;

tesseract_command_language/include/tesseract_command_language/poly/instruction_poly.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,16 @@ struct uuid;
5151
using C##InstanceBase = \
5252
tesseract_common::TypeErasureInstance<C, tesseract_planning::detail_instruction::InstructionInterface>; \
5353
using C##Instance = tesseract_planning::detail_instruction::InstructionInstance<C>; \
54-
using C##InstanceWrapper = tesseract_common::TypeErasureInstanceWrapper<C##Instance>; \
5554
} \
5655
BOOST_CLASS_EXPORT_KEY(N::C##InstanceBase) \
5756
BOOST_CLASS_EXPORT_KEY(N::C##Instance) \
58-
BOOST_CLASS_EXPORT_KEY(N::C##InstanceWrapper) \
5957
BOOST_CLASS_TRACKING(N::C##InstanceBase, boost::serialization::track_never) \
60-
BOOST_CLASS_TRACKING(N::C##Instance, boost::serialization::track_never) \
61-
BOOST_CLASS_TRACKING(N::C##InstanceWrapper, boost::serialization::track_never)
58+
BOOST_CLASS_TRACKING(N::C##Instance, boost::serialization::track_never)
6259

6360
/** @brief If shared library, this must go in the cpp after the implicit instantiation of the serialize function */
6461
#define TESSERACT_INSTRUCTION_EXPORT_IMPLEMENT(inst) \
6562
BOOST_CLASS_EXPORT_IMPLEMENT(inst##InstanceBase) \
66-
BOOST_CLASS_EXPORT_IMPLEMENT(inst##Instance) \
67-
BOOST_CLASS_EXPORT_IMPLEMENT(inst##InstanceWrapper)
63+
BOOST_CLASS_EXPORT_IMPLEMENT(inst##Instance)
6864

6965
/**
7066
* @brief This should not be used within shared libraries use the two above.
@@ -158,6 +154,11 @@ struct InstructionInstance : tesseract_common::TypeErasureInstance<T, Instructio
158154

159155
void print(const std::string& prefix) const final { this->get().print(prefix); }
160156

157+
std::unique_ptr<tesseract_common::TypeErasureInterface> clone() const final
158+
{
159+
return std::make_unique<InstructionInstance<T>>(this->get()); // Creates a copy of this object
160+
}
161+
161162
private:
162163
friend class boost::serialization::access;
163164
friend struct tesseract_common::Serialization;

tesseract_command_language/include/tesseract_command_language/poly/joint_waypoint_poly.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,20 +47,16 @@ TESSERACT_COMMON_IGNORE_WARNINGS_POP
4747
using C##InstanceBase = \
4848
tesseract_common::TypeErasureInstance<C, tesseract_planning::detail_joint_waypoint::JointWaypointInterface>; \
4949
using C##Instance = tesseract_planning::detail_joint_waypoint::JointWaypointInstance<C>; \
50-
using C##InstanceWrapper = tesseract_common::TypeErasureInstanceWrapper<C##Instance>; \
5150
} \
5251
BOOST_CLASS_EXPORT_KEY(N::C##InstanceBase) \
5352
BOOST_CLASS_EXPORT_KEY(N::C##Instance) \
54-
BOOST_CLASS_EXPORT_KEY(N::C##InstanceWrapper) \
5553
BOOST_CLASS_TRACKING(N::C##InstanceBase, boost::serialization::track_never) \
56-
BOOST_CLASS_TRACKING(N::C##Instance, boost::serialization::track_never) \
57-
BOOST_CLASS_TRACKING(N::C##InstanceWrapper, boost::serialization::track_never)
54+
BOOST_CLASS_TRACKING(N::C##Instance, boost::serialization::track_never)
5855

5956
/** @brief If shared library, this must go in the cpp after the implicit instantiation of the serialize function */
6057
#define TESSERACT_JOINT_WAYPOINT_EXPORT_IMPLEMENT(inst) \
6158
BOOST_CLASS_EXPORT_IMPLEMENT(inst##InstanceBase) \
62-
BOOST_CLASS_EXPORT_IMPLEMENT(inst##Instance) \
63-
BOOST_CLASS_EXPORT_IMPLEMENT(inst##InstanceWrapper)
59+
BOOST_CLASS_EXPORT_IMPLEMENT(inst##Instance)
6460

6561
/**
6662
* @brief This should not be used within shared libraries use the two above.
@@ -204,6 +200,11 @@ struct JointWaypointInstance : tesseract_common::TypeErasureInstance<T, JointWay
204200
const std::string& getName() const final { return this->get().getName(); }
205201
void print(const std::string& prefix) const final { this->get().print(prefix); }
206202

203+
std::unique_ptr<tesseract_common::TypeErasureInterface> clone() const final
204+
{
205+
return std::make_unique<JointWaypointInstance<T>>(this->get());
206+
}
207+
207208
private:
208209
friend class boost::serialization::access;
209210
friend struct tesseract_common::Serialization;

tesseract_command_language/include/tesseract_command_language/poly/move_instruction_poly.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,16 @@ TESSERACT_COMMON_IGNORE_WARNINGS_POP
5151
using C##InstanceBase = \
5252
tesseract_common::TypeErasureInstance<C, tesseract_planning::detail_move_instruction::MoveInstructionInterface>; \
5353
using C##Instance = tesseract_planning::detail_move_instruction::MoveInstructionInstance<C>; \
54-
using C##InstanceWrapper = tesseract_common::TypeErasureInstanceWrapper<C##Instance>; \
5554
} \
5655
BOOST_CLASS_EXPORT_KEY(N::C##InstanceBase) \
5756
BOOST_CLASS_EXPORT_KEY(N::C##Instance) \
58-
BOOST_CLASS_EXPORT_KEY(N::C##InstanceWrapper) \
5957
BOOST_CLASS_TRACKING(N::C##InstanceBase, boost::serialization::track_never) \
60-
BOOST_CLASS_TRACKING(N::C##Instance, boost::serialization::track_never) \
61-
BOOST_CLASS_TRACKING(N::C##InstanceWrapper, boost::serialization::track_never)
58+
BOOST_CLASS_TRACKING(N::C##Instance, boost::serialization::track_never)
6259

6360
/** @brief If shared library, this must go in the cpp after the implicit instantiation of the serialize function */
6461
#define TESSERACT_MOVE_INSTRUCTION_EXPORT_IMPLEMENT(inst) \
6562
BOOST_CLASS_EXPORT_IMPLEMENT(inst##InstanceBase) \
66-
BOOST_CLASS_EXPORT_IMPLEMENT(inst##Instance) \
67-
BOOST_CLASS_EXPORT_IMPLEMENT(inst##InstanceWrapper)
63+
BOOST_CLASS_EXPORT_IMPLEMENT(inst##Instance)
6864

6965
/**
7066
* @brief This should not be used within shared libraries use the two above.
@@ -283,6 +279,11 @@ struct MoveInstructionInstance : tesseract_common::TypeErasureInstance<T, MoveIn
283279
JointWaypointPoly createJointWaypoint() const final { return this->get().createJointWaypoint(); }
284280
StateWaypointPoly createStateWaypoint() const final { return this->get().createStateWaypoint(); }
285281

282+
std::unique_ptr<tesseract_common::TypeErasureInterface> clone() const final
283+
{
284+
return std::make_unique<MoveInstructionInstance<T>>(this->get());
285+
}
286+
286287
private:
287288
friend class boost::serialization::access;
288289
friend struct tesseract_common::Serialization;

tesseract_command_language/include/tesseract_command_language/poly/state_waypoint_poly.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,16 @@ TESSERACT_COMMON_IGNORE_WARNINGS_POP
4646
using C##InstanceBase = \
4747
tesseract_common::TypeErasureInstance<C, tesseract_planning::detail_state_waypoint::StateWaypointInterface>; \
4848
using C##Instance = tesseract_planning::detail_state_waypoint::StateWaypointInstance<C>; \
49-
using C##InstanceWrapper = tesseract_common::TypeErasureInstanceWrapper<C##Instance>; \
5049
} \
5150
BOOST_CLASS_EXPORT_KEY(N::C##InstanceBase) \
5251
BOOST_CLASS_EXPORT_KEY(N::C##Instance) \
53-
BOOST_CLASS_EXPORT_KEY(N::C##InstanceWrapper) \
5452
BOOST_CLASS_TRACKING(N::C##InstanceBase, boost::serialization::track_never) \
55-
BOOST_CLASS_TRACKING(N::C##Instance, boost::serialization::track_never) \
56-
BOOST_CLASS_TRACKING(N::C##InstanceWrapper, boost::serialization::track_never)
53+
BOOST_CLASS_TRACKING(N::C##Instance, boost::serialization::track_never)
5754

5855
/** @brief If shared library, this must go in the cpp after the implicit instantiation of the serialize function */
5956
#define TESSERACT_STATE_WAYPOINT_EXPORT_IMPLEMENT(inst) \
6057
BOOST_CLASS_EXPORT_IMPLEMENT(inst##InstanceBase) \
61-
BOOST_CLASS_EXPORT_IMPLEMENT(inst##Instance) \
62-
BOOST_CLASS_EXPORT_IMPLEMENT(inst##InstanceWrapper)
58+
BOOST_CLASS_EXPORT_IMPLEMENT(inst##Instance)
6359

6460
/**
6561
* @brief This should not be used within shared libraries use the two above.
@@ -222,6 +218,11 @@ struct StateWaypointInstance : tesseract_common::TypeErasureInstance<T, StateWay
222218
const std::string& getName() const final { return this->get().getName(); }
223219
void print(const std::string& prefix) const final { this->get().print(prefix); }
224220

221+
std::unique_ptr<tesseract_common::TypeErasureInterface> clone() const final
222+
{
223+
return std::make_unique<StateWaypointInstance<T>>(this->get());
224+
}
225+
225226
private:
226227
friend class boost::serialization::access;
227228
friend struct tesseract_common::Serialization;

tesseract_command_language/include/tesseract_command_language/poly/waypoint_poly.h

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -46,20 +46,16 @@ TESSERACT_COMMON_IGNORE_WARNINGS_POP
4646
using C##InstanceBase = \
4747
tesseract_common::TypeErasureInstance<C, tesseract_planning::detail_waypoint::WaypointInterface>; \
4848
using C##Instance = tesseract_planning::detail_waypoint::WaypointInstance<C>; \
49-
using C##InstanceWrapper = tesseract_common::TypeErasureInstanceWrapper<C##Instance>; \
5049
} \
5150
BOOST_CLASS_EXPORT_KEY(N::C##InstanceBase) \
5251
BOOST_CLASS_EXPORT_KEY(N::C##Instance) \
53-
BOOST_CLASS_EXPORT_KEY(N::C##InstanceWrapper) \
5452
BOOST_CLASS_TRACKING(N::C##InstanceBase, boost::serialization::track_never) \
55-
BOOST_CLASS_TRACKING(N::C##Instance, boost::serialization::track_never) \
56-
BOOST_CLASS_TRACKING(N::C##InstanceWrapper, boost::serialization::track_never)
53+
BOOST_CLASS_TRACKING(N::C##Instance, boost::serialization::track_never)
5754

5855
/** @brief If shared library, this must go in the cpp after the implicit instantiation of the serialize function */
5956
#define TESSERACT_WAYPOINT_EXPORT_IMPLEMENT(inst) \
6057
BOOST_CLASS_EXPORT_IMPLEMENT(inst##InstanceBase) \
61-
BOOST_CLASS_EXPORT_IMPLEMENT(inst##Instance) \
62-
BOOST_CLASS_EXPORT_IMPLEMENT(inst##InstanceWrapper)
58+
BOOST_CLASS_EXPORT_IMPLEMENT(inst##Instance)
6359

6460
/**
6561
* @brief This should not be used within shared libraries use the two above.
@@ -124,6 +120,11 @@ struct WaypointInstance : tesseract_common::TypeErasureInstance<T, WaypointInter
124120
const std::string& getName() const final { return this->get().getName(); }
125121
void print(const std::string& prefix) const final { this->get().print(prefix); }
126122

123+
std::unique_ptr<tesseract_common::TypeErasureInterface> clone() const final
124+
{
125+
return std::make_unique<WaypointInstance<T>>(this->get());
126+
}
127+
127128
private:
128129
friend class boost::serialization::access;
129130
friend struct tesseract_common::Serialization;

0 commit comments

Comments
 (0)