moved InterfaceFlag(s) into main scope

This commit is contained in:
Robert Haschke 2017-10-16 09:06:04 +02:00
parent a32007613e
commit a7de95932e
4 changed files with 25 additions and 27 deletions

View File

@ -85,7 +85,7 @@ SerialContainerPrivate::SerialContainerPrivate(SerialContainer *me, const std::s
ends_.reset(new Interface(Interface::NotifyFunction())); ends_.reset(new Interface(Interface::NotifyFunction()));
} }
StagePrivate::InterfaceFlags SerialContainerPrivate::announcedFlags() const { InterfaceFlags SerialContainerPrivate::announcedFlags() const {
InterfaceFlags f; InterfaceFlags f;
if (children().empty()) return f; if (children().empty()) return f;
f |= children().front()->pimpl()->announcedFlags() & INPUT_IF_MASK; f |= children().front()->pimpl()->announcedFlags() & INPUT_IF_MASK;

View File

@ -29,12 +29,12 @@ std::ostream& operator<<(std::ostream &os, const Stage& stage) {
return os; return os;
} }
template<StagePrivate::InterfaceFlag own, StagePrivate::InterfaceFlag other> template<InterfaceFlag own, InterfaceFlag other>
const char* direction(const StagePrivate& stage) { const char* direction(const StagePrivate& stage) {
StagePrivate::InterfaceFlags f = stage.deducedFlags(); InterfaceFlags f = stage.deducedFlags();
bool own_if = f & own; bool own_if = f & own;
bool other_if = f & other; bool other_if = f & other;
bool reverse = own & StagePrivate::INPUT_IF_MASK; bool reverse = own & INPUT_IF_MASK;
if (own_if && other_if) return "<>"; if (own_if && other_if) return "<>";
if (!own_if && !other_if) return "--"; if (!own_if && !other_if) return "--";
if (other_if ^ reverse) return "->"; if (other_if ^ reverse) return "->";
@ -49,9 +49,9 @@ std::ostream& operator<<(std::ostream &os, const StagePrivate& stage) {
else os << "-"; else os << "-";
} }
// trajectories // trajectories
os << std::setw(5) << direction<StagePrivate::READS_START, StagePrivate::WRITES_PREV_END>(stage) os << std::setw(5) << direction<READS_START, WRITES_PREV_END>(stage)
<< std::setw(3) << stage.trajectories_.size() << std::setw(3) << stage.trajectories_.size()
<< std::setw(5) << direction<StagePrivate::READS_END, StagePrivate::WRITES_NEXT_START>(stage); << std::setw(5) << direction<READS_END, WRITES_NEXT_START>(stage);
// ends // ends
for (const Interface* i : {stage.ends_.get(), stage.next_starts_}) { for (const Interface* i : {stage.ends_.get(), stage.next_starts_}) {
os << std::setw(3); os << std::setw(3);
@ -74,7 +74,7 @@ SubTrajectory& StagePrivate::addTrajectory(const robot_trajectory::RobotTrajecto
return back; return back;
} }
StagePrivate::InterfaceFlags StagePrivate::interfaceFlags() const InterfaceFlags StagePrivate::interfaceFlags() const
{ {
InterfaceFlags result = announcedFlags(); InterfaceFlags result = announcedFlags();
result &= ~InterfaceFlags(OWN_IF_MASK); result &= ~InterfaceFlags(OWN_IF_MASK);
@ -83,7 +83,7 @@ StagePrivate::InterfaceFlags StagePrivate::interfaceFlags() const
} }
// return the interface flags that can be deduced from the interface // return the interface flags that can be deduced from the interface
inline StagePrivate::InterfaceFlags StagePrivate::deducedFlags() const inline InterfaceFlags StagePrivate::deducedFlags() const
{ {
InterfaceFlags f; InterfaceFlags f;
if (starts_) f |= READS_START; if (starts_) f |= READS_START;
@ -99,7 +99,7 @@ PropagatingEitherWayPrivate::PropagatingEitherWayPrivate(PropagatingEitherWay *m
{ {
} }
StagePrivate::InterfaceFlags PropagatingEitherWayPrivate::announcedFlags() const { InterfaceFlags PropagatingEitherWayPrivate::announcedFlags() const {
InterfaceFlags f; InterfaceFlags f;
if (dir & PropagatingEitherWay::FORWARD) if (dir & PropagatingEitherWay::FORWARD)
f |= InterfaceFlags({READS_START, WRITES_NEXT_START}); f |= InterfaceFlags({READS_START, WRITES_NEXT_START});
@ -295,7 +295,7 @@ GeneratorPrivate::GeneratorPrivate(Generator *me, const std::string &name)
: StagePrivate(me, name) : StagePrivate(me, name)
{} {}
StagePrivate::InterfaceFlags GeneratorPrivate::announcedFlags() const { InterfaceFlags GeneratorPrivate::announcedFlags() const {
return InterfaceFlags({WRITES_NEXT_START,WRITES_PREV_END}); return InterfaceFlags({WRITES_NEXT_START,WRITES_PREV_END});
} }
@ -333,7 +333,7 @@ ConnectingPrivate::ConnectingPrivate(Connecting *me, const std::string &name)
it_pairs_ = std::make_pair(starts_->begin(), ends_->begin()); it_pairs_ = std::make_pair(starts_->begin(), ends_->begin());
} }
StagePrivate::InterfaceFlags ConnectingPrivate::announcedFlags() const { InterfaceFlags ConnectingPrivate::announcedFlags() const {
return InterfaceFlags({READS_START, READS_END}); return InterfaceFlags({READS_START, READS_END});
} }

View File

@ -12,6 +12,19 @@
namespace moveit { namespace task_constructor { namespace moveit { namespace task_constructor {
enum InterfaceFlag {
READS_START = 0x01,
READS_END = 0x02,
WRITES_NEXT_START = 0x04,
WRITES_PREV_END = 0x08,
OWN_IF_MASK = READS_START | READS_END,
EXT_IF_MASK = WRITES_NEXT_START | WRITES_PREV_END,
INPUT_IF_MASK = READS_START | WRITES_PREV_END,
OUTPUT_IF_MASK = READS_END | WRITES_NEXT_START,
};
typedef Flags<InterfaceFlag> InterfaceFlags;
class ContainerBasePrivate; class ContainerBasePrivate;
class StagePrivate { class StagePrivate {
friend class Stage; friend class Stage;
@ -19,22 +32,8 @@ class StagePrivate {
public: public:
typedef std::list<Stage::pointer> container_type; typedef std::list<Stage::pointer> container_type;
StagePrivate(Stage* me, const std::string& name); StagePrivate(Stage* me, const std::string& name);
enum InterfaceFlag {
READS_START = 0x01,
READS_END = 0x02,
WRITES_NEXT_START = 0x04,
WRITES_PREV_END = 0x08,
OWN_IF_MASK = READS_START | READS_END,
EXT_IF_MASK = WRITES_NEXT_START | WRITES_PREV_END,
INPUT_IF_MASK = READS_START | WRITES_PREV_END,
OUTPUT_IF_MASK = READS_END | WRITES_NEXT_START,
};
typedef Flags<InterfaceFlag> InterfaceFlags;
InterfaceFlags interfaceFlags() const; InterfaceFlags interfaceFlags() const;
InterfaceFlags deducedFlags() const; InterfaceFlags deducedFlags() const;
virtual InterfaceFlags announcedFlags() const = 0; virtual InterfaceFlags announcedFlags() const = 0;

View File

@ -73,8 +73,7 @@ protected:
TEST_F(BaseTest, interfaceFlags) { TEST_F(BaseTest, interfaceFlags) {
std::unique_ptr<Generator> g = std::make_unique<TestGenerator>(); std::unique_ptr<Generator> g = std::make_unique<TestGenerator>();
EXPECT_EQ(g->pimpl()->interfaceFlags(), EXPECT_EQ(g->pimpl()->interfaceFlags(),
StagePrivate::InterfaceFlags({StagePrivate::WRITES_NEXT_START, InterfaceFlags({WRITES_NEXT_START, WRITES_PREV_END}));
StagePrivate::WRITES_PREV_END}));
} }
#define VALIDATE(...) \ #define VALIDATE(...) \