RDM::TIME_SERIES::scale< RATIO, NEXT > Class Template Reference

Template Class for scaling. More...

#include "rdm_time_series_scale.h"

Public Member Functions

RDM_RETCODE init (RDM_DB db)
Initialize this object. More...
void reset (void)
Reset this object. More...
RDM_RETCODE flush_value (uint32_t threshold=1, RDM::DB::TRANSACTIONAL_T transactional=RDM::DB::NOT_TRANSACTIONAL)
Flush this object. More...
RDM_RETCODE flush_stats (uint32_t threshold=1, RDM::DB::TRANSACTIONAL_T transactional=RDM::DB::NOT_TRANSACTIONAL)
Flush this object. More...
RDM_RETCODE flush_range (uint32_t threshold=1, RDM::DB::TRANSACTIONAL_T transactional=RDM::DB::NOT_TRANSACTIONAL)
Flush this object. More...
template<class SOURCE_VALUE_T >
RDM_RETCODE put_value (SOURCE_VALUE_T *source_value, RDM::DB::TRANSACTIONAL_T transactional=RDM::DB::NOT_TRANSACTIONAL)
Template method for receiving a data value. More...
template<class SOURCE_STATS_T >
RDM_RETCODE put_stats (SOURCE_STATS_T *source_stats, RDM::DB::TRANSACTIONAL_T transactional=RDM::DB::NOT_TRANSACTIONAL)
Template method for receiving statistics. More...
template<class SOURCE_RANGE_T >
RDM_RETCODE put_range (SOURCE_RANGE_T *source_range, RDM::DB::TRANSACTIONAL_T transactional=RDM::DB::NOT_TRANSACTIONAL)
Template method for receiving ranges. More...

Friends

template<class ANY_NEXT >
class RDM::DB::transaction
template<class ANY_NEXT_1 , class ANY_NEXT_2 >
class split
template<uint32_t ANY_N, class ANY_RANGE_T , class ANY_NEXT >
class collect
template<uint32_t ANY_N, class ANY_RANGE_T , class ANY_INDATA_T , class ANY_NEXT >
class fft
template<uint32_t ANY_N, class ANY_AGGREGATE_T , class ANY_AGG_ELEMENT_T , class ANY_NEXT >
class mean
template<class ANY_RATIO , class ANY_NEXT >
class scale
template<uint32_t ANY_N, class ANY_STATS_T , class ANY_NEXT >
class stats
template<uint32_t ANY_N, class ANY_NEXT >
class downsample
template<class ANY_NEXT >
class custom

Detailed Description

template<class RATIO, class NEXT>
class RDM::TIME_SERIES::scale< RATIO, NEXT >

Template Class for scaling.

Template class for scaling data values, ranges, or statistics. What is received by this class will be scaled by a ration. The scaled result will be forwarded to the next class in the chain.

Upon destruction of this class, there might be incomplete aggregations that have not yet been passed to the next class in the chain. flush() can be called to force those incomplete aggregations to be sent to the next class. This approach may not always be desirable. Another approach is to restore the state of this class the next time this class is instantiated. See restore_aggregate for details.

Template Parameters
RATIO The ratio to scale by.
NEXT The class in the chain to receive scaled data values, ranges, or statistics.
Examples
time_series_fft.cpp.

Member Function Documentation

flush_range()

template<class RATIO , class NEXT >
RDM_RETCODE RDM::TIME_SERIES::scale< RATIO, NEXT >::flush_range ( uint32_t threshold = 1,
RDM::DB::TRANSACTIONAL_T transactional = RDM::DB::NOT_TRANSACTIONAL
)
inline

Flush this object.

Call this method to flush what has been collected so far. A threshold can also be provided. All the data collected for those ranges will be kept as is. The same is the case where the threshold has not been reached.

This operation can be specified as being transactional. However, if the caller always rolls back the transaction in the case of a failure, there is no need to specify single operations to be transactional.

