TReK C++  5.3.3
Telemetry/Command API
trek::CounterDependency Class Reference

This class determine a parameter's dependency based on a counter. More...

#include <counter_dependency.h>

Inherits trek::Dependency.

Public Member Functions

int32_t LoadFile (const char *filename)
 Loads the CounterDependency definition from the specified file. More...
 
int32_t SaveFile (const char *filename)
 Saves the CounterDependency definition to the specified file. More...
 
Constructors, Destructor, and Other Basic Methods
 CounterDependency ()
 Default constructor of the class.
 
 CounterDependency (CounterDependency &input)
 Copy constructor of the class.
 
virtual ~CounterDependency ()
 Class destructor. More...
 
virtual DependencyClone ()
 Creates and returns an extact copy of the object.
 
void operator= (CounterDependency &right_side)
 Provides the equal operator.
 
- Public Member Functions inherited from trek::Dependency
 Dependency ()
 Default constructor of the class.
 
 Dependency (Dependency &input)
 Copy constructor of the class.
 
virtual ~Dependency ()
 Class destructor. More...
 
void operator= (Dependency &right_side)
 Provides the equal operator.
 
virtual void Init ()
 Initializes the object.
 

Dependency Methods

int32_t Configure (const char *name, uint32_t mod_value, uint32_t remainder_value)
 Configures the counter dependency. More...
 
void SetStartCounter (uint32_t input)
 Sets a start counter for the dependency. More...
 
uint32_t GetModuloValue ()
 Returns the modulo value for the counter depenency.
 
uint32_t GetRemainderValue ()
 Returns the remainder value for the counter depenency.
 
uint32_t GetStartCounter ()
 Returns the start counter value for the counter depenency.
 
const char * GetDependencyParameter ()
 Returns the parameter to use for the counter.
 

Detailed Description

This class determine a parameter's dependency based on a counter.

For parameter X with a dependency on Parameter Y, the remainder from the modulo operator on the counter value (Y) determines if the parameter should be included.
value(Y) % mod_value == remainder

Constructor & Destructor Documentation

◆ ~CounterDependency()

trek::CounterDependency::~CounterDependency ( )
virtual

Class destructor.

Removes all resources created with this instance of the class.

Member Function Documentation

◆ Configure()

int32_t trek::CounterDependency::Configure ( const char *  name,
uint32_t  mod_value,
uint32_t  remainder_value 
)

Configures the counter dependency.

Sets the parameter to check for dependency as well as the required attributes. The parameter name is not checked on input for existence in the containing packet. This check will be performed when validation is available at the packet level.

Parameters
[in]nameThe name of the parameter whose value is checked.
[in]mod_valueThe modulo value.
[in]remainder_valueThe remainder that must match for the value % mod_value.
Returns
SUCCESS
TREK_DATA_NULL_PTR
TREK_DATA_REMAINDER_TOO_LARGE

Example:

ret_value = cd.Configure( "MyParameter", 10, 5 ); // if Value(MyParameter) % 10 == 5, dependency is met
if( ret_value )
; // process error
This class determine a parameter's dependency based on a counter.
Definition: counter_dependency.h:18
int32_t Configure(const char *name, uint32_t mod_value, uint32_t remainder_value)
Configures the counter dependency.
Definition: counter_dependency.cpp:90

◆ LoadFile()

int32_t trek::CounterDependency::LoadFile ( const char *  filename)

Loads the CounterDependency definition from the specified file.

Reads an XML format for the CounterDependency. It can be written in with SaveFile.

Parameters
[in]filenameThe file to load the parameter object from.
Returns
SUCCESS
TREK_DATA_NULL_PTR
Other return codes

Example:

ret_value = cd.LoadFile( "my_file.xml" );
int32_t LoadFile(const char *filename)
Loads the CounterDependency definition from the specified file.
Definition: counter_dependency.cpp:218

◆ SaveFile()

int32_t trek::CounterDependency::SaveFile ( const char *  filename)

Saves the CounterDependency definition to the specified file.

Writes an XML format for the CounterDependency. It can be read in with LoadFile.

Parameters
[in]filenameThe file to save the parameter object to.
Returns
SUCCESS
TREK_DATA_NULL_PTR
Other return codes

Example:

ret_value = cd.SaveFile( "my_file.xml" );
int32_t SaveFile(const char *filename)
Saves the CounterDependency definition to the specified file.
Definition: counter_dependency.cpp:253

◆ SetStartCounter()

void trek::CounterDependency::SetStartCounter ( uint32_t  input)

Sets a start counter for the dependency.

If a start counter is defined, then the dependency check will return false (fail) if the counter value is not greater than or equal to the value specified. The default start counter value is 0. Example:

ret_value = cd.Configure( "MyParameter", 10, 5 ); // if Value(MyParameter) % 10 == 5, dependency is met
if( ret_value )
; // process error
cd.SetStartCounter( 20 ); // value must be at least 20 before being met
void SetStartCounter(uint32_t input)
Sets a start counter for the dependency.
Definition: counter_dependency.cpp:124