Changeset 134:fae78f2f7787 in finroc_plugins_data_ports


Ignore:
Timestamp:
30.09.2018 15:18:52 (10 months ago)
Author:
Max Reichardt <mreichardt@…>
Branch:
14.08
Children:
135:fd179b075769, 136:c3e65240f9fd
Phase:
public
Message:

Adds Dequeue method to generic ports in order to support input queues in generic ports

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • api/tGenericPortImplementation.cpp

    r69 r134  
    314314} 
    315315 
     316void tGenericPortImplementation::DequeueAllBuffers(core::tAbstractPort& port, std::vector<tPortDataPointer<const rrlib::rtti::tGenericObject>>& result_buffer) 
     317{ 
     318  result_buffer.clear(); 
     319  if (IsCheaplyCopiedType(port.GetDataType())) 
     320  { 
     321    auto buffers = static_cast<tCheapCopyPort&>(port).DequeueAllRaw(); 
     322    while (!buffers.Empty()) 
     323    { 
     324      auto buffer = buffers.PopFront(); 
     325      tPortDataPointerImplementation<rrlib::rtti::tGenericObject, false> pointer(buffer->locked_buffer.release(), false); 
     326      result_buffer.emplace_back(std::move(pointer)); 
     327    } 
     328  } 
     329  else 
     330  { 
     331    auto buffers = static_cast<standard::tStandardPort&>(port).DequeueAllRaw(); 
     332    while (!buffers.Empty()) 
     333    { 
     334      auto buffer = buffers.PopFront(); 
     335      tPortDataPointerImplementation<rrlib::rtti::tGenericObject, false> pointer(buffer->locked_buffer.release(), false); 
     336      result_buffer.emplace_back(std::move(pointer)); 
     337    } 
     338  } 
     339} 
     340 
    316341void tGenericPortImplementation::SetPullRequestHandler(core::tAbstractPort& port, tPullRequestHandler<rrlib::rtti::tGenericObject>* pull_request_handler) 
    317342{ 
  • api/tGenericPortImplementation.h

    r69 r134  
    9090   */ 
    9191  virtual core::tAbstractPort* CreatePort(const common::tAbstractDataPortCreationInfo& creation_info) = 0; 
     92 
     93  /*! 
     94   * Dequeue all elements currently in input queue 
     95   * 
     96   * \param result_buffer Vector to fill with dequeued buffers (any contents in vector when calling this method are discarded) 
     97   */ 
     98  void DequeueAllBuffers(core::tAbstractPort& port, std::vector<tPortDataPointer<const rrlib::rtti::tGenericObject>>& result_buffer); 
    9299 
    93100  /*! 
  • tGenericPort.h

    r78 r134  
    182182 
    183183  /*! 
     184   * Dequeue all elements currently in input queue 
     185   * 
     186   * \param result_buffer Vector to fill with dequeued buffers (any contents in vector when calling this method are discarded) 
     187   */ 
     188  void DequeueAllBuffers(std::vector<tPortDataPointer<const rrlib::rtti::tGenericObject>>& result_buffer) 
     189  { 
     190    implementation->DequeueAllBuffers(*GetWrapped(), result_buffer); 
     191  } 
     192 
     193  /*! 
    184194   * Gets port's current value 
    185195   * 
Note: See TracChangeset for help on using the changeset viewer.