From a7de95932ea4b6abd058eb0e130c008c113ff75b Mon Sep 17 00:00:00 2001 From: Robert Haschke Date: Mon, 16 Oct 2017 09:06:04 +0200 Subject: [PATCH] moved InterfaceFlag(s) into main scope --- src/container.cpp | 2 +- src/stage.cpp | 20 ++++++++++---------- src/stage_p.h | 27 +++++++++++++-------------- src/test/container.cpp | 3 +-- 4 files changed, 25 insertions(+), 27 deletions(-) diff --git a/src/container.cpp b/src/container.cpp index 030e7071..81f12295 100644 --- a/src/container.cpp +++ b/src/container.cpp @@ -85,7 +85,7 @@ SerialContainerPrivate::SerialContainerPrivate(SerialContainer *me, const std::s ends_.reset(new Interface(Interface::NotifyFunction())); } -StagePrivate::InterfaceFlags SerialContainerPrivate::announcedFlags() const { +InterfaceFlags SerialContainerPrivate::announcedFlags() const { InterfaceFlags f; if (children().empty()) return f; f |= children().front()->pimpl()->announcedFlags() & INPUT_IF_MASK; diff --git a/src/stage.cpp b/src/stage.cpp index 7aa1608f..4fcb7242 100644 --- a/src/stage.cpp +++ b/src/stage.cpp @@ -29,12 +29,12 @@ std::ostream& operator<<(std::ostream &os, const Stage& stage) { return os; } -template +template const char* direction(const StagePrivate& stage) { - StagePrivate::InterfaceFlags f = stage.deducedFlags(); + InterfaceFlags f = stage.deducedFlags(); bool own_if = f & own; 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 (other_if ^ reverse) return "->"; @@ -49,9 +49,9 @@ std::ostream& operator<<(std::ostream &os, const StagePrivate& stage) { else os << "-"; } // trajectories - os << std::setw(5) << direction(stage) + os << std::setw(5) << direction(stage) << std::setw(3) << stage.trajectories_.size() - << std::setw(5) << direction(stage); + << std::setw(5) << direction(stage); // ends for (const Interface* i : {stage.ends_.get(), stage.next_starts_}) { os << std::setw(3); @@ -74,7 +74,7 @@ SubTrajectory& StagePrivate::addTrajectory(const robot_trajectory::RobotTrajecto return back; } -StagePrivate::InterfaceFlags StagePrivate::interfaceFlags() const +InterfaceFlags StagePrivate::interfaceFlags() const { InterfaceFlags result = announcedFlags(); 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 -inline StagePrivate::InterfaceFlags StagePrivate::deducedFlags() const +inline InterfaceFlags StagePrivate::deducedFlags() const { InterfaceFlags f; if (starts_) f |= READS_START; @@ -99,7 +99,7 @@ PropagatingEitherWayPrivate::PropagatingEitherWayPrivate(PropagatingEitherWay *m { } -StagePrivate::InterfaceFlags PropagatingEitherWayPrivate::announcedFlags() const { +InterfaceFlags PropagatingEitherWayPrivate::announcedFlags() const { InterfaceFlags f; if (dir & PropagatingEitherWay::FORWARD) f |= InterfaceFlags({READS_START, WRITES_NEXT_START}); @@ -295,7 +295,7 @@ GeneratorPrivate::GeneratorPrivate(Generator *me, const std::string &name) : StagePrivate(me, name) {} -StagePrivate::InterfaceFlags GeneratorPrivate::announcedFlags() const { +InterfaceFlags GeneratorPrivate::announcedFlags() const { 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()); } -StagePrivate::InterfaceFlags ConnectingPrivate::announcedFlags() const { +InterfaceFlags ConnectingPrivate::announcedFlags() const { return InterfaceFlags({READS_START, READS_END}); } diff --git a/src/stage_p.h b/src/stage_p.h index bc38a199..3baf2541 100644 --- a/src/stage_p.h +++ b/src/stage_p.h @@ -12,6 +12,19 @@ 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 InterfaceFlags; + class ContainerBasePrivate; class StagePrivate { friend class Stage; @@ -19,22 +32,8 @@ class StagePrivate { public: typedef std::list container_type; - 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 InterfaceFlags; - InterfaceFlags interfaceFlags() const; InterfaceFlags deducedFlags() const; virtual InterfaceFlags announcedFlags() const = 0; diff --git a/src/test/container.cpp b/src/test/container.cpp index 9d05a903..b7598099 100644 --- a/src/test/container.cpp +++ b/src/test/container.cpp @@ -73,8 +73,7 @@ protected: TEST_F(BaseTest, interfaceFlags) { std::unique_ptr g = std::make_unique(); EXPECT_EQ(g->pimpl()->interfaceFlags(), - StagePrivate::InterfaceFlags({StagePrivate::WRITES_NEXT_START, - StagePrivate::WRITES_PREV_END})); + InterfaceFlags({WRITES_NEXT_START, WRITES_PREV_END})); } #define VALIDATE(...) \