CARMA C++
carma::dbms::PhysicalDeviceIDAuthority Class Reference

A lookup class for mapping names and IDs of locations and devices. More...

#include <carma/dbms/PhysicalDeviceIDAuthority.h>

Public Member Functions

::std::string getDevice (const int &deviceID) const
 return the device name for for an ID More...
 
int getDeviceID (const ::std::string &device) const
 return the ID for a given hardware device name More...
 
::std::string getLocation (const int &locationID) const
 return the location name for for an ID More...
 
int getLocationID (const ::std::string &location) const
 return the ID for a given hardware location name More...
 

Static Public Member Functions

static void closeAuthority ()
 indicate that one's use of the authority is complete. More...
 
static const
PhysicalDeviceIDAuthority
getAuthority (bool production=false, const dbms::DBConfigurator *dbconf=0)
 get the singleton instance of the PhysicalDeviceIDAuthority. More...
 
::std::string getDevice (const int &deviceID, bool production, const dbms::DBConfigurator *dbconf)
 
static int getDeviceCount ()
 return the number of devices More...
 
static int getDeviceID (const ::std::string &device, bool production, const dbms::DBConfigurator *dbconf)
 
::std::string getLocation (const int &locationID, bool production, const dbms::DBConfigurator *dbconf)
 
static int getLocationCount ()
 return the number of locations More...
 
static int getLocationID (const ::std::string &location, bool production, const dbms::DBConfigurator *dbconf)
 

Detailed Description

A lookup class for mapping names and IDs of locations and devices.

This class is instantiated as a singleton via a factory method. The CARMA Database is the authoritative source for location and device names and IDs. However, because the Locations and Devices database tables are initialized using the names and array indices of locationnames and deviceNames of this class this class only needs to use these arrays. Because of this interdependence, IT IS NECESSARY THAT NEW LOCATIONS AND DEVICES ARE ADDED ONLY AT THE END OF locationNames_ and deviceNames_. If this isn't done, loss of database integrity will occur.

Definition at line 39 of file PhysicalDeviceIDAuthority.h.

Member Function Documentation

static void carma::dbms::PhysicalDeviceIDAuthority::closeAuthority ( )
static

indicate that one's use of the authority is complete.

If we are running in production mode, the singleton instance will be deleted. It is safe to call getAuthority() at anytime before or after this function is called.

static const PhysicalDeviceIDAuthority& carma::dbms::PhysicalDeviceIDAuthority::getAuthority ( bool  production = false,
const dbms::DBConfigurator dbconf = 0 
)
static

get the singleton instance of the PhysicalDeviceIDAuthority.

if the instance doesn't already exist, this method will create it if it does exist, this method simply returns the instance

Parameters
productionuse the database to get IDs
dbconfDBConfigurator pointer for configuring the db connection, not used if production=false
::std::string carma::dbms::PhysicalDeviceIDAuthority::getDevice ( const int &  deviceID) const

return the device name for for an ID

Parameters
deviceIDthe deviceID
Exceptions
NotFoundExceptionif name is not matched
int carma::dbms::PhysicalDeviceIDAuthority::getDeviceCount ( )
static

return the number of devices

Returns
the total number of devices

Definition at line 189 of file PhysicalDeviceIDAuthority.h.

int carma::dbms::PhysicalDeviceIDAuthority::getDeviceID ( const ::std::string &  device) const

return the ID for a given hardware device name

Parameters
devicethe device name
Exceptions
NotFoundExceptionif name is not matched
::std::string carma::dbms::PhysicalDeviceIDAuthority::getLocation ( const int &  locationID) const

return the location name for for an ID

Parameters
locationIDthe locationID
Exceptions
NotFoundExceptionif name is not matched
int carma::dbms::PhysicalDeviceIDAuthority::getLocationCount ( )
static

return the number of locations

Returns
the total number of locations

Definition at line 182 of file PhysicalDeviceIDAuthority.h.

int carma::dbms::PhysicalDeviceIDAuthority::getLocationID ( const ::std::string &  location) const

return the ID for a given hardware location name

Parameters
locationthe location name
Exceptions
NotFoundExceptionif name is not matched

The documentation for this class was generated from the following file: