constants.c File Reference

Detailed Description

Implementations of the functions operating on the Tconstants.

See Also
Tconstant, constants.h.

Definition in file constants.c.

Functions

void InitConstants (Tconstants *cts)
 Initializes a constant set. More...
 
void CopyConstants (Tconstants *cts_dst, Tconstants *cts_src)
 Copies a set of constants. More...
 
void MergeConstants (Tconstants *c1, Tconstants *c2, Tconstants *cout)
 Fuses constant sets. More...
 
unsigned int NConstants (Tconstants *cts)
 Number of constants. More...
 
unsigned int AddConstant (char *name, double v, Tconstants *cts)
 Add a constant. More...
 
unsigned int GetConstantWithName (char *name, Tconstants *cts)
 Retrives a constant from the set. More...
 
double GetConstantValue (unsigned int n, Tconstants *cts)
 Retrives a the value of a constant. More...
 
void PrintConstants (FILE *f, Tconstants *cts)
 Prints a set of constants. More...
 
void DeleteConstants (Tconstants *cts)
 Destructor. More...
 

Function Documentation

void InitConstants ( Tconstants cts)

Creates a new set of constants.

Parameters
ctsPointer to the set of constants to be initialized

Definition at line 21 of file constants.c.

References Tconstants::cts, INIT_NUM_CONSTANTS, Tconstants::max_constants, Tconstants::n, and NEW.

Referenced by InitCuikSystem().

void CopyConstants ( Tconstants cts_dst,
Tconstants cts_src 
)

Initializes a set of constant with data from another set.

Parameters
cts_dstThe new set.
cts_srcThe source set.

Definition at line 30 of file constants.c.

References AddConstant(), Tconstants::cts, Tconstants::max_constants, Tconstants::n, Tconstant::name, NEW, and Tconstant::vs.

Referenced by CopyCuikSystem(), and MergeConstants().

void MergeConstants ( Tconstants c1,
Tconstants c2,
Tconstants cout 
)

Merges the constats in to sets into a new set.

Parameters
c1The firts set of constants to merge.
c2The second set of constants to merge.
coutThe output set with all the constants.

Definition at line 42 of file constants.c.

References AddConstant(), CopyConstants(), Tconstants::cts, Tconstants::n, Tconstant::name, and Tconstant::vs.

Referenced by CuikSystemMerge().

unsigned int NConstants ( Tconstants cts)

Returns the number of constants currently in the set.

Parameters
ctsPointer to the set of constants.
Returns
The number of constants held in the set.

Definition at line 55 of file constants.c.

References Tconstants::n.

unsigned int AddConstant ( char *  name,
double  v,
Tconstants cts 
)

Adds a new constnat to the set. It does not test whether or not there is another constant with the same name. This must be tested before using AddConstant calling the function 'GetConstantWithName'

Parameters
nameName of the constant.
vValue of the new constant.
ctsPointer to the set of constants.
Returns
The position at which the constant is added (i.e., the numerical identifier for the constant).
See Also
GetConstantWithName

Definition at line 65 of file constants.c.

References Tconstants::cts, Tconstants::max_constants, MEM_DUP, Tconstants::n, Tconstant::name, NEW, and Tconstant::vs.

Referenced by CopyConstants(), and MergeConstants().

unsigned int GetConstantWithName ( char *  name,
Tconstants cts 
)

Determines the numerical identifier for a constant with a given name. It can be used also to check if a constant is included in the set or not.

Parameters
nameName of the constant to retrive.
ctsPointer to the set of constants.
Returns
The numerical identifier for the constant and NO_UINT if there is no constant in the set with the given name.

Definition at line 88 of file constants.c.

References Tconstants::cts, FALSE, Tconstant::name, NO_UINT, and TRUE.

double GetConstantValue ( unsigned int  n,
Tconstants cts 
)

Returns the value of a constant, given the numerical identifier of this constant.

Parameters
nNumerical identifier of the constant whose value we want to retrive.
ctsPointer to the set of constants.
Returns
The value of the constat or 0 if there is no constant with the given numerical identifier.

Definition at line 113 of file constants.c.

References Tconstants::cts, Error(), and Tconstant::vs.

void PrintConstants ( FILE *  f,
Tconstants cts 
)

Prints a set of constants into a stream, that can be stdout.

Parameters
fThe stream where to print the constant set.
ctsPointer to the set of constants to be printed.

Definition at line 126 of file constants.c.

References Tconstants::cts, Tconstants::n, Tconstant::name, and Tconstant::vs.

void DeleteConstants ( Tconstants cts)

Deletes a set of constants.

Parameters
ctsPointer to the set of constants to be deleted.

Definition at line 137 of file constants.c.

References Tconstants::cts, Tconstants::n, and Tconstant::name.

Referenced by DeleteCuikSystem().