Changeset 22:e2e8d05ef4e4 in finroc_plugins_composite_ports


Ignore:
Timestamp:
02.03.2021 00:15:46 (2 months ago)
Author:
Max Reichardt <mreichardt@…>
Branch:
default
Phase:
public
Message:

Cleanly implements the details of creating service ports in partially instantiated port composite interfaces.

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • internal/type_traits.h

    r16 r22  
    229229using MakeCounterPartParameterIfInput = MakeCounterDirectionPort<TPort, true>; 
    230230 
    231 template <template <typename> class TPort, bool TServer> 
     231template <template <typename> class TPort, bool TServer, bool TClient> 
    232232struct MakeRPCPort 
    233233{ 
    234234  template <typename T> 
     235  using type = core::tPortWrapperBase; 
     236}; 
     237template <template <typename> class TPort> 
     238struct MakeRPCPort<TPort, false, true> 
     239{ 
     240  template <typename T> 
    235241  using base_type = typename std::conditional < std::is_base_of<data_ports::tProxyPort<tTestType, false>, TPort<tTestType>>::value || std::is_base_of<data_ports::tProxyPort<tTestType, true>, TPort<tTestType>>::value, rpc_ports::tProxyPort<T, false>, rpc_ports::tClientPort<T >>::type; 
    236242 
     
    239245}; 
    240246template <template <typename> class TPort> 
    241 struct MakeRPCPort<TPort, true> 
     247struct MakeRPCPort<TPort, true, false> 
    242248{ 
    243249  template <typename T> 
     
    249255 
    250256template <template <typename> class TPort> 
    251 using MakeServerIfInput = MakeRPCPort<TPort, IsInputPort<TPort>::value>; 
    252 template <template <typename> class TPort> 
    253 using MakeClientIfInput = MakeRPCPort<TPort, IsOutputPort<TPort>::value>; 
     257using MakeServerIfInput = MakeRPCPort<TPort, IsInputPort<TPort>::value, IsOutputPort<TPort>::value>; 
     258template <template <typename> class TPort> 
     259using MakeClientIfInput = MakeRPCPort<TPort, IsOutputPort<TPort>::value, IsInputPort<TPort>::value>; 
    254260 
    255261 
  • tInterfaceBase.cpp

    r21 r22  
    337337bool tInterfaceBase::tBackend::CreateOutputPort(int primary_relation_id) 
    338338{ 
    339   auto* backend = GetBackend(primary_relation_id); 
    340   if (backend->GetFlag(tFlag::INTERFACE_FOR_OUTPUTS)) 
    341   { 
    342     return true; 
    343   } 
    344   if (backend->GetFlag(tFlag::INTERFACE_FOR_INPUTS) || backend->GetFlag(tFlag::PARAMETER_INTERFACE)) 
     339  auto backend = GetBackend(primary_relation_id); 
     340  if (!backend) 
    345341  { 
    346342    return false; 
    347343  } 
    348   if (backend->GetFlag(tFlag::INTERFACE_FOR_RPC_PORTS)) 
     344  auto component_interface = GetAggregator(*backend); 
     345  if ((!component_interface) || (!internal::IsComponent(component_interface->GetParent()))) 
     346  { 
     347    return false; 
     348  } 
     349  if (component_interface->GetFlag(tFlag::INTERFACE_FOR_RPC_PORTS)) 
    349350  { 
    350351    int last_relation = primary_relation_id & 0xFF; 
     
    358359      return derived_from_backend_is_output; 
    359360    } 
     361  } 
     362  if (component_interface->GetFlag(tFlag::INTERFACE_FOR_OUTPUTS)) 
     363  { 
     364    return true; 
     365  } 
     366  if (component_interface->GetFlag(tFlag::INTERFACE_FOR_INPUTS) || component_interface->GetFlag(tFlag::PARAMETER_INTERFACE)) 
     367  { 
     368    return false; 
    360369  } 
    361370  throw std::runtime_error("Unspecified port direction"); 
     
    424433    } 
    425434 
    426     tFrameworkElement* parent_candidate = (relation_list.empty() && do_not_create_primary_port_type) ? nullptr : component_interface; 
     435    tFrameworkElement* parent_candidate = do_not_create_primary_port_type ? nullptr : component_interface; 
    427436    core::tFrameworkElementFlags use_these_original_flags; 
    428437    if (do_not_create_primary_port_type) 
     
    503512      case internal::tPortTypeRelation::ePTR_CLIENT_IF_INPUT: 
    504513        target_set_flags = tFlag::INTERFACE_FOR_RPC_PORTS; 
    505         target_unset_flags = core::tFrameworkElementFlags(); 
     514        target_unset_flags = (partial_interface && (!parent_candidate)) ? target_set_flags : core::tFrameworkElementFlags(); // With partially instantiated interfaces, create service ports if the port types they are derived from are also created 
    506515        break; 
    507516      default: 
     
    525534      } 
    526535 
    527       if ((!new_candidate) && this->IsPartialInterface() && ((partial_interface_direction_is_output && (!target_set_flags.Get(tFlag::INTERFACE_FOR_OUTPUTS))) || ((!partial_interface_direction_is_output) && target_set_flags.Get(tFlag::INTERFACE_FOR_OUTPUTS)))) 
     536      if ((!new_candidate) && this->IsPartialInterface() && ((partial_interface_direction_is_output && (!target_set_flags.Get(tFlag::INTERFACE_FOR_OUTPUTS))) || ((!partial_interface_direction_is_output) && target_set_flags.Get(tFlag::INTERFACE_FOR_OUTPUTS)) || target_set_flags.Get(tFlag::INTERFACE_FOR_RPC_PORTS))) 
    528537      { 
    529538        use_these_original_flags = target_set_flags; 
  • tInterfaceBase.h

    r20 r22  
    235235 
    236236    /*! 
    237      * \param any_port_type Whether backend is a generic port (-> unspecified whether input or output) 
     237     * \param generic_port_backend Whether backend is a generic port (-> unspecified whether input or output) 
    238238     * \return Default port flags for ports below this backend 
    239239     */ 
Note: See TracChangeset for help on using the changeset viewer.