DUECA/DUSIME
Loading...
Searching...
No Matches
Public Member Functions | List of all members
dueca::StreamWriter< T, init > Class Template Reference

This is a light weight (on the stack) object to facilitate for writing stream data. More...

#include <StreamWriter.hxx>

Inheritance diagram for dueca::StreamWriter< T, init >:
Inheritance graph
[legend]
Collaboration diagram for dueca::StreamWriter< T, init >:
Collaboration graph
[legend]

Public Member Functions

 StreamWriter (StreamChannelWriteToken< T > &token, const TimeSpec &ts)
 Constructor.
 
 ~StreamWriter ()
 Destructor.
 
bool ok () const
 Check that the stream writing is OK.
 
- Public Member Functions inherited from dueca::DataWriter< T >
 DataWriter (ChannelWriteToken &token, const TimeSpec &ts)
 Constructor.
 
 DataWriter (ChannelWriteToken &token, const DataTimeSpec &ts)
 Constructor.
 
 DataWriter (ChannelWriteToken &token, const TimeTickType ts=SimTime::getTimeTick())
 Constructor with tick.
 
template<typename N1 >
 DataWriter (ChannelWriteToken &token, const TimeSpec &ts, N1 n1)
 Constructor.
 
template<typename N1 >
 DataWriter (ChannelWriteToken &token, const DataTimeSpec &ts, N1 n1)
 Constructor.
 
template<typename N1 >
 DataWriter (ChannelWriteToken &token, const TimeTickType &ts, N1 n1)
 Constructor.
 
template<typename N1 , typename N2 >
 DataWriter (ChannelWriteToken &token, const TimeSpec &ts, N1 n1, N2 n2)
 Constructor.
 
template<typename N1 , typename N2 >
 DataWriter (ChannelWriteToken &token, const DataTimeSpec &ts, N1 n1, N2 n2)
 Constructor.
 
template<typename N1 , typename N2 >
 DataWriter (ChannelWriteToken &token, const TimeTickType &ts, N1 n1, N2 n2)
 Constructor.
 
template<typename N1 , typename N2 , typename N3 >
 DataWriter (ChannelWriteToken &token, const TimeSpec &ts, N1 n1, N2 n2, N3 n3)
 Constructor.
 
template<typename N1 , typename N2 , typename N3 >
 DataWriter (ChannelWriteToken &token, const DataTimeSpec &ts, N1 n1, N2 n2, N3 n3)
 Constructor.
 
template<typename N1 , typename N2 , typename N3 >
 DataWriter (ChannelWriteToken &token, const TimeTickType &ts, N1 n1, N2 n2, N3 n3)
 Constructor.
 
Tdata ()
 Access the data in the channel, returns a reference to the data.
 
 ~DataWriter ()
 Destructor.
 

Additional Inherited Members

- Protected Member Functions inherited from dueca::DataWriterBase
 DataWriterBase (ChannelWriteToken &token, const DataTimeSpec &ts)
 Constructor.
 
void releaseAccess (void *data_ptr)
 Releasing the read access means that the data will be made accessible for reading.
 
void baseCheckAccess (uint32_t magic)
 Verify the magic number and validity for access.
 
- Protected Attributes inherited from dueca::DataWriterBase
ChannelWriteTokentoken
 Access to the channel.
 
DataTimeSpec ts
 Time specification to be used.
 

Detailed Description

template<class T, bool init = true>
class dueca::StreamWriter< T, init >

This is a light weight (on the stack) object to facilitate for writing stream data.

By creating a "StreamWriter", the access token is used to gain access to the data in the channel. The data() member of the StreamWriter can be used to write the proper data. When at the end of scope the StreamWriter is destroyed, the actual data is sent.

Template Parameters
TData type of the channel
initIf false, the newly written variable is not initialised using the default constructor. Default is true. Note that, to have any positive effect from this, the default values for the data type need to be specified in the dco file.

An example, suppose you have created a StreamChannelWriteToken for a channel with MyData objects:

// it is good practice to start with an opening bracket. This
// starts a new variable scope
{
// create the writer
// put the proper data in
w.data().a = some_value;
// etc. Note that you get cryptic error messages if you forget
// that data() is a function, and type "w.data.a"
// If you forget to assign a value to a member of w.data(), the
// value there will be undefined, unless you specified the
// default values for the constructor of the MyData type
} // <-- This closing bracket ends the "scope", in which
// StreamWriter<MyData> w was created. That means that at this
// point the destructor is called. The destructor actually sends
// the data over the channel.
const T & data()
Access to the data.
Definition DataReader.hxx:456
DataTimeSpec ts
Time specification to be used.
Definition DataWriter.hxx:32
This is a "light weight object" that enables you to read the latest set of data on a StreamChannelEnd...
Definition StreamReaderLatest.hxx:43

Constructor & Destructor Documentation

◆ StreamWriter()

template<class T , bool init = true>
dueca::StreamWriter< T, init >::StreamWriter ( StreamChannelWriteToken< T > & token,
const TimeSpec & ts )
inline

Constructor.

Gains access to the channel for which the token was made.

Parameters
tokenRead access token.
tsTime specification.

◆ ~StreamWriter()

template<class T , bool init = true>
dueca::StreamWriter< T, init >::~StreamWriter ( )
inline

Destructor.

Releases the access again with a token.

Member Function Documentation

◆ ok()

template<class T , bool init = true>
bool dueca::StreamWriter< T, init >::ok ( ) const
inline

Check that the stream writing is OK.

Only applicable in code without exceptions.


The documentation for this class was generated from the following file: