A singleton class for dealing with units of measure in the TerraLib environment.
More...
#include <UnitsOfMeasureManager.h>
A singleton class for dealing with units of measure in the TerraLib environment.
This class manages a unique catalogue of known units of measure within the TerraLib environment.
- See also
- UnitOfMeasure
Definition at line 54 of file UnitsOfMeasureManager.h.
te::common::UnitsOfMeasureManager::UnitsOfMeasureManager |
( |
| ) |
|
|
protected |
te::common::UnitsOfMeasureManager::~UnitsOfMeasureManager |
( |
| ) |
|
|
protected |
bool te::common::UnitsOfMeasureManager::areConvertible |
( |
const std::string & |
unitFromName, |
|
|
const std::string & |
unitToName |
|
) |
| const |
Check if two units of measure are compatible.
Check if a unit can be converted to another.
- Parameters
-
unitFromName | A unit of measure name. |
unitToName | The name of unit to be converted to. |
- Returns
- True if the UnitFrom can be converted to UnitTo false otherwise.
It returns an iterator to the beginning of the conteiner.
- Returns
- An iterator to the beginning of the conteiner.
Definition at line 222 of file UnitsOfMeasureManager.h.
References m_uoms.
It returns an iterator to the beginning of the conteiner.
- Returns
- An iterator to the beginning of the conteiner.
Definition at line 227 of file UnitsOfMeasureManager.h.
References m_uoms.
void te::common::UnitsOfMeasureManager::clear |
( |
| ) |
|
Removes all units from the catalogue.
It returns an iterator to the end of the conteiner.
- Returns
- An iterator to the beginning of the conteiner.
Definition at line 232 of file UnitsOfMeasureManager.h.
References m_uoms.
It returns an iterator to the end of the conteiner.
- Returns
- An iterator to the beginning of the conteiner.
Definition at line 237 of file UnitsOfMeasureManager.h.
References m_uoms.
UnitOfMeasurePtr te::common::UnitsOfMeasureManager::find |
( |
unsigned int |
id | ) |
const |
Returns a unit of measure identified by its identificaton.
- Parameters
-
id | The unit identification. |
- Returns
- A pointer unit of measure if found; null pointer otherwise.
UnitOfMeasurePtr te::common::UnitsOfMeasureManager::find |
( |
const std::string & |
name | ) |
const |
Returns a unit of measure identified by its name.
- Parameters
-
id | The unit identification. |
- Returns
- A unit of measure pointer if found; null pointer otherwise.
UnitOfMeasurePtr te::common::UnitsOfMeasureManager::findBySymbol |
( |
const std::string & |
symbol | ) |
const |
Returns a unit of measure identified by its symbol.
- Parameters
-
- Returns
- A unit of measure pointer if found; null pointer otherwise.
double te::common::UnitsOfMeasureManager::getConversion |
( |
const std::string & |
unitFromName, |
|
|
const std::string & |
unitToName |
|
) |
| const |
Calculates a multiplicative factor to convert from a given unit to its base unit and vice-versa.
- Parameters
-
unitFromName | A unit of measure name. |
unitToName | The name of unit to be converted to. |
- Returns
- A multiplicative factor to convert from a given unit to another.
- Exceptions
-
It returns a reference to the singleton instance.
- Returns
- A reference to the singleton instance.
void te::common::UnitsOfMeasureManager::getNames |
( |
UnitOfMeasurePtr & |
uom, |
|
|
std::vector< std::string > & |
names |
|
) |
| const |
Retrieves the alternative names for a unit of measure.
- Parameters
-
uom | Pointer to the unit of measure. Shouldn't be null; |
altNames | Reference to a vector of strings to return the alternative names (output). |
void te::common::UnitsOfMeasureManager::init |
( |
| ) |
|
It initializes the list of well kown units of measure.
The list is read from the JSON file TERRALIB_DIR/resources/json/uom.json.
- Exceptions
-
Exception | It throws an exception if it is not possible to initialize the UOM list. |
Inserts a new unit of measure to be managed.
- Parameters
-
uom | Pointer to unit of measure to be managed. Shouldn't be null. The manager takes the pointer ownership. |
- Exceptions
-
void te::common::UnitsOfMeasureManager::insert |
( |
UnitOfMeasurePtr & |
uom, |
|
|
const std::vector< std::string > & |
alternativeNames |
|
) |
| |
Inserts a new unit of measure to be managed and its alternative names.
- Parameters
-
uom | Pointer to unit of measure to be managed. Shouldn't be null. The manager takes the pointer ownership. |
alternativeNames | The list of alternative (or auxiliary) names for identifying an unit of measure. |
- Exceptions
-
bool te::common::UnitsOfMeasureManager::isInitialized |
( |
| ) |
|
Removes a unit of measure from the manager.
- Parameters
-
uom | Pointer to unit of measure to be managed. Shouldn't be null. The manager will delete the pointer. |
- Exceptions
-
std::size_t te::common::UnitsOfMeasureManager::size |
( |
| ) |
const |
|
inline |
It returns the number of units in the manager.
- Returns
- The number of units in the manager.
Definition at line 217 of file UnitsOfMeasureManager.h.
References m_uoms.
std::map<unsigned int, UnitOfMeasurePtr> te::common::UnitsOfMeasureManager::m_uoms |
|
private |
std::map<std::string, unsigned int> te::common::UnitsOfMeasureManager::m_uomsIdxByName |
|
private |
The documentation for this class was generated from the following file: