simplify internal API

This commit is contained in:
Robert Haschke 2020-04-10 10:45:14 +02:00
parent e56c772ecb
commit aa732d8c66
2 changed files with 11 additions and 13 deletions

View File

@ -119,18 +119,16 @@ public:
protected: protected:
ContainerBasePrivate(ContainerBase* me, const std::string& name); ContainerBasePrivate(ContainerBase* me, const std::string& name);
// Set child's push interfaces: allow pushing if child requires it or // Set child's push interfaces: allow pushing if child requires it.
// if the interface is unknown: in this case greedily assume a push interface. inline void setChildsPushBackwardInterface(StagePrivate* child) {
// If, during pruneInterface() later, we notice that it's not needed, prune there. InterfaceFlags required = child->requiredInterface();
inline void setChildsPushBackwardInterface(Stage& child) {
InterfaceFlags required = child.pimpl()->requiredInterface();
bool allowed = (required & WRITES_PREV_END); bool allowed = (required & WRITES_PREV_END);
child.pimpl()->setPrevEnds(allowed ? pending_backward_ : InterfacePtr()); child->setPrevEnds(allowed ? pending_backward_ : InterfacePtr());
} }
inline void setChildsPushForwardInterface(Stage& child) { inline void setChildsPushForwardInterface(StagePrivate* child) {
InterfaceFlags required = child.pimpl()->requiredInterface(); InterfaceFlags required = child->requiredInterface();
bool allowed = (required & WRITES_NEXT_START); bool allowed = (required & WRITES_NEXT_START);
child.pimpl()->setNextStarts(allowed ? pending_forward_ : InterfacePtr()); child->setNextStarts(allowed ? pending_forward_ : InterfacePtr());
} }
/// copy external_state to a child's interface and remember the link in internal_to map /// copy external_state to a child's interface and remember the link in internal_to map

View File

@ -436,7 +436,7 @@ void SerialContainerPrivate::pruneInterface(InterfaceFlags accepted) {
// FIRST child // FIRST child
first.pimpl()->pruneInterface(accepted & START_IF_MASK); first.pimpl()->pruneInterface(accepted & START_IF_MASK);
// connect first child's (start) push interface // connect first child's (start) push interface
setChildsPushBackwardInterface(first); setChildsPushBackwardInterface(first.pimpl());
// validate that first child's and this container's start interfaces match // validate that first child's and this container's start interfaces match
validateInterface<START_IF_MASK>(*first.pimpl(), accepted); validateInterface<START_IF_MASK>(*first.pimpl(), accepted);
// connect first child's (start) pull interface // connect first child's (start) pull interface
@ -453,7 +453,7 @@ void SerialContainerPrivate::pruneInterface(InterfaceFlags accepted) {
} }
// connect last child's (end) push interface // connect last child's (end) push interface
setChildsPushForwardInterface(last); setChildsPushForwardInterface(last.pimpl());
// validate that last child's and this container's end interfaces match // validate that last child's and this container's end interfaces match
validateInterface<END_IF_MASK>(*last.pimpl(), accepted); validateInterface<END_IF_MASK>(*last.pimpl(), accepted);
// connect last child's (end) pull interface // connect last child's (end) pull interface
@ -566,8 +566,8 @@ void ParallelContainerBasePrivate::pruneInterface(InterfaceFlags accepted) {
child_impl->pruneInterface(accepted); child_impl->pruneInterface(accepted);
validateInterfaces(*child_impl, accepted, first); validateInterfaces(*child_impl, accepted, first);
// initialize push connections of children according to their demands // initialize push connections of children according to their demands
setChildsPushForwardInterface(*child); setChildsPushForwardInterface(child_impl);
setChildsPushBackwardInterface(*child); setChildsPushBackwardInterface(child_impl);
first = false; first = false;
} catch (InitStageException& e) { } catch (InitStageException& e) {
exceptions.append(e); exceptions.append(e);