Return values
sOKAY Normal, successful return.
eNOSTARTUPDATE An update operation was attempted when no rdm_dbStartUpdate() is active.
eNOTLOCKED Attempt to access a table for reading or update without proper locks.
eCURSORDB Cursor is associated with a different database.
eDBNOTOPEN Database not open.
ePRECOMMITTED A precommitted transaction must be committed or rolled back before further operations on this database are allowed.
eDUPLICATE Attempt to insert a duplicate value as a unique/primary key.
eREADONLY Database is read-only and cannot be updated.
eREFINTEGRITY Integrity constraint violation.
eROWLIMIT Table row limit reached.
eINVARG Invalid argument.
Parameters
threshold [IN] Only flush objects where at least this many elements have been collected
transactional [IN] Is the flush required to be transactional
290 {
291RDM_RETCODE rc = next.flush_range (threshold, transactional);
292
293return rc;
294 }

flush_stats()

template<class RATIO , class NEXT >
RDM_RETCODE RDM::TIME_SERIES::scale< RATIO, NEXT >::flush_stats ( uint32_t threshold = 1,
RDM::DB::TRANSACTIONAL_T transactional = RDM::DB::NOT_TRANSACTIONAL
)
inline

Flush this object.

Call this method to flush what has been collected so far. A threshold can also be provided. All the data collected for those statistics will be kept as is. The same is the case where the threshold has not been reached.

This operation can be specified as being transactional. However, if the caller always rolls back the transaction in the case of a failure, there is no need to specify single operations to be transactional.

Return values
sOKAY Normal, successful return.
eNOSTARTUPDATE An update operation was attempted when no rdm_dbStartUpdate() is active.
eNOTLOCKED Attempt to access a table for reading or update without proper locks.
eCURSORDB Cursor is associated with a different database.
eDBNOTOPEN Database not open.
ePRECOMMITTED A precommitted transaction must be committed or rolled back before further operations on this database are allowed.
eDUPLICATE Attempt to insert a duplicate value as a unique/primary key.
eREADONLY Database is read-only and cannot be updated.
eREFINTEGRITY Integrity constraint violation.
eROWLIMIT Table row limit reached.
eINVARG Invalid argument.
Parameters
threshold [IN] Only flush objects where at least this many elements have been collected
transactional [IN] Is the flush required to be transactional
256 {
257RDM_RETCODE rc = next.flush_stats (threshold, transactional);
258
259return rc;
260 }

flush_value()

template<class RATIO , class NEXT >
RDM_RETCODE RDM::TIME_SERIES::scale< RATIO, NEXT >::flush_value ( uint32_t threshold = 1,
RDM::DB::TRANSACTIONAL_T transactional = RDM::DB::NOT_TRANSACTIONAL
)
inline

Flush this object.

Call this method to flush what has been collected so far. A threshold can also be provided. All the data collected for those values will be kept as is. The same is the case where the threshold has not been reached.

This operation can be specified as being transactional. However, if the caller always rolls back the transaction in the case of a failure, there is no need to specify single operations to be transactional.

Return values
sOKAY Normal, successful return.
eNOSTARTUPDATE An update operation was attempted when no rdm_dbStartUpdate() is active.
eNOTLOCKED Attempt to access a table for reading or update without proper locks.
eCURSORDB Cursor is associated with a different database.
eDBNOTOPEN Database not open.
ePRECOMMITTED A precommitted transaction must be committed or rolled back before further operations on this database are allowed.
eDUPLICATE Attempt to insert a duplicate value as a unique/primary key.
eREADONLY Database is read-only and cannot be updated.
eREFINTEGRITY Integrity constraint violation.
eROWLIMIT Table row limit reached.
eINVARG Invalid argument.
Parameters
threshold [IN] Only flush objects where at least this many elements have been collected
transactional [IN] Is the flush required to be transactional
222 {
223RDM_RETCODE rc = next.flush_value (threshold, transactional);
224
225return rc;
226 }

init()

template<class RATIO , class NEXT >
RDM_RETCODE RDM::TIME_SERIES::scale< RATIO, NEXT >::init ( RDM_DB db )
inline

Initialize this object.

Call this method before sending it any data values, ranges, or statistics.

