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

Class to represent an SQL selection (portion of SELECT clause) based on the attributes of a monitor point. More...

#include <carma/dbms/MonitorPointSelector.h>

Inheritance diagram for carma::dbms::MonitorPointSelector:
carma::dbms::Selector

Classes

struct  SelectionMask
 Holds info on which monitor point fields should be selected (ie returned) by a query), if a value is set to true, the corresponding column is included in the selection (in cases where the selection makes sense, see the description of individual fields), if false it is not. More...
 

Public Member Functions

SelectionMask allSelectionMask () const
 get a selection mask with all fields set to true. More...
 
bool doSelectEnumString () const
 should the enumerator string column be selected based on the selection mask and on the datatype? More...
 
std::string getColumnPrefix () const
 
MonitorPointDataType getDataType () const
 get the data type of the monitor point associated with this selector More...
 
carma::dbms::MonitorDescription getMonitorConfiguration () const
 
SelectionMask getSelectionMask () const
 get the selection mask More...
 
unsigned getSupplementalTableJoinCount () const
 returns the number of supplemental tables which will need to be joined to the main monitor table(s) to produce the desired selection <il> More...
 
unsigned getTagID () const
 get the tagID of the monitor point represented by this selection More...
 
 MonitorPointSelector (const unsigned &tagID, const carma::dbms::DBConnection *const dbc)
 constructor the object is intialized with all the members of its selection mask set to false, with the exception of .time and .value which are set to true More...
 
 MonitorPointSelector (const unsigned &tagID, carma::dbms::MonitorPointDataType dataType)
 constructor the object is intialized with all the members of its selection mask set to false, with the exception of .time and More...
 
SelectionMask nullSelectionMask () const
 get a selection mask with all fields set to false More...
 
unsigned selectedColumnCount (carma::dbms::MonitorAverageType &avgType) const
 get the number of columns which will be selected based on the selection mask, monitor point data type, and average type More...
 
void selectOnlyTagID ()
 convenience method for setting the SelectionMask to permit selecting only the tagID column More...
 
void setColumnPrefix (const std::string &columnPrefix)
 set the column prefix for the fields returned in the result set for example if the mask is set to select only the value, the column name containing these values will be "joe.value" if this method is called with columnPrefix=joe More...
 
void setSelectionMask (const SelectionMask &mask, bool quietly=false)
 set the selection mask More...
 
void setSelectionMask (const std::string &maskString)
 set the selection mask using a string. More...
 
std::string toString () const
 string representation of this selection More...
 
std::string toString (const carma::dbms::MonitorAverageType &avgType, const std::string &table="", const std::string &columnAliasPrepender="", const std::string &blankingFlagTableAlias="", const std::string &validityTableAlias="", const std::string &enumIndexTableAlias="", const bool &onlyAliases=false) const
 SQL string representation of the selection. More...
 
 ~MonitorPointSelector ()
 destructor More...
 
- Public Member Functions inherited from carma::dbms::Selector
std::string * getTable () const
 get the pointer to the table name. More...
 
void setTable (const std::string &tableName)
 set the option table name or aliased table name for this selection More...
 
virtual ~Selector ()
 destructor More...
 

Protected Member Functions

std::vector< std::string > selectedColumns_ (const carma::dbms::MonitorAverageType &avgType, const std::string &table="", const std::string &columnAliasPrepender="", const std::string &blankingFlagTableAlias="", const std::string &validityTableAlias="", const std::string &enumIndexTableAlias="", const bool &onlyAliases=false) const
 get the column selections as a a vector for making counting, etc easier More...
 
void setDefaultSelection_ ()
 set the default selection More...
 

Static Protected Member Functions

static std::string getModifiedColumnSelection_ (const carma::dbms::DBColumn &columnName, const std::string &table, const std::string &alias, const bool &onlyAlias)
 

Protected Attributes

std::string columnPrefix_
 
carma::dbms::MonitorPointDataType dataType_
 
SelectionMask mask_
 
MonitorDescriptionmd_
 
unsigned tagID_
 
- Protected Attributes inherited from carma::dbms::Selector
std::string * tableName_
 

Detailed Description

Class to represent an SQL selection (portion of SELECT clause) based on the attributes of a monitor point.

Definition at line 28 of file MonitorPointSelector.h.

Constructor & Destructor Documentation

carma::dbms::MonitorPointSelector::MonitorPointSelector ( const unsigned &  tagID,
const carma::dbms::DBConnection *const  dbc 
)

constructor the object is intialized with all the members of its selection mask set to false, with the exception of .time and .value which are set to true

Parameters
tagIDthe tagID of the monitor point to select
dbca valid database connection, needed to get the data type of the monitor point with the specified tagID
carma::dbms::MonitorPointSelector::MonitorPointSelector ( const unsigned &  tagID,
carma::dbms::MonitorPointDataType  dataType 
)

constructor the object is intialized with all the members of its selection mask set to false, with the exception of .time and

Parameters
tagIDthe tagID of the monitor point to select
dataTypethe dataType of the point with the specified tagID. It better be correct! if unsure, use the alternate constructor which will get the datatype from the database
carma::dbms::MonitorPointSelector::~MonitorPointSelector ( )

