CARMA C++
|
Class to represent an SQL selection (portion of SELECT clause) based on the attributes of a monitor point. More...
#include <carma/dbms/MonitorPointSelector.h>
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... | |
![]() | |
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_ |
MonitorDescription * | md_ |
unsigned | tagID_ |
![]() | |
std::string * | tableName_ |
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.
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
tagID | the tagID of the monitor point to select |
dbc | a 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
tagID | the tagID of the monitor point to select |
dataType | the 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
SelectionMask carma::dbms::MonitorPointSelector::allSelectionMask | ( | ) | const |
get 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?
MonitorPointDataType carma::dbms::MonitorPointSelector::getDataType | ( | void | ) | const |
get the data type of the monitor point associated with this selector
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
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
|
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
columnPrefix | the string to prefix column names with |
Definition at line 258 of file MonitorPointSelector.h.
|
protected |
set the default selection
void carma::dbms::MonitorPointSelector::setSelectionMask | ( | const SelectionMask & | mask, |
bool | quietly = false |
||
) |
set the selection mask
mask | the selection mask to use |
quietly | If true, don't throw an exception for inappropriate requests. (Quietly override them). |
carma::util::IllegalArgumentException | if 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.
maskString | String 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. |
carma::util::IllegalArgumentException | if 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) |
|
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.
avgType | the average type |
table | optional table name from where the selection is to occur. If not "", prepends table + "." to the column name |
columnAliasPrepender | if not "", results in " AS " + columnAliasPrepender + "." column name being appended to the column selection |
blankingFlagTableAlias | alias to use for the blanking flag table only used if a blanking flag column selection is set |
validityTableAlias | alias to use for the validity table only used if a validity column selection is set |
enumIndexTableAlias | alias 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 |
onlyAliases | return only the column aliases as a comma delimited list |