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

This class determine a parameter's dependency a series of dependencies of which all must be true. More...

#include <and_dependency.h>

Inherits trek::Dependency.

Public Member Functions

int32_t LoadFile (const char *filename)
 Loads the AndDependency definition from the specified file. More...
 
int32_t SaveFile (const char *filename)
 Saves the AndDependency definition to the specified file. More...
 
Constructors, Destructor, and Other Basic Methods
 AndDependency ()
 Default constructor of the class.
 
 AndDependency (AndDependency &input)
 Copy constructor of the class.
 
virtual ~AndDependency ()
 Class destructor. More...
 
virtual DependencyClone ()
 Creates and returns an extact copy of the object.
 
void operator= (AndDependency &right_side)
 Provides the equal operator.
 
Dependency Methods
int32_t AddDependency (Dependency *item)
 Adds a dependency. More...
 
int32_t RemoveDependency (uint32_t index)
 Removes the dependency at the specified index. More...
 
void ClearAllDependencies ()
 Removes all of the dependencies. More...
 
uint32_t GetNumberOfDependencies ()
 Gets the number of dependencies. More...
 
int32_t GetDependency (uint32_t index, Dependency **dep_ptr)
 Gets the dependency at the specified index. More...
 
virtual bool Check ()
 Checks for the dependency. More...
 
virtual int32_t ConfigureParameter (Packet *input)
 
- 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 a series of dependencies of which all must be true.

Constructor & Destructor Documentation

◆ ~AndDependency()

trek::AndDependency::~AndDependency ( )
virtual

Class destructor.

Removes all resources created with this instance of the class.

Member Function Documentation

◆ AddDependency()

int32_t trek::AndDependency::AddDependency ( Dependency item)

Adds a dependency.

Parameters
[in]itemThe dependency to add. A copy is made of the object and it is safe to delete the input.
Returns
SUCCESS
TREK_DATA_NULL_PTR

Example:

int32_t ret_value;
AndDependency and_dep;
cd1.Configure( "MyParameter", COMP_TYPE_GT, 15, 1 );
cd2.Configure( "MyParameter", COMP_TYPE_LTE, 25, 1 );
// want dependency to be met when 15 < value <= 25
ret_value = and_dep.AddDependency( &cd1 );
ret_value = and_dep.AddDependency( &cd2 );
This class determine a parameter's dependency a series of dependencies of which all must be true.
Definition: and_dependency.h:16
int32_t AddDependency(Dependency *item)
Adds a dependency.
Definition: and_dependency.cpp:99
This class determine a parameter's dependency based on a numeric comparison.
Definition: comparison_dependency.h:29
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

◆ Check()

bool trek::AndDependency::Check ( )
virtual

Checks for the dependency.

Checks to see if all of the dependency items are true.

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.
if( cd.Check() )
; // include in packet
virtual bool Check()
Checks for the dependency.
Definition: and_dependency.cpp:244

Implements trek::Dependency.

◆ ClearAllDependencies()

void trek::AndDependency::ClearAllDependencies ( )

Removes all of the dependencies.

Example:

int32_t ret_value;
AndDependency and_dep;
cd1.Configure( "MyParameter", COMP_TYPE_GT, 15, 1 );
cd2.Configure( "MyParameter", COMP_TYPE_LTE, 25, 1 );
ret_value = and_dep.AddDependency( &cd1 );
ret_value = and_dep.AddDependency( &cd2 );
// remove the dependencies
void ClearAllDependencies()
Removes all of the dependencies.
Definition: and_dependency.cpp:163

◆ GetDependency()

int32_t trek::AndDependency::GetDependency ( uint32_t  index,
Dependency **  dep_ptr 
)

Gets the dependency at the specified index.

If successful the method returns the internal dependency at the requested index. The memory should not be deleted as it is still used by the class.

Parameters
[in]indexThe index to retreive
[in]dep_ptrThe found dependency. Only set if return code indicates success.
Returns
SUCCESS
TREK_DATA_DOES_NOT_EXIST

Example:

int32_t ret_value;
AndDependency and_dep;
Dependency *dep_ptr;
cd1.Configure( "MyParameter", COMP_TYPE_GT, 15, 1 );
cd2.Configure( "MyParameter", COMP_TYPE_LTE, 25, 1 );
ret_value = and_dep.AddDependency( &cd1 );
ret_value = and_dep.AddDependency( &cd2 );
// Get the dependency at the first index and print its type
if( and_dep.GetDependency( 0, &dep_ptr ) == SUCCESS )
printf( "Dependency type: %s\n", dep_ptr->GetElementName() );
int32_t GetDependency(uint32_t index, Dependency **dep_ptr)
Gets the dependency at the specified index.
Definition: and_dependency.cpp:217
This class is the abstraction for all parameter dependencies.
Definition: dependency.h:30
#define SUCCESS
The function completed successfully.
Definition: trek_error.h:8

◆ GetNumberOfDependencies()

uint32_t trek::AndDependency::GetNumberOfDependencies ( )

Gets the number of dependencies.

Returns
The number of dependencies.

Example:

AndDepenency dep;
uint32_t num_dep;
num_dep = dep.GetNumberOfDependencies();

◆ LoadFile()

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

Loads the AndDependency definition from the specified file.

Reads an XML format for the AndDependency. 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 AndDependency definition from the specified file.
Definition: and_dependency.cpp:290

◆ RemoveDependency()

int32_t trek::AndDependency::RemoveDependency ( uint32_t  index)

Removes the dependency at the specified index.

Parameters
[in]indexThe index to remove.
Returns
SUCCESS
TREK_DATA_DOES_NOT_EXIST

Example:

int32_t ret_value;
AndDependency and_dep;
cd1.Configure( "MyParameter", COMP_TYPE_GT, 15, 1 );
cd2.Configure( "MyParameter", COMP_TYPE_LTE, 25, 1 );
ret_value = and_dep.AddDependency( &cd1 );
ret_value = and_dep.AddDependency( &cd2 );
// remove the first dependency
ret_value = and_dep.RemoveDependency( 0 );
int32_t RemoveDependency(uint32_t index)
Removes the dependency at the specified index.
Definition: and_dependency.cpp:133

◆ SaveFile()

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

Saves the AndDependency definition to the specified file.

Writes an XML format for the AndDependency. 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 AndDependency definition to the specified file.
Definition: and_dependency.cpp:333