Return values
sOKAY Normal, successful return.
eINVARG Invalid argument.
eDBNOTOPEN Database not open.
eCURSORDB Cursor is associated with a different database.
ePRECOMMITTED A precommitted transaction must be committed or rolled back before further operations on this database are allowed.
Parameters
db [IN] Use this database for chained classes that need to insert rows
177 {
178RDM_RETCODE rc = next.init (db);
179
180return rc;
181 }

put_range()

template<class RATIO , class NEXT >
template<class SOURCE_RANGE_T >
RDM_RETCODE RDM::TIME_SERIES::scale< RATIO, NEXT >::put_range ( SOURCE_RANGE_T * source_range,
RDM::DB::TRANSACTIONAL_T transactional = RDM::DB::NOT_TRANSACTIONAL
)
inline

Template method for receiving ranges.

Receive one range and process it accordingly.

The type for the value provided is required to have columns for 'time_stamp_first', 'time_stamp_last', and 'value_range' with appropriate types. The column 'value_range' must be an array that is able to hold a static number of elements. Such a type can be generated using rdm-compile with a schema including a table similar to this:

CREATE TABLE range
(
value_range DOUBLE ARRAY [32] NOT NULL,
time_stamp_first UINT64 NOT NULL,
time_stamp_last UINT64 PRIMARY KEY
);

This operation can be specified as being transactional. However, if the caller always rolls back the transaction in the case of a failure, there is no need to specify single operations to be transactional.

Template Parameters
SOURCE_RANGE_T The actual type of the range received.
Return values
sOKAY Normal, successful return.
eNOSTARTUPDATE An update operation was attempted when no rdm_dbStartUpdate() is active.
eNOTLOCKED Attempt to access a table for reading or update without proper locks.
eCURSORDB Cursor is associated with a different database.
eDBNOTOPEN Database not open.
ePRECOMMITTED A precommitted transaction must be committed or rolled back before further operations on this database are allowed.
eDUPLICATE Attempt to insert a duplicate value as a unique/primary key.
eREADONLY Database is read-only and cannot be updated.
eREFINTEGRITY Integrity constraint violation.
eROWLIMIT Table row limit reached.
eINVARG Invalid argument.
Parameters
[in] source_range The source range sent to this class
transactional [IN] Is the put required to be transactional
446 {
447 SOURCE_RANGE_T scaled_range;
448
449 scale_range (source_range, scaled_range);
450RDM_RETCODE rc = next.put_range (&scaled_range, transactional);
451
452return rc;
453 }

put_stats()

template<class RATIO , class NEXT >
template<class SOURCE_STATS_T >
RDM_RETCODE RDM::TIME_SERIES::scale< RATIO, NEXT >::put_stats ( SOURCE_STATS_T * source_stats,
RDM::DB::TRANSACTIONAL_T transactional = RDM::DB::NOT_TRANSACTIONAL
)
inline

Template method for receiving statistics.

Receive one statistic and process it accordingly.

The type for the value provided is required to have columns for 'time_stamp_first', 'time_stamp_last', 'n', 'value_sum', and 'value_sum2' with appropriate types. Such a type can be generated using rdm-compile with a schema including a table similar to this:

CREATE TABLE stats
(
time_stamp_first UINT64 NOT NULL,
time_stamp_last UINT64 PRIMARY KEY,
n UINT64 NOT NULL,
value_sum DOUBLE NOT NULL,
value_sum2 DOUBLE NOT NULL
);

This operation can be specified as being transactional. However, if the caller always rolls back the transaction in the case of a failure, there is no need to specify single operations to be transactional.

Template Parameters
SOURCE_STATS_T The actual type of the statistic received.
Return values
sOKAY Normal, successful return.
eNOSTARTUPDATE An update operation was attempted when no rdm_dbStartUpdate() is active.
eNOTLOCKED Attempt to access a table for reading or update without proper locks.
eCURSORDB Cursor is associated with a different database.
eDBNOTOPEN Database not open.
ePRECOMMITTED A precommitted transaction must be committed or rolled back before further operations on this database are allowed.
eDUPLICATE Attempt to insert a duplicate value as a unique/primary key.
eREADONLY Database is read-only and cannot be updated.
eREFINTEGRITY Integrity constraint violation.
eROWLIMIT Table row limit reached.
eINVARG Invalid argument.
Parameters
[in] source_stats The source statistics sent to this class
transactional [IN] Is the put required to be transactional
392 {
393 SOURCE_STATS_T scaled_stats;
394
395 scale_stats (source_stats, scaled_stats);
396RDM_RETCODE rc = next.put_stats (&scaled_stats, transactional);
397
398return rc;
399 }

