Changeset 186:bf8a796dc6b6 in finroc_plugins_data_ports
- Timestamp:
- 08.02.2022 07:36:55 (22 months ago)
- Branch:
- 17.03
- Phase:
- public
- Tags:
- tip
- Location:
- common
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
common/tConversionConnector.cpp
r173 r186 72 72 tConversionConnector::tConversionConnector(core::tAbstractPort& source_port, core::tAbstractPort& destination_port, const core::tConnectOptions& connect_options) : 73 73 tConnector(source_port, destination_port, connect_options, conversion_operation), 74 conversion_operation(connect_options.conversion_operations.Compile(false, source_port.GetDataType(), destination_port.GetDataType() ))74 conversion_operation(connect_options.conversion_operations.Compile(false, source_port.GetDataType(), destination_port.GetDataType(), typeid(tDestinationPointer))) 75 75 { 76 76 static_assert(sizeof(destination_port_generic_memory) == sizeof(tGenericPort), "Adjust array size"); … … 82 82 {} 83 83 84 void tConversionConnector::Publish(const rrlib::rtti::tGenericObject& input_data, const rrlib::time::tTimestamp& timestamp, tChangeStatus change_constant) const84 void tConversionConnector::Publish(const rrlib::rtti::tGenericObject& input_data, const rrlib::time::tTimestamp& input_timestamp, tChangeStatus change_constant) const 85 85 { 86 86 try … … 88 88 tGenericPort& generic_port = const_cast<tGenericPort&>(reinterpret_cast<const tGenericPort&>(destination_port_generic_memory[0])); 89 89 tPortDataPointer<rrlib::rtti::tGenericObject> buffer = generic_port.GetUnusedBuffer(); 90 buffer.SetTimestamp(timestamp); 91 conversion_operation.Convert(input_data, *buffer); 92 generic_port.BrowserPublish(buffer, true, change_constant); 90 rrlib::time::tTimestamp timestamp = input_timestamp; 91 bool skip = false; 92 tDestinationPointer destination_pointer(*buffer, timestamp, skip); 93 conversion_operation.Convert(input_data, destination_pointer); 94 if (!skip) 95 { 96 buffer.SetTimestamp(timestamp); 97 generic_port.BrowserPublish(buffer, true, change_constant); 98 } 93 99 } 94 100 catch (const std::exception& e) -
common/tConversionConnector.h
r173 r186 96 96 97 97 98 /*! Destination Pointer used in tConversionConnector 99 * 100 * Provides additional settings with respect to published buffer to conversion operations 101 */ 102 class tDestinationPointer : public rrlib::rtti::tTypedPointer 103 { 104 public: 105 106 tDestinationPointer(const tTypedPointer& pointer, rrlib::time::tTimestamp& timestamp, bool& skip) : 107 tTypedPointer(pointer), 108 timestamp(timestamp), 109 skip(skip) 110 {} 111 112 // Convenience constructor for use in conversion operation implementations' first conversion function 113 tDestinationPointer(const tTypedPointer& pointer, const tDestinationPointer& share_additional_settings_with) : 114 tDestinationPointer(pointer, share_additional_settings_with.timestamp, share_additional_settings_with.skip) 115 {} 116 117 118 /*! 119 * \return Destination timestamp 120 */ 121 rrlib::time::tTimestamp& Timestamp() const 122 { 123 return timestamp; 124 } 125 126 /*! 127 * \return Whether to skip converting this value 128 */ 129 bool& Skip() const 130 { 131 return skip; 132 } 133 134 private: 135 136 /*! Destination timestamp (set to timestamp input data buffer by default) */ 137 rrlib::time::tTimestamp& timestamp; 138 139 /*! Whether to skip converting this value (without printing a warning; similar but somewhat more efficient than throwing tSilentConversionException) */ 140 bool& skip; 141 }; 142 98 143 class tSilentConversionException : public std::exception 99 {}; 144 { 145 }; 100 146 101 147 //----------------------------------------------------------------------
Note: See TracChangeset
for help on using the changeset viewer.