Changeset 429:e4f565f3b102 in finroc_core
- Timestamp:
- 07.06.2017 22:05:58 (7 years ago)
- Branch:
- 17.03
- Phase:
- public
- Location:
- port
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
port/tAbstractPort.cpp
r425 r429 148 148 if (connect_direction_flags.Raw() == 0) // auto mode? 149 149 { 150 bool to_target_possible = MayConnectTo(to );151 bool to_source_possible = to.MayConnectTo(*this );150 bool to_target_possible = MayConnectTo(to, connect_options); 151 bool to_source_possible = to.MayConnectTo(*this, connect_options); 152 152 if (to_target_possible && to_source_possible) 153 153 { … … 162 162 std::stringstream reason_stream; 163 163 reason_stream << "Could not connect ports '" << (*this) << "' and '" << to << "' for the following reason: "; 164 MayConnectTo(to, &reason_stream);164 MayConnectTo(to, connect_options, &reason_stream); 165 165 reason_stream << "\nConnecting in the reverse direction did not work either: "; 166 to.MayConnectTo(*this, &reason_stream);166 to.MayConnectTo(*this, connect_options, &reason_stream); 167 167 FINROC_LOG_PRINT(WARNING, reason_stream.str()); 168 168 return nullptr; 169 169 } 170 } 171 else 172 { 173 connect_direction = connect_options.flags.Get(tConnectionFlag::DIRECTION_TO_DESTINATION) ? tConnectDirection::TO_DESTINATION : tConnectDirection::TO_SOURCE; 170 174 } 171 175 … … 174 178 tAbstractPort& destination = (connect_direction == tConnectDirection::TO_DESTINATION) ? to : *this; 175 179 std::stringstream reason_stream; 176 if (source.MayConnectTo(destination, &reason_stream))180 if (source.MayConnectTo(destination, connect_options, &reason_stream)) 177 181 { 178 182 FINROC_LOG_PRINT(DEBUG_VERBOSE_1, "Creating Edge from ", source, " to ", destination); … … 568 572 } 569 573 570 bool tAbstractPort::MayConnectTo(tAbstractPort& destination, std::stringstream* reason_stream) const571 { 572 if ( !rrlib::rtti::conversion::tStaticCastOperation::IsImplicitlyConvertibleTo(data_type, destination.data_type))574 bool tAbstractPort::MayConnectTo(tAbstractPort& destination, const tConnectOptions& connect_options, std::stringstream* reason_stream) const 575 { 576 if (connect_options.conversion_operations.Size() == 0 && (!rrlib::rtti::conversion::tStaticCastOperation::IsImplicitlyConvertibleTo(data_type, destination.data_type))) 573 577 { 574 578 if (reason_stream) … … 578 582 return false; 579 583 } 584 // TODO: should conversion operation be checked here already? (con: simpler if not and it will be checked anyway when creating the connector) 585 586 if (GetFlag(tFlag::TOOL_PORT) || destination.GetFlag(tFlag::TOOL_PORT)) 587 { 588 return true; // ignore flags and constraints for ports from tools 589 } 580 590 581 591 if (!GetFlag(tFlag::EMITS_DATA)) … … 595 605 } 596 606 return false; 597 }598 599 if (GetFlag(tFlag::TOOL_PORT) || destination.GetFlag(tFlag::TOOL_PORT))600 {601 return true; // ignore constraints for ports from tools602 607 } 603 608 -
port/tAbstractPort.h
r425 r429 323 323 * 324 324 * \param destination Destination port to check connectability to. 325 * \param connect_options Any connect options to apply 325 326 * \param reason_string If connecting is not possible, appends reason to this stream (unless it is nullptr) 326 327 * \return Answer 327 328 */ 328 bool MayConnectTo(tAbstractPort& destination, std::stringstream* reason_stream = nullptr) const;329 bool MayConnectTo(tAbstractPort& destination, const tConnectOptions& connect_options = tConnectOptions(), std::stringstream* reason_stream = nullptr) const; 329 330 330 331 /*!
Note: See TracChangeset
for help on using the changeset viewer.