Changeset 106:5096776a7d9c in finroc_plugins_data_ports


Ignore:
Timestamp:
26.08.2016 01:20:56 (3 years ago)
Author:
Max Reichardt <mreichardt@…>
Branch:
17.03
Phase:
public
Rebase:
63623034643762363930333234343533623761323037643036343938643132306663343662396663
Message:

Adapts to changes in rrlib_rtti and finroc_core

Files:
15 edited

Legend:

Unmodified
Added
Removed
  • api/tGenericPortImplementation.cpp

    r100 r106  
    265265  if (type.GetRttiName() == typeid(T).name()) 
    266266  { 
    267     type.AddAnnotation<tGenericPortImplementation>(new internal::tGenericPortImplementationTyped<T>()); 
    268   } 
    269 } 
     267    static internal::tGenericPortImplementationTyped<T> cINSTANCE; 
     268    type.AddAnnotation<tGenericPortImplementation*>(&cINSTANCE); 
     269  } 
     270} 
     271 
     272tGenericPortImplementationCheapCopy cINSTANCE_CHEAP_COPY; 
     273tGenericPortImplementationStandard cINSTANCE_STANDARD; 
    270274 
    271275} // namespace internal 
     
    274278{ 
    275279  static rrlib::thread::tMutex mutex; 
    276   static int16_t initialized_types = 0; 
     280  static size_t initialized_types = 0; 
    277281  rrlib::thread::tLock lock(mutex); 
    278282 
     
    296300      internal::CheckCreateImplementationForType<numeric::tNumber>(type); 
    297301 
    298       if (!type.GetAnnotation<tGenericPortImplementation>()) 
     302      if (!type.GetAnnotation<tGenericPortImplementation*>()) 
    299303      { 
    300304        assert((type.GetTypeTraits() & rrlib::rtti::trait_flags::cIS_INTEGRAL) == 0 || type.GetRttiName() == typeid(bool).name()); 
    301305        if (IsCheaplyCopiedType(type)) 
    302306        { 
    303           type.AddAnnotation<tGenericPortImplementation>(new internal::tGenericPortImplementationCheapCopy()); 
     307          type.AddAnnotation<tGenericPortImplementation*>(&internal::cINSTANCE_CHEAP_COPY); 
    304308        } 
    305309        else 
    306310        { 
    307           type.AddAnnotation<tGenericPortImplementation>(new internal::tGenericPortImplementationStandard()); 
     311          type.AddAnnotation<tGenericPortImplementation*>(&internal::cINSTANCE_STANDARD); 
    308312        } 
    309313      } 
  • api/tGenericPortImplementation.h

    r103 r106  
    4040// External includes (system with <>, local with "") 
    4141//---------------------------------------------------------------------- 
    42 #include "rrlib/rtti/tTypeAnnotation.h" 
    4342 
    4443//---------------------------------------------------------------------- 
     
    7473 * Implementations for tGenericPort. 
    7574 */ 
    76 class tGenericPortImplementation : public rrlib::rtti::tTypeAnnotation 
     75class tGenericPortImplementation 
    7776{ 
    7877//---------------------------------------------------------------------- 
     
    126125  static tGenericPortImplementation* GetImplementation(const rrlib::rtti::tType& type) 
    127126  { 
    128     tGenericPortImplementation* annotation = type.GetAnnotation<tGenericPortImplementation>(); 
     127    tGenericPortImplementation* annotation = type.GetAnnotation<tGenericPortImplementation*>(); 
    129128    if (!annotation) 
    130129    { 
    131130      CreateImplementations(); 
    132       annotation = type.GetAnnotation<tGenericPortImplementation>(); 
     131      annotation = type.GetAnnotation<tGenericPortImplementation*>(); 
    133132    } 
    134133    return annotation; 
  • api/tPullRequestHandlerAdapter.h

    r59 r106  
    138138    if (pulled_buffer) 
    139139    { 
    140       result_buffer.GetObject().DeepCopyFrom(*pulled_buffer, NULL); 
     140      result_buffer.GetObject().DeepCopyFrom(*pulled_buffer); 
    141141      result_buffer.SetTimestamp(pulled_buffer.GetTimestamp()); 
    142142    } 
  • common/tAbstractDataPort.cpp

    r93 r106  
    118118  for (auto it = IncomingConnectionsBegin(); it != IncomingConnectionsEnd(); ++it) 
    119119  { 
    120     tAbstractDataPort& port = static_cast<tAbstractDataPort&>(*it); 
     120    tAbstractDataPort& port = static_cast<tAbstractDataPort&>(it->Source()); 
    121121    if (push_wanter || port.GetStrategy() != strategy2) 
    122122    { 
     
    133133  for (auto it = OutgoingConnectionsBegin(); it != OutgoingConnectionsEnd(); ++it) 
    134134  { 
    135     tAbstractDataPort& port = static_cast<tAbstractDataPort&>(*it); 
     135    tAbstractDataPort& port = static_cast<tAbstractDataPort&>(it->Destination()); 
    136136    if (port.GetStrategy() > 0) 
    137137    { 
     
    144144  for (auto it = IncomingConnectionsBegin(); it != IncomingConnectionsEnd(); ++it) 
    145145  { 
    146     tAbstractDataPort& port = static_cast<tAbstractDataPort&>(*it); 
     146    tAbstractDataPort& port = static_cast<tAbstractDataPort&>(it->Source()); 
    147147    if (port.GetFlag(tFlag::PUSH_STRATEGY_REVERSE)) 
    148148    { 
     
    231231  for (auto it = OutgoingConnectionsBegin(); it != OutgoingConnectionsEnd(); ++it) 
    232232  { 
    233     tAbstractDataPort& port = static_cast<tAbstractDataPort&>(*it); 
     233    tAbstractDataPort& port = static_cast<tAbstractDataPort&>(it->Destination()); 
    234234    max = static_cast<int16_t>(std::max(max, port.GetStrategy())); 
    235235  } 
     
    251251      for (auto it = IncomingConnectionsBegin(); it != IncomingConnectionsEnd(); ++it) 
    252252      { 
    253         tAbstractDataPort& port = static_cast<tAbstractDataPort&>(*it); 
     253        tAbstractDataPort& port = static_cast<tAbstractDataPort&>(it->Source()); 
    254254        if (port.IsReady() && (!port.ReversePushStrategy())) 
    255255        { 
     
    278278  for (auto it = IncomingConnectionsBegin(); it != IncomingConnectionsEnd(); ++it) 
    279279  { 
    280     if (it->IsReady() && &(*it) != new_connection_partner) 
     280    if (it->Source().IsReady() && &(it->Source()) != new_connection_partner) 
    281281    { 
    282282      other_sources++; 
     
    353353    for (auto it = OutgoingConnectionsBegin(); it != OutgoingConnectionsEnd(); ++it) 
    354354    { 
    355       tAbstractDataPort& port = static_cast<tAbstractDataPort&>(*it); 
     355      tAbstractDataPort& port = static_cast<tAbstractDataPort&>(it->Destination()); 
    356356      if (port.IsReady()) 
    357357      { 
  • common/tPublishOperation.h

    r93 r106  
    131131      for (auto it = port.OutgoingConnectionsBegin(); it != port.OutgoingConnectionsEnd(); ++it) 
    132132      { 
    133         TPort& destination_port = static_cast<TPort&>(*it); 
     133        TPort& destination_port = static_cast<TPort&>(it->Destination()); 
    134134        if (destination_port.template WantsPush<REVERSE, CHANGE_CONSTANT>()) 
    135135        { 
     
    144144      for (auto it = port.IncomingConnectionsBegin(); it != port.IncomingConnectionsEnd(); ++it) 
    145145      { 
    146         TPort& destination_port = static_cast<TPort&>(*it); 
     146        TPort& destination_port = static_cast<TPort&>(it->Source()); 
    147147        if (destination_port.template WantsPush<true, CHANGE_CONSTANT>()) 
    148148        { 
     
    176176      for (auto it = port.OutgoingConnectionsBegin(); it != port.OutgoingConnectionsEnd(); ++it) 
    177177      { 
    178         TPort& destination_port = static_cast<TPort&>(*it); 
     178        TPort& destination_port = static_cast<TPort&>(it->Destination()); 
    179179        if (destination_port.template WantsPush<false, CHANGE_CONSTANT>()) 
    180180        { 
     
    186186      for (auto it = port.IncomingConnectionsBegin(); it != port.IncomingConnectionsEnd(); ++it) 
    187187      { 
    188         TPort& destination_port = static_cast<TPort&>(*it); 
     188        TPort& destination_port = static_cast<TPort&>(it->Source()); 
    189189        if (&destination_port != &origin && destination_port.template WantsPush<true, CHANGE_CONSTANT>()) 
    190190        { 
  • common/tPullOperation.h

    r93 r106  
    134134    for (auto it = port.IncomingConnectionsBegin(); it != port.IncomingConnectionsEnd(); ++it) 
    135135    { 
    136       ExecuteImplementation(static_cast<TPort&>(*it), false); 
     136      ExecuteImplementation(static_cast<TPort&>(it->Source()), false); 
    137137      typename TPort::tTaggedBufferPointer::tStorage tagged_pointer_raw = this->published_buffer_tagged_pointer; 
    138138      if (tagged_pointer_raw != port.current_value.load()) 
  • optimized/cheaply_copied_types.cpp

    r100 r106  
    3333// External includes (system with <>, local with "") 
    3434//---------------------------------------------------------------------- 
    35 #include "rrlib/rtti/tTypeAnnotation.h" 
    3635#include "rrlib/thread/tLock.h" 
    3736#include "core/definitions.h" 
     
    7675{ 
    7776 
    78 class tIndexAnnotation : public rrlib::rtti::tTypeAnnotation 
     77class tIndexAnnotation 
    7978{ 
    8079public: 
    8180 
    82   tIndexAnnotation(uint32_t index) : index(index) {} 
     81  tIndexAnnotation(uint32_t index = 0) : index(index) {} 
    8382 
    8483  /*! Cheaply copied typed index */ 
     
    127126uint32_t GetCheaplyCopiedTypeIndex(const rrlib::rtti::tType& type) 
    128127{ 
    129   internal::tIndexAnnotation* annotation = type.GetAnnotation<internal::tIndexAnnotation>(); 
    130   if (annotation) 
     128  internal::tIndexAnnotation annotation = type.GetAnnotation<internal::tIndexAnnotation>(); 
     129  if (annotation.index) 
    131130  { 
    132     return annotation->index; 
     131    return annotation.index - 1; 
    133132  } 
    134133 
     
    155154  reg.registered_types++; 
    156155  rrlib::rtti::tType type_copy = type; 
    157   type_copy.AddAnnotation(new internal::tIndexAnnotation(result)); 
     156  type_copy.AddAnnotation(internal::tIndexAnnotation(result + 1)); // +1 so that index zero is different from Null-memory 
    158157  if (result >= cMAX_CHEAPLY_COPYABLE_TYPES) 
    159158  { 
  • optimized/tCheapCopyPort.cpp

    r101 r106  
    8080  if (creation_info.DefaultValueSet() || creation_info.flags.Get(core::tFrameworkElement::tFlag::DEFAULT_ON_DISCONNECT)) 
    8181  { 
    82     rrlib::rtti::tGenericObject* result = creation_info.data_type.CreateInstanceGeneric(); 
     82    rrlib::rtti::tGenericObject* result = creation_info.data_type.CreateGenericObject(); 
    8383    if (creation_info.DefaultValueSet()) 
    8484    { 
     
    122122  else 
    123123  { 
    124     std::unique_ptr<rrlib::rtti::tGenericObject> object_with_default_value(GetDataType().CreateInstanceGeneric()); 
     124    std::unique_ptr<rrlib::rtti::tGenericObject> object_with_default_value(GetDataType().CreateGenericObject()); 
    125125    initial->GetObject().DeepCopyFrom(*object_with_default_value); 
    126126  } 
     
    263263  { 
    264264    tLockingManagerPointer dc = PullValueRaw(strategy == tStrategy::PULL_IGNORING_HANDLER_ON_THIS_PORT); 
    265     buffer.DeepCopyFrom(dc->GetObject(), NULL); 
     265    buffer.DeepCopyFrom(dc->GetObject()); 
    266266    timestamp = dc->GetTimestamp(); 
    267267  } 
     
    505505  if (!default_value) 
    506506  { 
    507     default_value.reset(new_default.GetType().CreateInstanceGeneric()); 
     507    default_value.reset(new_default.GetType().CreateGenericObject()); 
    508508  } 
    509509  else if (default_value->GetType() != new_default.GetType()) 
  • optimized/tCheaplyCopiedBufferManager.cpp

    r46 r106  
    8787  static_assert(sizeof(tCheaplyCopiedBufferManager) % 8 == 0, "Port Data manager must be aligned to 8 byte boundary"); 
    8888  char* placement = (char*)operator new(sizeof(tCheaplyCopiedBufferManager) + type.GetSize(true)); 
    89   type.CreateInstanceGeneric(placement + sizeof(tCheaplyCopiedBufferManager)); 
     89  type.EmplaceGenericObject(placement + sizeof(tCheaplyCopiedBufferManager)).release(); 
    9090  return new(placement) tCheaplyCopiedBufferManager(); 
    9191} 
  • optimized/tSingleThreadedCheapCopyPortGeneric.cpp

    r103 r106  
    7777  standard_assign(!GetFlag(tFlag::NON_STANDARD_ASSIGN) && (!GetFlag(tFlag::HAS_QUEUE))) 
    7878{ 
    79   current_value.data.reset(creation_info.data_type.CreateInstanceGeneric()); 
     79  current_value.data.reset(creation_info.data_type.CreateGenericObject()); 
    8080  current_value.data_pointer = current_value.data->GetRawDataPointer(); 
    8181  current_value.cheaply_copyable_type_index = RegisterPort(creation_info.data_type); 
     
    9191  if (creation_info.DefaultValueSet() || creation_info.flags.Get(core::tFrameworkElement::tFlag::DEFAULT_ON_DISCONNECT)) 
    9292  { 
    93     default_value.reset(creation_info.data_type.CreateInstanceGeneric()); 
     93    default_value.reset(creation_info.data_type.CreateGenericObject()); 
    9494    if (creation_info.DefaultValueSet()) 
    9595    { 
     
    192192void tSingleThreadedCheapCopyPortGeneric::SetCurrentValueBuffer(void* address) 
    193193{ 
    194   std::unique_ptr<rrlib::rtti::tGenericObject> new_buffer(GetDataType().CreateInstanceGeneric(address, false)); 
     194  std::unique_ptr<rrlib::rtti::tGenericObject> new_buffer(GetDataType().CreateGenericObject(address)); 
    195195  new_buffer->DeepCopyFrom(*current_value.data); 
    196196  std::swap(new_buffer, current_value.data); 
     
    200200void tSingleThreadedCheapCopyPortGeneric::SetDefault(rrlib::rtti::tGenericObject& new_default) 
    201201{ 
    202   default_value.reset(new_default.GetType().CreateInstanceGeneric()); 
     202  default_value.reset(new_default.GetType().CreateGenericObject()); 
    203203  default_value->DeepCopyFrom(new_default); 
    204204  current_value.data->DeepCopyFrom(new_default); 
  • optimized/tThreadLocalBufferManager.cpp

    r69 r106  
    8585  static_assert(sizeof(tThreadLocalBufferManager) % 8 == 0, "Port Data manager must be aligned to 8 byte boundary"); 
    8686  char* placement = (char*)operator new(sizeof(tThreadLocalBufferManager) + type.GetSize(true)); 
    87   type.CreateInstanceGeneric(placement + sizeof(tThreadLocalBufferManager)); 
     87  type.EmplaceGenericObject(placement + sizeof(tThreadLocalBufferManager)).release(); 
    8888  return new(placement) tThreadLocalBufferManager(); 
    8989} 
  • standard/tPortBufferManager.cpp

    r88 r106  
    8585  static_assert(sizeof(tPortBufferManager) % 8 == 0, "Port Data manager must be aligned to 8 byte boundary"); 
    8686  char* placement = (char*)operator new(sizeof(tPortBufferManager) + type.GetSize(true)); 
    87   type.CreateInstanceGeneric(placement + sizeof(tPortBufferManager)); 
     87  type.EmplaceGenericObject(placement + sizeof(tPortBufferManager)).release(); 
    8888  return new(placement) tPortBufferManager(); 
    8989} 
  • tGenericPort.h

    r103 r106  
    167167    { 
    168168      tPortDataPointer<rrlib::rtti::tGenericObject> buffer = GetUnusedBuffer(); 
    169       std::unique_ptr<rrlib::rtti::tGenericObject> default_buffer(buffer->GetType().CreateInstanceGeneric()); 
     169      std::unique_ptr<rrlib::rtti::tGenericObject> default_buffer(buffer->GetType().CreateGenericObject()); 
    170170      buffer->DeepCopyFrom(*default_buffer); 
    171171      BrowserPublish(buffer); 
  • tests/initial_pushing.cpp

    r67 r106  
    148148  core::tFrameworkElement::InitAll(); 
    149149  o0.Publish(test_values[5]); 
    150   o0.ConnectTo(o1, core::tAbstractPort::tConnectDirection::TO_TARGET); 
     150  o0.ConnectTo(o1, core::tConnectionFlag::DIRECTION_TO_DESTINATION); 
    151151  CheckPortValue(o3, test_values[5]); 
    152152 
     
    158158  core::tFrameworkElement::InitAll(); 
    159159  o4.ConnectTo(o5); 
    160   o2.ConnectTo(o4, core::tAbstractPort::tConnectDirection::TO_TARGET); 
     160  o2.ConnectTo(o4, core::tConnectionFlag::DIRECTION_TO_DESTINATION); 
    161161  CheckPortValue(o5, test_values[5]); 
    162162  tOutputPort<T> o6("o6", parent); 
     
    177177  o7.ConnectTo(o8); 
    178178  CheckPortValue(o8, test_values[7]); 
    179   o7.ConnectTo(o1, core::tAbstractPort::tConnectDirection::TO_TARGET); 
     179  o7.ConnectTo(o1, core::tConnectionFlag::DIRECTION_TO_DESTINATION); 
    180180  CheckPortValue(o1, test_values[6]); 
    181181 
  • tests/test_collection.cpp

    r103 r106  
    195195    void OnPortChange(const rrlib::rtti::tGenericObject& value, tChangeContext& change_context) 
    196196    { 
    197       FINROC_LOG_PRINT(DEBUG_VERBOSE_1, "  Port Changed Generic: ", value); 
     197      rrlib::serialization::tStringOutputStream stream; 
     198      value.Serialize(stream); 
     199      FINROC_LOG_PRINT(DEBUG_VERBOSE_1, "  Port Changed Generic: ", stream.ToString()); 
    198200      this->calls++; 
    199201    } 
    200202    void OnPortChange(tPortDataPointer<const rrlib::rtti::tGenericObject>& value, tChangeContext& change_context) 
    201203    { 
    202       FINROC_LOG_PRINT(DEBUG_VERBOSE_1, "  Port Changed Generic (tPortDataPointer): ", *value); 
     204      rrlib::serialization::tStringOutputStream stream; 
     205      value->Serialize(stream); 
     206      FINROC_LOG_PRINT(DEBUG_VERBOSE_1, "  Port Changed Generic (tPortDataPointer): ", stream.ToString()); 
    203207      this->calls++; 
    204208    } 
Note: See TracChangeset for help on using the changeset viewer.