more constexpr InterfaceFlags

This commit is contained in:
Robert Haschke 2018-02-25 11:50:23 +01:00
parent a24039846a
commit a2fd5fb7b8
4 changed files with 16 additions and 16 deletions

View File

@ -105,12 +105,12 @@ protected:
// If, during pruneInterface() later, we notice that it's not needed, prune there. // If, during pruneInterface() later, we notice that it's not needed, prune there.
inline void setChildsPushBackwardInterface(Stage& child) { inline void setChildsPushBackwardInterface(Stage& child) {
bool allowed = (child.pimpl()->requiredInterface() & WRITES_PREV_END) || bool allowed = (child.pimpl()->requiredInterface() & WRITES_PREV_END) ||
(child.pimpl()->requiredInterface() == 0); // unknown interface (child.pimpl()->requiredInterface() == UNKNOWN);
child.pimpl()->setPrevEnds(allowed ? pending_backward_ : InterfacePtr()); child.pimpl()->setPrevEnds(allowed ? pending_backward_ : InterfacePtr());
} }
inline void setChildsPushForwardInterface(Stage& child) { inline void setChildsPushForwardInterface(Stage& child) {
bool allowed = (child.pimpl()->requiredInterface() & WRITES_NEXT_START) || bool allowed = (child.pimpl()->requiredInterface() & WRITES_NEXT_START) ||
(child.pimpl()->requiredInterface() == 0); // unknown interface (child.pimpl()->requiredInterface() == UNKNOWN);
child.pimpl()->setNextStarts(allowed ? pending_forward_ : InterfacePtr()); child.pimpl()->setNextStarts(allowed ? pending_forward_ : InterfacePtr());
} }

View File

@ -85,6 +85,7 @@ typedef Flags<InterfaceFlag> InterfaceFlags;
constexpr InterfaceFlags UNKNOWN; constexpr InterfaceFlags UNKNOWN;
constexpr InterfaceFlags INPUT_IF_MASK({READS_START, WRITES_PREV_END}); constexpr InterfaceFlags INPUT_IF_MASK({READS_START, WRITES_PREV_END});
constexpr InterfaceFlags OUTPUT_IF_MASK({READS_END, WRITES_NEXT_START}); constexpr InterfaceFlags OUTPUT_IF_MASK({READS_END, WRITES_NEXT_START});
constexpr InterfaceFlags PROPAGATE_BOTHWAYS({PROPAGATE_FORWARDS, PROPAGATE_BACKWARDS});
MOVEIT_CLASS_FORWARD(Interface) MOVEIT_CLASS_FORWARD(Interface)
MOVEIT_CLASS_FORWARD(Stage) MOVEIT_CLASS_FORWARD(Stage)

View File

