mirror of
https://github.com/nasa/trick.git
synced 2024-12-22 22:42:26 +00:00
19025d77ad
Reorganized. Created a new top level include directory that will hold all of Trick's header files. Moved all of the Trick headers to this directory. Created a libexec directory that holds all of the executables that users don't need to execute directly. Changed all of the executables remaining in bin to start with "trick-". In the sim_services directories changed all source files to find the Trick headers in their new location. Since all of the include files are gone in sim_services, removed the src directories as well, moving all of the source files up a level. Moved the makefiles, docs, man, and other architecture independent files into a top level share directory. Renamed lib_${TRICK_HOST_CPU} to lib64 or lib depending on the platform we're currently on. refs #63
54 lines
1.3 KiB
C++
54 lines
1.3 KiB
C++
|
|
#include <iostream>
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
#include "trick/UnitsMap.hh"
|
|
|
|
// Class static pointer initialization
|
|
Trick::UnitsMap * Trick::UnitsMap::pInstance = NULL ;
|
|
|
|
// Memeber Function
|
|
Trick::UnitsMap * Trick::UnitsMap::units_map() {
|
|
if ( pInstance == NULL ) {
|
|
pInstance = new Trick::UnitsMap() ;
|
|
}
|
|
|
|
return(pInstance) ;
|
|
} ;
|
|
|
|
// Destructor
|
|
Trick::UnitsMap::~UnitsMap() {
|
|
|
|
std::map<std::string, char * >::iterator pit ;
|
|
|
|
for ( pit = param_units.begin() ; pit != param_units.end() ; pit++ ) {
|
|
free((*pit).second) ;
|
|
}
|
|
param_units.clear() ;
|
|
|
|
}
|
|
|
|
// Member Function
|
|
int Trick::UnitsMap::add_param(std::string param , const char * units) {
|
|
/**
|
|
* @par Design Details:
|
|
* @li Adds a variable with specified units to the map. The key is the name of a variable and the value is the units of the variable.
|
|
*/
|
|
param_units[param] = strdup(units) ;
|
|
return(0) ;
|
|
}
|
|
|
|
// Memeber Function
|
|
std::string Trick::UnitsMap::get_units( std::string param ) {
|
|
/**
|
|
* @par Design Details:
|
|
* @li Finds the specified variable in the map and returns the units of the found variable.
|
|
* If the variable can not be found, returns "--" (unitless).
|
|
*/
|
|
if ( param_units.find(param) != param_units.end() ) {
|
|
return(std::string(param_units[param])) ;
|
|
} else {
|
|
return(std::string("--")) ;
|
|
}
|
|
}
|