Changeset 141:76a6d44547fb in finroc_plugins_data_ports


Ignore:
Timestamp:
19.07.2019 11:45:56 (2 months ago)
Author:
Max Reichardt <max.reichardt@…>
Branch:
17.03
Children:
142:fbf566b7209e, 143:d5ea7a4f9bbf
Parents:
138:b4ec8fe1d2ef (diff), 140:aca37ccb431b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Phase:
public
Message:

Merge with 14.08

Files:
2 edited

Legend:

Unmodified
Added
Removed
  • tGenericPort.h

    r135 r141  
    256256  inline tPortDataPointer<rrlib::rtti::tGenericObject> GetUnusedBuffer() 
    257257  { 
    258     return implementation->GetUnusedBuffer(*GetWrapped()); 
     258    auto result = implementation->GetUnusedBuffer(*GetWrapped()); 
     259    result.SetTimestamp(rrlib::time::cNO_TIME); 
     260    return result; 
    259261  } 
    260262 
  • tGenericPort.h

    r140 r141  
    4848//---------------------------------------------------------------------- 
    4949#include "plugins/data_ports/api/tGenericPortImplementation.h" 
     50#include "plugins/data_ports/tEvent.h" 
    5051 
    5152//---------------------------------------------------------------------- 
     
    102103   * A tQueueSettings argument creates an input queue with the specified settings. 
    103104   * tBounds<T> are port's bounds. 
    104    * tUnit argument is port's unit. 
    105105   * tPortCreationBase argument is copied. This is only allowed as first argument. 
    106106   */ 
     
    124124   * 
    125125   * (It's preferred to add listeners before port is initialized) 
    126    * (Note: Buffer in 'value' always has data type of port backend (e.g. tNumber instead of double) 
    127126   */ 
    128127  template <typename TListener> 
     
    136135   * 
    137136   * (It's preferred to add listeners before port is initialized) 
    138    * (Note: Buffer in 'value' always has data type of port backend (e.g. tNumber instead of double) 
    139137   */ 
    140138  template <typename TListener> 
     
    151149  template <typename TListener> 
    152150  void AddPortListenerSimple(TListener& listener); 
     151 
     152  /*! 
     153   * Apply default value to port 
     154   * (not particularly efficient) 
     155   * 
     156   * apply_type_default_if_no_port_default_defined If no default value was set in constructor, use default of data type? (otherwise prints a warning) 
     157   */ 
     158  void ApplyDefault(bool apply_type_default_if_no_port_default_defined) 
     159  { 
     160    if (GetDefaultValue() || (!apply_type_default_if_no_port_default_defined)) 
     161    { 
     162      static_cast<common::tAbstractDataPort&>(*GetWrapped()).ApplyDefaultValue(); 
     163    } 
     164    else 
     165    { 
     166      tPortDataPointer<rrlib::rtti::tGenericObject> buffer = GetUnusedBuffer(); 
     167      std::unique_ptr<rrlib::rtti::tGenericObject> default_buffer(buffer->GetType().CreateGenericObject()); 
     168      buffer->DeepCopyFrom(*default_buffer); 
     169      BrowserPublish(buffer); 
     170    } 
     171  } 
    153172 
    154173  /*! 
     
    213232   * \return Buffer with port's current value with read lock. 
    214233   * 
    215    * Note: Buffer always has data type of port backend (e.g. tNumber instead of double) 
    216234   * If this is not desired, use pass-by-value-Get Operation above. 
    217235   */ 
     
    230248 
    231249  /*! 
    232    * Note: Buffer always has data type of port backend (e.g. tNumber instead of double) 
    233250   * If this is not desired, use pass-by-value-Publish Operation below. 
    234251   * 
     
    273290 
    274291  /*! 
     292   * Publish Data Buffer. This data will be forwarded to any connected ports. 
     293   * Should only be called on output ports. 
     294   * 
     295   * \param buffer Buffer with data to publish - typically acquired with GetUnuserBuffer() 
     296   */ 
     297  inline void Publish(tPortDataPointer<rrlib::rtti::tGenericObject>& buffer) 
     298  { 
     299    implementation->Publish(*GetWrapped(), buffer); 
     300  } 
     301 
     302  /*! 
    275303   * Set new bounds 
    276304   * (This is not thread-safe and must only be done in "pause mode") 
    277305   * 
    278    * \param b New Bounds 
     306   * \param min Minimum value 
     307   * \param max Maximum value 
    279308   */ 
    280309  inline void SetBounds(const rrlib::rtti::tGenericObject& min, const rrlib::rtti::tGenericObject& max) 
     
    296325   * 
    297326   * \param wrap Type-less tAbstractPort to wrap as tGenericPort 
    298    * \param use_backend_type_only Use only the internal data type that used in the port backend? (e.g. tNumber instead of double; relevant e.g. for Get() and Publish() methods) 
    299    */ 
    300   static tGenericPort Wrap(core::tAbstractPort& wrap, bool use_backend_type_only = false) 
     327   */ 
     328  static tGenericPort Wrap(core::tAbstractPort& wrap) 
    301329  { 
    302330    if (!IsDataFlowType(wrap.GetDataType())) 
     
    306334    tGenericPort port; 
    307335    port.SetWrapped(&wrap); 
    308     port.implementation = api::tGenericPortImplementation::GetImplementation( 
    309                             ((!use_backend_type_only) && wrap.GetWrapperDataType() != NULL) ? wrap.GetWrapperDataType() : wrap.GetDataType()); 
     336    port.implementation = api::tGenericPortImplementation::GetImplementation(wrap.GetDataType()); 
    310337    return port; 
    311338  } 
     339 
     340  static tGenericPort Wrap(core::tAbstractPort& wrap, bool unused) __attribute__((deprecated)) 
     341  { 
     342    return Wrap(wrap); 
     343  } 
     344 
    312345 
    313346//---------------------------------------------------------------------- 
Note: See TracChangeset for help on using the changeset viewer.