Changeset 10:475d7a686fd6 in finroc_plugins_composite_ports
- Timestamp:
- 21.03.2020 16:11:47 (3 years ago)
- Branch:
- default
- Phase:
- public
- Files:
-
- 1 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
examples/example.finroc
r9 r10 23 23 <edge src="Aggregator Coded/Sensor Output/Simple 2" dest="Group With User/Sensor Input/Simple 1"/> 24 24 <edge src="Aggregator Coded/Sensor Output/Simple 3" dest="Group With User/Sensor Input/Simple 2"/> 25 <edge src="Aggregator/Sensor Output/Fancy 1" dest="Group With User/Sensor Input/I%2FO Interconnected"/> 25 26 <edge src="Aggregator/Sensor Output/Fancy 2" dest="Group With User/Sensor Input/Fancy 2"/> 26 27 <edge src="Aggregator/Sensor Output/Input Output Interface 4" dest="Group With User/Sensor Input/I%2FO Interface 3"/> -
examples/gUser.xml
r9 r10 12 12 <port name="Simple 3" type="finroc.composite_ports.examples.interfaces.Simple"/> 13 13 <port name="Simple 4" type="finroc.composite_ports.examples.interfaces.Simple"/> 14 <port name="I/O Interconnected" type="finroc.composite_ports.examples.interfaces.InputOutput"/> 14 15 </interface> 15 16 <element name="Interface User" group="finroc_plugins_composite_ports_example" type="InterfaceUser"> -
tInterface.h
r8 r10 104 104 105 105 typedef typename std::conditional<cCONVENIENCE_PORT, structure::tComponent*, core::tPortGroup*>::type tParent; 106 typedef tInterfaceBase tBase; 106 107 107 108 //---------------------------------------------------------------------- -
tInterfaceBase.cpp
r8 r10 389 389 void tInterfaceBase::tBackend::OnConnect(tAbstractPort& partner, bool partner_is_destination) 390 390 { 391 if (&primary_backend != this) 392 { 393 primary_backend.OnConnect(partner, this->IsOutputPort() == primary_backend.IsOutputPort() ? partner_is_destination : (!partner_is_destination)); 391 if (primary_backend.operation_on_all_elements_pending) 392 { 394 393 return; 395 394 } 396 if (this->operation_on_all_elements_pending) 397 { 398 return; 399 } 400 401 this->operation_on_all_elements_pending = true; 395 396 tBackend& other = static_cast<tBackend&>(partner); 397 bool connect_all_backends = this->IsPrimaryBackend() && other.IsPrimaryBackend(); 398 399 primary_backend.operation_on_all_elements_pending = true; 402 400 try 403 401 { 404 tBackend& other = static_cast<tBackend&>(partner).primary_backend; 405 if (this->custom_connect_function) 402 if (primary_backend.custom_connect_function) 406 403 { 407 404 if (partner_is_destination) 408 405 { 409 custom_connect_function(*this, other);406 primary_backend.custom_connect_function(*this, other); 410 407 } 411 408 else 412 409 { 413 custom_connect_function(other, *this);414 } 415 this->operation_on_all_elements_pending = false;410 primary_backend.custom_connect_function(other, *this); 411 } 412 primary_backend.operation_on_all_elements_pending = false; 416 413 return; 417 414 } 418 415 419 416 // Connect all matching backends and ports 420 for (auto this_backend : this->relation_backend_mapping)421 { 422 for (auto other_backend : other.primary_backend. relation_backend_mapping)423 { 424 if (this_backend.first - this->primary_relation_id == other_backend.first - other.primary_relation_id)417 for (auto this_backend : primary_backend.relation_backend_mapping) 418 { 419 for (auto other_backend : other.primary_backend.primary_backend.relation_backend_mapping) 420 { 421 if (this_backend.first - primary_backend.primary_relation_id == other_backend.first - other.primary_backend.primary_relation_id && (connect_all_backends || this_backend.second == this || other_backend.second == &other)) 425 422 { 426 423 core::tConnectionFlag direction = (this->IsOutputPort() == this_backend.second->IsOutputPort() ? partner_is_destination : (!partner_is_destination)) ? core::tConnectionFlag::DIRECTION_TO_DESTINATION : core::tConnectionFlag::DIRECTION_TO_SOURCE; … … 435 432 FINROC_LOG_PRINT(WARNING, "Connecting failed: ", e); 436 433 } 437 this->operation_on_all_elements_pending = false;434 primary_backend.operation_on_all_elements_pending = false; 438 435 } 439 436 -
tInterfaceType.h
r0 r10 48 48 // Internal includes with "" 49 49 //---------------------------------------------------------------------- 50 #include "plugins/composite_ports/internal/tInterfaceTypeInfo.h" 51 #include "plugins/composite_ports/internal/tGenericPortType.h" 50 #include "plugins/composite_ports/internal/tTypeInfo.h" 52 51 53 52 //---------------------------------------------------------------------- … … 62 61 // Forward declarations / typedefs / enums 63 62 //---------------------------------------------------------------------- 64 65 /*!66 * Port class that is suitable for generic instantiation of any interface67 */68 template <typename T>69 class tAnyPortType : public internal::tGenericPortType<0, data_ports::tPort, T, false>70 {71 using internal::tGenericPortType<0, data_ports::tPort, T, false>::tGenericPortType;72 };73 63 74 64 //---------------------------------------------------------------------- … … 91 81 92 82 typedef TInterface<tAnyPortType> tGeneric; 83 typedef internal::tTypeInfo<tGeneric> tHolder; 93 84 94 85 tInterfaceType() : 95 rrlib::rtti::tType(& cTYPE_INFO)86 rrlib::rtti::tType(&tHolder::cTYPE_INFO) 96 87 { 97 88 } … … 99 90 template <size_t Tchars> 100 91 tInterfaceType(const char(&name)[Tchars]) : 101 rrlib::rtti::tType(& cTYPE_INFO)92 rrlib::rtti::tType(&tHolder::cTYPE_INFO) 102 93 { 103 GetSharedInfo().SetName(rrlib::util::tManagedConstCharPointer(name, false), & cTYPE_INFO);94 GetSharedInfo().SetName(rrlib::util::tManagedConstCharPointer(name, false), &tHolder::cTYPE_INFO); 104 95 } 105 96 106 97 template <typename ... TFunctions> 107 98 tInterfaceType(const std::string& name) : 108 rrlib::rtti::tType(& cTYPE_INFO)99 rrlib::rtti::tType(&tHolder::cTYPE_INFO) 109 100 { 110 GetSharedInfo().SetName(rrlib::util::tManagedConstCharPointer(name.c_str(), true), & cTYPE_INFO);101 GetSharedInfo().SetName(rrlib::util::tManagedConstCharPointer(name.c_str(), true), &tHolder::cTYPE_INFO); 111 102 } 112 103 … … 116 107 private: 117 108 118 /*! Shared Type Info for this type */119 static internal::tInterfaceTypeInfo shared_info;120 121 /*! Type info for this type */122 static constexpr rrlib::rtti::detail::tTypeInfo cTYPE_INFO = { typeid(tGeneric), static_cast<uint>(rrlib::rtti::tTypeClassification::PORT_COMPOSITE_INTERFACE), &rrlib::rtti::detail::tTypeInfo::cNULL_TYPE_INFO, &rrlib::rtti::detail::tTypeInfo::cNULL_TYPE_INFO, &shared_info, sizeof(tGeneric) };123 124 /*! Generic create function */125 static tInterfaceBase Create(const std::string& name, core::tPortGroup* parent)126 {127 return tGeneric(name, parent);128 }129 130 109 }; 131 132 133 template <template <template <typename> class TPrimaryPort, template <typename> class ... TSecondaryPorts> class TInterface>134 constexpr rrlib::rtti::detail::tTypeInfo tInterfaceType<TInterface>::cTYPE_INFO;135 136 template <template <template <typename> class TPrimaryPort, template <typename> class ... TSecondaryPorts> class TInterface>137 internal::tInterfaceTypeInfo tInterfaceType<TInterface>::shared_info(&tInterfaceType<TInterface>::cTYPE_INFO, &tInterfaceType<TInterface>::Create, 0);138 110 139 111 //----------------------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.