Logo
Telescience Resource Kit
TReK C++  5.4.0 ART
trek::ComparisonDependency Class Reference

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

#include <comparison_dependency.h>

Inherits trek::Dependency.

Public Member Functions

int32_t LoadFile (const char *filename)
 Loads the ComparisonDependency definition from the specified file. More...
 
int32_t SaveFile (const char *filename)
 Saves the ComparisonDependency definition to the specified file. More...
 
Constructors, Destructor, and Other Basic Methods
 ComparisonDependency ()
 Default constructor of the class.
 
 ComparisonDependency (ComparisonDependency &input)
 Copy constructor of the class.
 
virtual ~ComparisonDependency ()
 Class destructor. More...
 
virtual DependencyClone ()
 Creates and returns an extact copy of the object.
 
void operator= (ComparisonDependency &right_side)
 Provides the equal operator.
 
Dependency Methods
int32_t Configure (const char *name, enum comparison_type comp_type, double value, bool use_cal, uint16_t samp_num=1)
 Configures the comparison dependency. More...
 
double GetValue ()
 Returns the value for the comparison depenendcy.
 
enum comparison_type GetComparisonType ()
 Returns the comparison type for the comparison depenendcy.
 
bool GetUseCalibratedValue ()
 Returns if the calibrated value should be used in the comparison.
 
uint16_t GetSampleNumber ()
 Returns the start sample number for the comparison depenendcy.
 
virtual bool Check ()
 Checks for if the dependency is met. More...
 
- Public Member Functions inherited from trek::Dependency
enum dependency_type GetType ()
 Returns an enumeration for the type of dependency.
 
const char * GetDependencyParameter ()
 Returns the parameter to use for the counter.
 
 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.
 
- Public Member Functions inherited from trek::NamedItem
void SetName (const char *input_ptr)
 Sets the name of the item. More...
 
void SetAlias (const char *input)
 Sets the alias of the item. More...
 
void SetShortDescription (const char *input_ptr)
 Sets the short description of the item. More...
 
void SetLongDescription (const char *input_ptr)
 Sets the long description of the item. More...
 
void SetUserDescription (const char *input_ptr)
 Sets the user description of the item. More...
 
void SetOwner (const char *input_ptr)
 Sets the owner of the item. More...
 
void SetPath (const char *input_ptr)
 Sets the path for the item. More...
 
const char * GetName ()
 Returns the name of the item.
 
const char * GetAlias ()
 Returns the alias of the item.
 
const char * GetShortDescription ()
 Returns the short description of the item.
 
const char * GetLongDescription ()
 Returns the long description of the item.
 
const char * GetUserDescription ()
 Returns the user description of the item.
 
const char * GetOwner ()
 Returns the owner of the item.
 
const char * GetPath ()
 Returns the path for the item.
 
int32_t AddAttribute (const char *name, const char *value)
 Adds an attribute to the item. More...
 
void GetAttributeList (StringArray &attr_array)
 Gets a list of the attribute names. More...
 
int32_t GetAttribute (const char *name, char *value, uint32_t &value_len)
 Get the value of the specified attribute. More...
 
 NamedItem ()
 Default constructor of the class.
 
 NamedItem (NamedItem &input)
 Copy constructor of the class.
 
virtual ~NamedItem ()
 Class destructor. More...
 
void operator= (NamedItem &right_side)
 Provides the equal operator.
 
bool operator== (NamedItem &right_side)
 Provides the == operator.
 

Detailed Description

This class determine a parameter's dependency based on a numeric comparison.

A simple comparison class used to determine inclusion of a parameter based on the comparison with a value from a second parameter. Comparison operators supported are equal, not equal, greater than, great than or equal to, less than, and less than or equal to.

Constructor & Destructor Documentation

◆ ~ComparisonDependency()

trek::ComparisonDependency::~ComparisonDependency ( )
virtual

Class destructor.

Removes all resources created with this instance of the class.

Member Function Documentation

◆ Check()

bool trek::ComparisonDependency::Check ( )
virtual

Checks for if the dependency is met.

Compares dependency parameter value to the configured data to see if the parameter is included in the packet.

Returns
true if parameter dependency is met @retruns false if parameter dependency is not met

Example:

// NOTE: This code is very unlikely to be called directly by user code.
ret_value = cd.Configure( "MyParameter", COMP_TYPE_EQ, 15, 1 ); // if Value(MyParameter) == 15, dependency is met
if( cd.Check() )
; // include in packet
This class determine a parameter's dependency based on a numeric comparison.
Definition: comparison_dependency.h:29
virtual bool Check()
Checks for if the dependency is met.
Definition: comparison_dependency.cpp:155
int32_t Configure(const char *name, enum comparison_type comp_type, double value, bool use_cal, uint16_t samp_num=1)
Configures the comparison dependency.
Definition: comparison_dependency.cpp:94

Implements trek::Dependency.

◆ Configure()

int32_t trek::ComparisonDependency::Configure ( const char *  name,
enum comparison_type  comp_type,
double  value,
bool  use_cal,
uint16_t  samp_num = 1 
)

Configures the comparison 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. Also, the sample number is not checked to see if it exists. These checks will be performed when validation is available at the packet level.

Parameters
[in]nameThe name of the parameter whose value is checked.
[in]comp_typeThe comparison type.
[in]valueThe value to comparison against.
[in]samp_numThe sample number of the parameter to use. Sample numbers begin with 1.
Returns
SUCCESS
TREK_DATA_NULL_PTR

Example:

ret_value = cd.Configure( "MyParameter", COMP_TYPE_EQ, 15, 1 ); // if Value(MyParameter) == 15, dependency is met
if( ret_value )
; // process error

◆ LoadFile()

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

Loads the ComparisonDependency definition from the specified file.

Reads an XML format for the ComparisonDependency. 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 ComparisonDependency definition from the specified file.
Definition: comparison_dependency.cpp:225

◆ SaveFile()

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

Saves the ComparisonDependency definition to the specified file.

Writes an XML format for the ComparisonDependency. 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 ComparisonDependency definition to the specified file.
Definition: comparison_dependency.cpp:260