39 #ifndef ORO_OUTPUT_PORT_HPP 40 #define ORO_OUTPUT_PORT_HPP 85 T
const& initial_sample =
sample->Get();
92 log(
Error) <<
"Failed to pass data sample to data channel. Aborting connection."<<
endlog();
141 OutputPort(std::string
const&
name =
"unnamed",
bool keep_last_written_value =
true)
144 , has_last_written_value(false)
145 , has_initial_sample(false)
146 , keeps_next_written_value(false)
147 , keeps_last_written_value(false)
150 if (keep_last_written_value)
158 keeps_next_written_value = keep;
163 keeps_last_written_value = keep;
175 return sample->
Get();
186 if (has_last_written_value)
188 this->sample->Get(sample);
211 this->sample->Set(sample);
212 has_initial_sample =
true;
213 has_last_written_value =
false;
218 log(
Error) <<
"A channel of port " <<
getName() <<
" has been invalidated during setDataSample(), it will be removed" <<
endlog();
229 has_last_written_value =
false;
234 if (shared_connection) {
235 shared_connection->clear();
245 if (keeps_last_written_value || keeps_next_written_value)
247 keeps_next_written_value =
false;
248 has_initial_sample =
true;
249 this->sample->Set(sample);
256 result =
getEndpoint()->getWriteEndpoint()->write(sample);
258 log(
Error) <<
"A channel of port " <<
getName() <<
" has been invalidated during write(), it will be removed" <<
endlog();
282 log(
Error) <<
"trying to write from an incompatible data source" <<
endlog();
319 #ifndef ORO_DISABLE_PORT_DATA_SCRIPTING 332 object->addSynchronousOperation(
"write", write_m,
this).doc(
"Writes a sample on the port.").arg(
"sample",
"");
333 object->addSynchronousOperation(
"last", last_m,
this).doc(
"Returns last written value to this port.");
341 return endpoint.get();
void setDataSample(const T &sample)
base::DataObjectInterface< T >::shared_ptr sample
boost::intrusive_ptr< ChannelElement< T > > shared_ptr
virtual result_t get() const =0
boost::intrusive_ptr< SharedConnectionBase > shared_ptr
WriteStatus write(base::DataSourceBase::shared_ptr source)
boost::shared_ptr< DataObjectInterface< T > > shared_ptr
OutputPort(std::string const &name="unnamed", bool keep_last_written_value=true)
virtual const types::TypeInfo * getTypeInfo() const
bool getLastWrittenValue(T &sample) const
void keepLastWrittenValue(bool keep)
bool has_initial_sample
True if sample has been written at least once, either by calling.
virtual FlowStatus Get(reference_t pull, bool copy_old_data=true) const =0
const std::string & getName() const
virtual base::PortInterface * clone() const
virtual internal::ConnInputEndpoint< T > * getEndpoint() const
virtual Service * createPortObject()
internal::ConnInputEndpoint< T >::shared_ptr endpoint
bool keeps_next_written_value
If true, the next call to write() will save the sample in sample.
bool has_last_written_value
True if sample has been set at least once by a call to write()
bool keeps_last_written_value
If true, all calls to write() will save the sample in sample.
virtual Service * createPortObject()
virtual const_reference_t rvalue() const =0
virtual bool createStream(ConnPolicy const &policy)
static bool createStream(OutputPort< T > &output_port, ConnPolicy const &policy)
bool createConnection(InputPortInterface &sink)
virtual bool connectionAdded(base::ChannelElementBase::shared_ptr channel_input, ConnPolicy const &policy)
bool keepsLastWrittenValue() const
WriteStatus write(const T &sample)
virtual bool connected() const
boost::intrusive_ptr< ChannelElementBase > shared_ptr
boost::intrusive_ptr< DataSource< T > > shared_ptr
boost::intrusive_ptr< AssignableDataSource< T > > shared_ptr
static const types::TypeInfo * getTypeInfo()
virtual base::ChannelElement< T >::shared_ptr getSharedBuffer() const
void keepNextWrittenValue(bool keep)
internal::ConnectionManager cmanager
virtual void disconnect()
virtual WriteStatus data_sample(param_t sample, bool reset=true)
boost::intrusive_ptr< DataSourceBase > shared_ptr
virtual WriteStatus write(param_t sample)
Contains TaskContext, Activity, OperationCaller, Operation, Property, InputPort, OutputPort, Attribute.
OutputPort & operator=(OutputPort const &orig)
T getLastWrittenValue() const
virtual base::DataSourceBase::shared_ptr getDataSource() const
static bool createConnection(OutputPort< T > &output_port, base::InputPortInterface &input_port, ConnPolicy const &policy)
virtual base::PortInterface * antiClone() const
OutputPort(OutputPort const &orig)
static Logger::LogFunction endlog()
virtual bool createConnection(base::InputPortInterface &input_port, ConnPolicy const &policy)
internal::SharedConnectionBase::shared_ptr getSharedConnection() const