DUECA/DUSIME
Public Member Functions | List of all members
dueca::MultiStreamWriter< T > Class Template Reference

This is a facilitator for writing multi-stream data. More...

Public Member Functions

 MultiStreamWriter (MultiStreamWriteToken< T > &token, const TimeSpec &ts)
 Constructor. More...
 
 ~MultiStreamWriter ()
 Destructor. More...
 
bool ok ()
 Check that the stream writing is OK. More...
 

Detailed Description

template<class T>
class dueca::MultiStreamWriter< T >

This is a facilitator for writing multi-stream data.

By creating a "MultiStreamWriter", the access token is used to gain access to the data in the channel. When at the end of scope the MultiStreamWriter is destroyed, the access is released again, and the actual data is sent.

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

// it is good practice to start with an opening braket. This
// starts a new variable scope
{
// create the writer
MultiStreamWriter<MyData> w(my_multi_stream_write_token, ts);
// put the proper data in
w.data().a = some_value;
w.data().b = some_other_value;
// etc. Note that you get cryptic error messages if you forget
// that data() is a function, and type "w.data.a"
} // <-- This closing bracket ends the "scope", in which
// MultiStreamWriter<MyData> w was created. That means that at this
// point the destructor is called. The destructor actually sends
// the data over the channel.

MultiStream channels work differently from Event and Stream channels, in that the data written there is persistent. The next time you create a MultiStreamWriter on a channel, the data you had written before is present (and readable) in the Writer. If you want, you can limit yourself to only writing the changes.

Constructor & Destructor Documentation

◆ MultiStreamWriter()

template<class T >
dueca::MultiStreamWriter< T >::MultiStreamWriter ( MultiStreamWriteToken< T > &  token,
const TimeSpec ts 
)
inline

Constructor.

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

Parameters
tokenRead access token.
tsTime specification.

◆ ~MultiStreamWriter()

template<class T >
dueca::MultiStreamWriter< T >::~MultiStreamWriter ( )
inline

Destructor.

Releases the access again with a token.

Member Function Documentation

◆ ok()

template<class T >
bool dueca::MultiStreamWriter< T >::ok ( )
inline

Check that the stream writing is OK.

Only applicable in code without exceptions.


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