@ -483,11 +483,10 @@ void SerialContainer::init(const moveit::core::RobotModelConstPtr& robot_model)
// called by parent asking for pruning of this' interface // called by parent asking for pruning of this' interface
void SerialContainerPrivate::pruneInterface(InterfaceFlags accepted) { void SerialContainerPrivate::pruneInterface(InterfaceFlags accepted) {
if (children().empty()) return; if (children().empty()) return;
constexpr InterfaceFlags BOTHWAYS({PROPAGATE_FORWARDS, PROPAGATE_BACKWARDS});
// We only need to deal with the special case of the whole sequence to be pruned. // We only need to deal with the special case of the whole sequence to be pruned.
if (accepted != BOTHWAYS && // will interface be restricted at all? if (accepted != PROPAGATE_BOTHWAYS && // will interface be restricted at all?
children().front()->pimpl()->interfaceFlags() == BOTHWAYS) // still undecided? children().front()->pimpl()->interfaceFlags() == PROPAGATE_BOTHWAYS) // still undecided?
{ {
pruneInterfaces(children().begin(), children().end(), accepted); pruneInterfaces(children().begin(), children().end(), accepted);

View File

@ -219,7 +219,7 @@ TEST_F(SerialTest, insertion_order) {
TEST_F(SerialTest, init_empty) { TEST_F(SerialTest, init_empty) {
EXPECT_INIT_FAILURE(true, true); // no children EXPECT_INIT_FAILURE(true, true); // no children
EXPECT_EQ(serial.pimpl()->interfaceFlags(), InterfaceFlags({WRITES_NEXT_START, WRITES_PREV_END})); EXPECT_EQ(serial.pimpl()->interfaceFlags(), InterfaceFlags(GENERATE));
EXPECT_INIT_FAILURE(false, false); // no children EXPECT_INIT_FAILURE(false, false); // no children
EXPECT_EQ(serial.pimpl()->interfaceFlags(), InterfaceFlags()); EXPECT_EQ(serial.pimpl()->interfaceFlags(), InterfaceFlags());
@ -238,7 +238,7 @@ TEST_F(SerialTest, init_connecting) {
TEST_F(SerialTest, init_generator) { TEST_F(SerialTest, init_generator) {
EXPECT_INIT_SUCCESS(true, true, GEN); EXPECT_INIT_SUCCESS(true, true, GEN);
EXPECT_EQ(serial.pimpl()->interfaceFlags(), InterfaceFlags({WRITES_NEXT_START, WRITES_PREV_END})); EXPECT_EQ(serial.pimpl()->interfaceFlags(), InterfaceFlags(GENERATE));
EXPECT_EQ(serial.pimpl()->interfaceFlags(), serial.pimpl()->children().front()->pimpl()->interfaceFlags()); EXPECT_EQ(serial.pimpl()->interfaceFlags(), serial.pimpl()->children().front()->pimpl()->interfaceFlags());
EXPECT_INIT_FAILURE(false, false, GEN); // generator wants to push, but container cannot propagate pushes EXPECT_INIT_FAILURE(false, false, GEN); // generator wants to push, but container cannot propagate pushes
@ -260,7 +260,7 @@ TEST_F(SerialTest, init_forward) {
EXPECT_EQ(serial.pimpl()->interfaceFlags(), serial.pimpl()->children().front()->pimpl()->interfaceFlags()); EXPECT_EQ(serial.pimpl()->interfaceFlags(), serial.pimpl()->children().front()->pimpl()->interfaceFlags());
EXPECT_INIT_SUCCESS(true, true, GEN, FW); EXPECT_INIT_SUCCESS(true, true, GEN, FW);
EXPECT_EQ(serial.pimpl()->interfaceFlags(), InterfaceFlags({WRITES_NEXT_START, WRITES_PREV_END})); EXPECT_EQ(serial.pimpl()->interfaceFlags(), InterfaceFlags(GENERATE));
} }
TEST_F(SerialTest, init_backward) { TEST_F(SerialTest, init_backward) {
@ -277,10 +277,10 @@ TEST_F(SerialTest, init_backward) {
EXPECT_EQ(serial.pimpl()->interfaceFlags(), serial.pimpl()->children().front()->pimpl()->interfaceFlags()); EXPECT_EQ(serial.pimpl()->interfaceFlags(), serial.pimpl()->children().front()->pimpl()->interfaceFlags());
EXPECT_INIT_SUCCESS(true, true, BW, GEN); EXPECT_INIT_SUCCESS(true, true, BW, GEN);
EXPECT_EQ(serial.pimpl()->interfaceFlags(), InterfaceFlags({WRITES_NEXT_START, WRITES_PREV_END})); EXPECT_EQ(serial.pimpl()->interfaceFlags(), InterfaceFlags(GENERATE));
EXPECT_INIT_SUCCESS(true, true, BW, GEN, FW); EXPECT_INIT_SUCCESS(true, true, BW, GEN, FW);
EXPECT_EQ(serial.pimpl()->interfaceFlags(), InterfaceFlags({WRITES_NEXT_START, WRITES_PREV_END})); EXPECT_EQ(serial.pimpl()->interfaceFlags(), InterfaceFlags(GENERATE));
} }
TEST_F(SerialTest, interface_detection) { TEST_F(SerialTest, interface_detection) {
@ -327,13 +327,13 @@ TEST_F(SerialTest, interface_detection) {
EXPECT_INIT_SUCCESS(true, true, ANY, ANY); // <> <> EXPECT_INIT_SUCCESS(true, true, ANY, ANY); // <> <>
it = serial.pimpl()->children().begin(); it = serial.pimpl()->children().begin();
EXPECT_EQ( (*it)->pimpl()->interfaceFlags(), InterfaceFlags({PROPAGATE_FORWARDS, PROPAGATE_BACKWARDS})); EXPECT_EQ( (*it)->pimpl()->interfaceFlags(), PROPAGATE_BOTHWAYS);
EXPECT_EQ((*++it)->pimpl()->interfaceFlags(), InterfaceFlags({PROPAGATE_FORWARDS, PROPAGATE_BACKWARDS})); EXPECT_EQ((*++it)->pimpl()->interfaceFlags(), PROPAGATE_BOTHWAYS);
EXPECT_EQ(serial.pimpl()->interfaceFlags(), InterfaceFlags({PROPAGATE_FORWARDS, PROPAGATE_BACKWARDS})); EXPECT_EQ(serial.pimpl()->interfaceFlags(), PROPAGATE_BOTHWAYS);
EXPECT_INIT_FAILURE(false, false, ANY, ANY); // -- -- EXPECT_INIT_FAILURE(false, false, ANY, ANY); // -- --
it = serial.pimpl()->children().begin(); it = serial.pimpl()->children().begin();
EXPECT_EQ( (*it)->pimpl()->interfaceFlags(), InterfaceFlags()); EXPECT_EQ( (*it)->pimpl()->interfaceFlags(), UNKNOWN);
EXPECT_EQ((*++it)->pimpl()->interfaceFlags(), InterfaceFlags()); EXPECT_EQ((*++it)->pimpl()->interfaceFlags(), UNKNOWN);
EXPECT_EQ(serial.pimpl()->interfaceFlags(), InterfaceFlags()); EXPECT_EQ(serial.pimpl()->interfaceFlags(), UNKNOWN);
} }