put_value()

template<class RATIO , class NEXT >
template<class SOURCE_VALUE_T >
RDM_RETCODE RDM::TIME_SERIES::scale< RATIO, NEXT >::put_value ( SOURCE_VALUE_T * source_value,
RDM::DB::TRANSACTIONAL_T transactional = RDM::DB::NOT_TRANSACTIONAL
)
inline

Template method for receiving a data value.

Receive one data value and process it accordingly.

The type for the value provided is required to have columns for 'time_stamp_current' and 'value_current' with appropriate types. Such a type can be generated using rdm-compile with a schema including a table similar to this:

CREATE TABLE measurement
(
time_stamp_current UINT64 PRIMARY KEY,
value_current DOUBLE NOT NULL
);

This operation can be specified as being transactional. However, if the caller always rolls back the transaction in the case of a failure, there is no need to specify single operations to be transactional.

Template Parameters
SOURCE_VALUE_T The actual type of the source values received
Return values
sOKAY Normal, successful return.
eNOSTARTUPDATE An update operation was attempted when no rdm_dbStartUpdate() is active.
eNOTLOCKED Attempt to access a table for reading or update without proper locks.
eCURSORDB Cursor is associated with a different database.
eDBNOTOPEN Database not open.
ePRECOMMITTED A precommitted transaction must be committed or rolled back before further operations on this database are allowed.
eDUPLICATE Attempt to insert a duplicate value as a unique/primary key.
eREADONLY Database is read-only and cannot be updated.
eREFINTEGRITY Integrity constraint violation.
eROWLIMIT Table row limit reached.
eINVARG Invalid argument.
Parameters
[in] source_value The source value sent to this class
transactional [IN] Is the put required to be transactional
338 {
339 SOURCE_VALUE_T scaled_value;
340
341 scale_value (source_value, scaled_value);
342RDM_RETCODE rc = next.put_value (&scaled_value, transactional);
343
344return rc;
345 }

reset()

template<class RATIO , class NEXT >
void RDM::TIME_SERIES::scale< RATIO, NEXT >::reset ( void )
inline

Reset this object.

Call this method to discard all internally kept data values, ranges, and statistics that have not yet been persisted and start over from scratch.

190 {
191 next.reset ();
192 }

Friends And Related Function Documentation

collect

template<class RATIO , class NEXT >
template<uint32_t ANY_N, class ANY_RANGE_T , class ANY_NEXT >
friend class collect
friend

custom

template<class RATIO , class NEXT >
template<class ANY_NEXT >
friend class custom
friend

downsample

template<class RATIO , class NEXT >
template<uint32_t ANY_N, class ANY_NEXT >
friend class downsample
friend

fft

template<class RATIO , class NEXT >
template<uint32_t ANY_N, class ANY_RANGE_T , class ANY_INDATA_T , class ANY_NEXT >
friend class fft
friend

mean

template<class RATIO , class NEXT >
template<uint32_t ANY_N, class ANY_AGGREGATE_T , class ANY_AGG_ELEMENT_T , class ANY_NEXT >
friend class mean
friend

RDM::DB::transaction

template<class RATIO , class NEXT >
template<class ANY_NEXT >
friend class RDM::DB::transaction
friend

scale

template<class RATIO , class NEXT >
template<class ANY_RATIO , class ANY_NEXT >
friend class scale
friend

split

template<class RATIO , class NEXT >
template<class ANY_NEXT_1 , class ANY_NEXT_2 >
friend class split
friend

stats

template<class RATIO , class NEXT >
template<uint32_t ANY_N, class ANY_STATS_T , class ANY_NEXT >
friend class stats
friend

The documentation for this class was generated from the following files:
RDM_RETCODE
RDM status and error return codes.
Definition: rdmretcodetypes.h:44