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

This class provides the common set of names and descriptions allowed for items in the Data API. More...

#include <named_item.h>

Inherited by trek::Calibrator, trek::Dependency, trek::ExpectedStateAlarm, trek::LimitAlarm, trek::PacketItem, trek::Parameter, and trek::SwitchSet.

Public Member Functions

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...
 
Constructors, Destructor, and Other Basic Methods
 NamedItem ()
 Default constructor of the class.
 
 NamedItem (NamedItem &input)
 Copy constructor of the class.
 
virtual ~NamedItem ()
 Class destructor. More...
 
virtual void Init ()
 Initializes the object.
 
void operator= (NamedItem &right_side)
 Provides the equal operator.
 
bool operator== (NamedItem &right_side)
 Provides the == operator.
 

Detailed Description

This class provides the common set of names and descriptions allowed for items in the Data API.

Constructor & Destructor Documentation

◆ ~NamedItem()

trek::NamedItem::~NamedItem ( )
virtual

Class destructor.

Removes all resources created with this instance of the class.

Member Function Documentation

◆ AddAttribute()

int32_t trek::NamedItem::AddAttribute ( const char *  name,
const char *  value 
)

Adds an attribute to the item.

Parameters
[in]nameThe name of the attribute.
[in]valueThe value of the attribute.
Returns
SUCCESS

Example:

// Note: NamedItem is usually not instantiated directly
p.SetName( "param1" );
p.AddAttribute( "colour", "grey" );
void SetName(const char *input_ptr)
Sets the name of the item.
Definition: named_item.cpp:167
int32_t AddAttribute(const char *name, const char *value)
Adds an attribute to the item.
Definition: named_item.cpp:315
This class describes a single parameter within a telemetry or command message including its value.
Definition: parameter.h:100

◆ GetAttribute()

int32_t trek::NamedItem::GetAttribute ( const char *  name,
char *  value,
uint32_t &  value_len 
)

Get the value of the specified attribute.

Parameters
[in]name- The name of the attribute to retrieve.
[out]str_value- The returned attribute value.
[in/out]value_len - The number of bytes available in str_value. If TREK_DATA_NOT_ENOUGH_SPACE is returned the value is set to the required minimum value.
Returns
SUCCESS
TREK_DATA_NOT_ENOUGH_SPACE
TREK_DATA_DOES_NOT_EXIST

Example:

// Note: NamedItem is usually not instantiated directly
StringArray my_array;
char str_value[1000];
uint32_t value_len;
p.GetAttributeList( my_array );
for( uint32_t ii = 0; ii < my_array.Size(); ii++ )
{
value_len = 1000;
if( p.GetAttribute( my_array.GetAt(ii), str_value, value_len ) == SUCCESS )
printf( "%s = %s\n", my_array.GetAt(ii), str_value );
}
void GetAttributeList(StringArray &attr_array)
Gets a list of the attribute names.
Definition: named_item.cpp:346
int32_t GetAttribute(const char *name, char *value, uint32_t &value_len)
Get the value of the specified attribute.
Definition: named_item.cpp:384
This class provides a wrapper for std::vector and std::string so different versions of the standard t...
Definition: string_array.h:19
uint32_t Size()
Returns the number of items in the string array.
Definition: string_array.cpp:67
const char * GetAt(uint32_t index)
Returns the string at the given location.
Definition: string_array.cpp:89
#define SUCCESS
The function completed successfully.
Definition: trek_error.h:8

◆ GetAttributeList()

void trek::NamedItem::GetAttributeList ( StringArray attr_array)

Gets a list of the attribute names.

Parameters
[out]attr_arrayUsed to hold list of names. A length of zero indicates no attributes are available.

Example:

// Note: NamedItem is usually not instantiated directly
StringArray my_array;
char str_value[1000];
uint32_t value_len;
p.GetAttributeList( my_array );
for( uint32_t ii = 0; ii < my_array.Size(); ii++ )
{
value_len = 1000;
if( p.GetAttribute( my_array.GetAt(ii), str_value, value_len ) == SUCCESS )
printf( "%s = %s\n", my_array.GetAt(ii), str_value );
}

◆ SetAlias()

void trek::NamedItem::SetAlias ( const char *  input_ptr)

Sets the alias of the item.

There is no restriction on the length of the alias. However, individual projects may impose length restrictions.

Parameters
[in]input_ptrThe new alias for the item.

◆ SetLongDescription()

void trek::NamedItem::SetLongDescription ( const char *  input_ptr)

Sets the long description of the item.

There is no restriction on the length of the long description. However, individual projects may impose length restrictions.

Parameters
[in]input_ptrThe new long description for the item.

◆ SetName()

void trek::NamedItem::SetName ( const char *  input_ptr)

Sets the name of the item.

There is no restriction on the length of the name. However, individual projects may impose length restrictions.

Parameters
[in]input_ptrThe new name for the item.
Examples
define_packet/define_packet.cpp, and integrate_user_calibrator/integrate_user_calibrator.cpp.

◆ SetOwner()

void trek::NamedItem::SetOwner ( const char *  input_ptr)

Sets the owner of the item.

There is no restriction on the length of the owner. However, individual projects may impose length restrictions.

Parameters
[in]input_ptrThe new owner for the item.

◆ SetPath()

void trek::NamedItem::SetPath ( const char *  input_ptr)

Sets the path for the item.

There is no restriction on the length of the path. It can be used to support a path like name for the item for informational purposes.

Parameters
[in]input_ptrThe new path for the item.

◆ SetShortDescription()

void trek::NamedItem::SetShortDescription ( const char *  input_ptr)

Sets the short description of the item.

There is no restriction on the length of the short description. However, individual projects may impose length restrictions.

Parameters
[in]input_ptrThe new short description for the item.

◆ SetUserDescription()

void trek::NamedItem::SetUserDescription ( const char *  input_ptr)

Sets the user description of the item.

There is no restriction on the length of the user description. However, individual projects may impose length restrictions.

Parameters
[in]input_ptrThe new user description for the item.