CARMA C++
MonitorPointSelector.h
Go to the documentation of this file.
1 #ifndef CARMA_DBMS_MONITORPOINTSELECTOR_H
2 #define CARMA_DBMS_MONITORPOINTSELECTOR_H
3 
13 #include <string>
14 #include "carma/dbms/ColumnNames.h"
15 #include "carma/dbms/MonitorDescription.h"
17 #include "carma/dbms/Selector.h"
18 
19 namespace carma {
20 namespace dbms {
21 
22  class DBConnection;
23 
29 
30 public:
31 
32  //friend class MonitorDataQueryManager;
33 
42  typedef struct {
49  bool time;
55  bool tagID;
63  bool value;
87  bool validityID;
98  bool validity;
107  bool iSample;
128  bool maxValue;
140  bool minValue;
141  } SelectionMask;
142 
152  MonitorPointSelector(const unsigned& tagID,
153  const carma::dbms::DBConnection* const dbc);
154 
164  MonitorPointSelector(const unsigned& tagID,
166 
171 
175  unsigned getTagID() const { return tagID_; }
176 
189  void setSelectionMask(const SelectionMask& mask, bool quietly=false);
190 
208  void setSelectionMask(const std::string &maskString);
209 
213  SelectionMask getSelectionMask() const;
214 
215  carma::dbms::MonitorDescription getMonitorConfiguration() const;
216 
220  std::string toString() const;
221 
240  std::string toString
241  (const carma::dbms::MonitorAverageType& avgType,
242  const std::string& table="",
243  const std::string& columnAliasPrepender="",
244  const std::string& blankingFlagTableAlias="",
245  const std::string& validityTableAlias="",
246  const std::string& enumIndexTableAlias="",
247  const bool& onlyAliases=false)
248  const;
249 
250 
258  void setColumnPrefix(const std::string& columnPrefix) {
259  columnPrefix_ = columnPrefix;
260  }
261 
262  std::string getColumnPrefix() const { return columnPrefix_; }
263 
269  bool doSelectEnumString() const;
270 
279  unsigned getSupplementalTableJoinCount() const;
280 
286  unsigned selectedColumnCount(carma::dbms::MonitorAverageType& avgType) const;
287 
292  MonitorPointDataType getDataType() const { return dataType_; }
293 
298  void selectOnlyTagID();
299 
304  SelectionMask nullSelectionMask() const;
305 
310  SelectionMask allSelectionMask() const;
311 
312 protected:
313  unsigned tagID_;
314  // make this a pointer since the default MonitorDescription constructor
315  // is protected
316  MonitorDescription *md_;
317  SelectionMask mask_;
318  //carma::dbms::MonitorAverageType avgType_;
320  std::string columnPrefix_;
321 
325  void setDefaultSelection_();
326 
327  static std::string getModifiedColumnSelection_
328  (const carma::dbms::DBColumn& columnName, const std::string& table,
329  const std::string& alias, const bool& onlyAlias);
330 
335  std::vector<std::string> selectedColumns_
336  (const carma::dbms::MonitorAverageType& avgType,
337  const std::string& table="",
338  const std::string& columnAliasPrepender="",
339  const std::string& blankingFlagTableAlias="",
340  const std::string& validityTableAlias="",
341  const std::string& enumIndexTableAlias="",
342  const bool& onlyAliases=false) const;
343 };
344 
350 {
351  public:
352  bool operator()
353  (const MonitorPointSelector* lhs, const MonitorPointSelector* rhs) ;
354 };
355 
357 typedef std::set<MonitorPointSelector*, MPSelectorCompare> MPSelectorSet;
358 
359 }}
360 
361 #endif // CARMA_DBMS_MONITORPOINTSELECTOR_H
362 
363 
Class for sorting a set of MPSelector pointers.
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
void selectOnlyTagID()
convenience method for setting the SelectionMask to permit selecting only the tagID column ...
std::set< MonitorPointSelector *, MPSelectorCompare > MPSelectorSet
A set of MonitorPointSelector points ordered by tagID.
Selector class.
bool blankingFlag
If true, the blankingFlag column is from the BlankingFlags table is selected.
unsigned getTagID() const
get the tagID of the monitor point represented by this selection
bool minValue
If true, the minValue column is selected.
bool enumString
If true, the corresponding enumerator string column is selected if the monitor point has data type en...
Class to represent an SQL selection (portion of SELECT clause) based on the attributes of a monitor p...
SelectionMask getSelectionMask() const
get the selection mask
void setSelectionMask(const SelectionMask &mask, bool quietly=false)
set the selection mask
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 sel...
SelectionMask allSelectionMask() const
get a selection mask with all fields set to true.
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...
std::string toString() const
string representation of this selection
A MonitorDescription object holds all information on a monitor point which is stored in the database ...
bool maxValue
If true, the maxValue column is selected.
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.
bool validityID
If true, the validityID column is selected.
bool tagID
If true, the tagID column is selected.
bool blankingFlagID
if true, the blankingFlagID column is selected.
relationships between the monitor and dbms systems
bool validity
If true, the validity column from the Validities table is selected.
bool doSelectEnumString() const
should the enumerator string column be selected based on the selection mask and on the datatype...
SelectionMask nullSelectionMask() const
get a selection mask with all fields set to false
MonitorAverageType
average type of the monitor[point,data file,table]
access of column names in the database
void setDefaultSelection_()
set the default selection
bool iSample
If true, the iSample column is selected.
unsigned getSupplementalTableJoinCount() const
returns the number of supplemental tables which will need to be joined to the main monitor table(s) t...
bool time
If true, the time column (frameCount for frame and minute averages, integrationID for astronomical in...
Abstract base class to represent an SQL selection (portion of SELECT clause)
Definition: Selector.h:24
MonitorPointDataType getDataType() const
get the data type of the monitor point associated with this selector
an abstract class from which database queries may be launched.
Definition: DBConnection.h:46
bool value
If true, the value column is selected.
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...
MonitorPointDataType
type of the monitor point.
DBColumn
database columns
Definition: ColumnNames.h:26