destructor

Member Function Documentation

SelectionMask carma::dbms::MonitorPointSelector::allSelectionMask ( ) const

get a selection mask with all fields set to true.

Returns
a selection mask with all fields set to true
bool carma::dbms::MonitorPointSelector::doSelectEnumString ( ) const

should the enumerator string column be selected based on the selection mask and on the datatype?

Returns
if the enumerator string column should be selected
MonitorPointDataType carma::dbms::MonitorPointSelector::getDataType ( void  ) const

get the data type of the monitor point associated with this selector

Returns
the data type

Definition at line 292 of file MonitorPointSelector.h.

SelectionMask carma::dbms::MonitorPointSelector::getSelectionMask ( ) const

get the selection mask

unsigned carma::dbms::MonitorPointSelector::getSupplementalTableJoinCount ( ) const

returns the number of supplemental tables which will need to be joined to the main monitor table(s) to produce the desired selection <il>

== true => +1

== true => +1

== true && datatype == enumeration => +2

unsigned carma::dbms::MonitorPointSelector::getTagID ( ) const

get the tagID of the monitor point represented by this selection

Definition at line 175 of file MonitorPointSelector.h.

SelectionMask carma::dbms::MonitorPointSelector::nullSelectionMask ( ) const

get a selection mask with all fields set to false

Returns
a selection mask with all fields set to false
unsigned carma::dbms::MonitorPointSelector::selectedColumnCount ( carma::dbms::MonitorAverageType avgType) const

get the number of columns which will be selected based on the selection mask, monitor point data type, and average type

Returns
the number of columns which will be selected
std::vector<std::string> carma::dbms::MonitorPointSelector::selectedColumns_ ( const carma::dbms::MonitorAverageType avgType,
const std::string &  table = "",
const std::string &  columnAliasPrepender = "",
const std::string &  blankingFlagTableAlias = "",
const std::string &  validityTableAlias = "",
const std::string &  enumIndexTableAlias = "",
const bool &  onlyAliases = false 
) const
protected

get the column selections as a a vector for making counting, etc easier

void carma::dbms::MonitorPointSelector::selectOnlyTagID ( )

convenience method for setting the SelectionMask to permit selecting only the tagID column

void carma::dbms::MonitorPointSelector::setColumnPrefix ( const std::string &  columnPrefix)

set the column prefix for the fields returned in the result set for example if the mask is set to select only the value, the column name containing these values will be "joe.value" if this method is called with columnPrefix=joe

Parameters
columnPrefixthe string to prefix column names with

Definition at line 258 of file MonitorPointSelector.h.

void carma::dbms::MonitorPointSelector::setDefaultSelection_ ( )
protected

set the default selection

void carma::dbms::MonitorPointSelector::setSelectionMask ( const SelectionMask mask,
bool  quietly = false 
)

set the selection mask

Parameters
maskthe selection mask to use
quietlyIf true, don't throw an exception for inappropriate requests. (Quietly override them).
Exceptions
carma::util::IllegalArgumentExceptionif certain fields of the mask are true and this makes no sense based on the monitor point's data type (see the documentation regarding carma::dbms::MonitorPointSelection::SelectionMask for details)
void carma::dbms::MonitorPointSelector::setSelectionMask ( const std::string &  maskString)

set the selection mask using a string.

Parameters
maskStringString containing "|" separated field names. A field name may be any of time|tagID|value|blankingFlagID|blankingFlag|validityID| validity|maxValue|minValue|all|none All means all fields. None means remove all fields. Individual field names may be prepended (with no intervening space) by a "-" to indicate that field is to be removed from the list. Entries are processed left to right.
Exceptions
carma::util::IllegalArgumentExceptionif certain fields of the mask are true and this makes no sense based on the monitor point's data type (see the documentation regarding carma::dbms::MonitorPointSelection::SelectionMask for details)
std::string carma::dbms::MonitorPointSelector::toString ( ) const
virtual

string representation of this selection

Implements carma::dbms::Selector.

std::string carma::dbms::MonitorPointSelector::toString ( const carma::dbms::MonitorAverageType avgType,
const std::string &  table = "",
const std::string &  columnAliasPrepender = "",
const std::string &  blankingFlagTableAlias = "",
const std::string &  validityTableAlias = "",
const std::string &  enumIndexTableAlias = "",
const bool &  onlyAliases = false 
) const

SQL string representation of the selection.

Parameters
avgTypethe average type
tableoptional table name from where the selection is to occur. If not "", prepends table + "." to the column name
columnAliasPrependerif not "", results in " AS " + columnAliasPrepender + "." column name being appended to the column selection
blankingFlagTableAliasalias to use for the blanking flag table only used if a blanking flag column selection is set
validityTableAliasalias to use for the validity table only used if a validity column selection is set
enumIndexTableAliasalias to use for the enumerator index table only used if the selection mask's enumString field is true and if the data type is enumeration
onlyAliasesreturn only the column aliases as a comma delimited list

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