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

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

#include <DataUpdater.hxx>

Inheritance diagram for dueca::DataUpdater< T >:
Inheritance graph
[legend]
Collaboration diagram for dueca::DataUpdater< T >:
Collaboration graph
[legend]

Public Member Functions

 DataUpdater (ChannelWriteToken &token, const TimeSpec &ts)
 Constructor.
 
 DataUpdater (ChannelWriteToken &token, const DataTimeSpec &ts)
 Constructor.
 
 DataUpdater (ChannelWriteToken &token, const TimeTickType &ts)
 Constructor with tick.
 
Tdata ()
 Access the data in the channel, returns a reference to the data.
 
 ~DataUpdater ()
 Destructor.
 

Additional Inherited Members

- Protected Member Functions inherited from dueca::DataUpdaterBase
 DataUpdaterBase (ChannelWriteToken &token, const DataTimeSpec &ts)
 Constructor.
 
voidbaseGetAccess (uint32_t magic)
 Lets the token copy the latest data written (or, if not available, return a default object)
 
void releaseAccess (void *data_ptr)
 Releasing the read access means that the data will be sent to the channel and made accessible for reading.
 
- Protected Attributes inherited from dueca::DataUpdaterBase
ChannelWriteTokentoken
 Access to the channel.
 
DataTimeSpec ts
 Time specification to be used.
 

Detailed Description

template<class T>
class dueca::DataUpdater< T >

This is a facilitator for writing multi-stream data.

By creating a "DataUpdater", the access token is used to gain access to the data in the channel. A copy of the latest data written is returned to the updater. Using the data() accessor method, any changes to this data may be made. When at the end of scope the DataUpdater is destroyed, the access is released again, and the actual data is sent to the channel.

An example, suppose you have created a ChannelWriteToken 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
// 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"
} // <-- This closing bracket ends the "scope", in which
// DataUpdater<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 DataUpdater.hxx:30
This is a "light weight object" that enables you to read the latest set of data on a StreamChannelEnd...
Definition StreamReaderLatest.hxx:43

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

If you rather start from a blank/default object, use the DataWriter template, which will create an object for your modification, but always starts from clean, blank objects. Note that you should provide a proper definition of what is default when you write the .dco file defining your data type, otherwise the object's members are undefined.

Constructor & Destructor Documentation

◆ DataUpdater() [1/3]

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

Constructor.

Gains access to the channel for which the token was made. The accessed data will contain the latest written values.

Parameters
tokenWrite access token.
tsTime specification. The specification is used, to define the new data validity span, or only the start time is used if the token has been opened with Channel::Events for time aspect.

◆ DataUpdater() [2/3]

template<class T >
dueca::DataUpdater< T >::DataUpdater ( ChannelWriteToken & token,
const DataTimeSpec & ts )
inline

Constructor.

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

Parameters
tokenWrite access token.
tsTime specification.

◆ DataUpdater() [3/3]

template<class T >
dueca::DataUpdater< T >::DataUpdater ( ChannelWriteToken & token,
const TimeTickType & ts )
inline

Constructor with tick.

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

Note that using only a tick does not make sense with stream data, only use for event data!

Parameters
tokenWrite access token.
tsTime tick/moment.

◆ ~DataUpdater()

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

Destructor.

At destruction of the updater, the data is sent.


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