|
tdaq-develop-2025-02-12
|
Public Types | |
| typedef std::vector< std::vector< std::string > > | DataView |
| typedef DataView::iterator | iterator |
| typedef DataView::const_iterator | const_iterator |
Public Member Functions | |
| TableView (const std::string &tableName) | |
| = ""); | |
| void | init (void) |
| TableView & | copy (const TableView &src, TableVersion destinationVersion, const std::string &author) |
| unsigned int | copyRows (const std::string &author, const TableView &src, unsigned int srcOffsetRow=0, unsigned int srcRowsToCopy=(unsigned int) -1, unsigned int destOffsetRow=(unsigned int) -1, unsigned char generateUniqueDataColumns=false, const std::string &baseNameAutoUID="") |
| template<class T > | |
| unsigned int | findRow (unsigned int col, const T &value, unsigned int offsetRow=0, bool doNotThrow=false) const |
| < in included .icc source | |
| unsigned int | findRow (unsigned int col, const std::string &value, unsigned int offsetRow=0, bool doNotThrow=false) const |
| template<class T > | |
| unsigned int | findRowInGroup (unsigned int col, const T &value, const std::string &groupId, const std::string &childLinkIndex, unsigned int offsetRow=0) const |
| < in included .icc source | |
| unsigned int | findRowInGroup (unsigned int col, const std::string &value, const std::string &groupId, const std::string &childLinkIndex, unsigned int offsetRow=0) const |
| unsigned int | findCol (const std::string &name) const |
| unsigned int | findColByType (const std::string &type, unsigned int startingCol=0) const |
| const std::string & | getCustomStorageData (void) const |
| Getters. | |
| const std::string & | getTableName (void) const |
| const TableVersion & | getVersion (void) const |
| const std::string & | getComment (void) const |
| const std::string & | getAuthor (void) const |
| const time_t & | getCreationTime (void) const |
| const time_t & | getLastAccessTime (void) const |
| const bool & | getLooseColumnMatching (void) const |
| unsigned int | getDataColumnSize (void) const |
| getDataColumnSize More... | |
| const unsigned int & | getSourceColumnMismatch (void) const |
| const unsigned int & | getSourceColumnMissing (void) const |
| const std::set< std::string > & | getSourceColumnNames (void) const |
| std::set< std::string > | getColumnNames (void) const |
| std::map< std::string, unsigned int > | getColumnNamesMap (void) const |
| std::set< std::string > | getColumnStorageNames (void) const |
| const std::vector< std::string > & | getDefaultRowValues (void) const |
| std::string | getMismatchColumnInfo (void) const |
| unsigned int | getNumberOfRows (void) const |
| unsigned int | getNumberOfColumns (void) const |
| unsigned int | getColUID (void) const |
| unsigned int | getColStatus (void) const |
| unsigned int | getColPriority (void) const |
| std::set< std::string > | getSetOfGroupIDs (const std::string &childLinkIndex, unsigned int row=-1) const |
| std::set< std::string > | getSetOfGroupIDs (const unsigned int &col, unsigned int row=-1) const |
| bool | isEntryInGroup (const unsigned int &row, const std::string &childLinkIndex, const std::string &groupNeedle) const |
| bool | getChildLink (const unsigned int &col, bool &isGroup, std::pair< unsigned int, unsigned int > &linkPair) const |
| unsigned int | getLinkGroupIDColumn (const std::string &childLinkIndex) const |
| std::vector< unsigned int > | getGroupRows (const unsigned int groupIdCol, const std::string &groupID, bool onlyStatusTrue=false, bool orderedByPriority=false) const |
| std::vector< std::vector< unsigned int > > | getGroupRowsByPriority (const unsigned int groupIdCol, const std::string &groupID, bool onlyStatusTrue=false) const |
| void | addRowToGroup (const unsigned int &row, const unsigned int &col, const std::string &groupID) |
| , const std::string& colDefault); More... | |
| bool | removeRowFromGroup (const unsigned int &row, const unsigned int &col, const std::string &groupID, bool deleteRowIfNoGroupLeft=false) |
| template<class T > | |
| void | getValue (T &value, unsigned int row, unsigned int col, bool doConvertEnvironmentVariables=true) const |
| < in included .icc source | |
| void | getValue (std::string &value, unsigned int row, unsigned int col, bool doConvertEnvironmentVariables=true) const |
| template<class T > | |
| T | validateValueForColumn (const std::string &value, unsigned int col, bool doConvertEnvironmentVariables=true) const |
| < in included .icc source | |
| std::string | validateValueForColumn (const std::string &value, unsigned int col, bool convertEnvironmentVariables=true) const |
| std::string | getValueAsString (unsigned int row, unsigned int col, bool convertEnvironmentVariables=true) const |
| std::string | getEscapedValueAsString (unsigned int row, unsigned int col, bool convertEnvironmentVariables=true) const |
| bool | isURIEncodedCommentTheSame (const std::string &comment) const |
| const DataView & | getDataView (void) const |
| const std::vector< TableViewColumnInfo > & | getColumnsInfo (void) const |
| std::vector< TableViewColumnInfo > * | getColumnsInfoP (void) |
| const TableViewColumnInfo & | getColumnInfo (unsigned int column) const |
| void | setCustomStorageData (const std::string &storageData) |
| void | setComment (const std::string &comment) |
| void | setURIEncodedComment (const std::string &uriComment) |
| void | setAuthor (const std::string &author) |
| void | setCreationTime (time_t t) |
| void | setLastAccessTime (time_t t=time(0)) |
| void | setLooseColumnMatching (bool setValue) |
| void | doGetSourceRawData (bool setValue) |
| const std::string & | getSourceRawData (void) |
| template<class T > | |
| void | setVersion (const T &version) |
| < in included .icc source | |
| template<class T > | |
| void | setValue (const T &value, unsigned int row, unsigned int col) |
| < in included .icc source | |
| void | setValue (const std::string &value, unsigned int row, unsigned int col) |
| void | setValue (const char *value, unsigned int row, unsigned int col) |
| void | setValueAsString (const std::string &value, unsigned int row, unsigned int col) |
| const std::string & | setUniqueColumnValue (unsigned int row, unsigned int col, std::string baseValueAsString="", bool doMathAppendStrategy=false, std::string childLinkIndex="", std::string groupId="") |
| void | resizeDataView (unsigned int nRows, unsigned int nCols) |
| unsigned int | addRow (const std::string &author="", unsigned char incrementUniqueData=false, const std::string &baseNameAutoUID="", unsigned int rowToAdd=(unsigned int) -1, std::string childLinkIndex="", std::string groupId="") |
| void | deleteRow (int r) |
| void | deleteAllRows (void) |
| iterator | begin (void) |
| iterator | end (void) |
| const_iterator | begin (void) const |
| const_iterator | end (void) const |
| void | reset (void) |
| void | print (std::ostream &out=std::cout) const |
| void | printJSON (std::ostream &out=std::cout) const |
| int | fillFromJSON (const std::string &json) |
| int | fillFromCSV (const std::string &data, const int &dataOffset=0, const std::string &author="") |
| bool | setURIEncodedValue (const std::string &value, const unsigned int &row, const unsigned int &col, const std::string &author="") |
Static Public Attributes | |
| static const unsigned int | INVALID = -1 |
Definition at line 20 of file TableView.h.
| unsigned int TableView::addRow | ( | const std::string & | author = "", |
| unsigned char | incrementUniqueData = false, |
||
| const std::string & | baseNameAutoUID = "", |
||
| unsigned int | rowToAdd = (unsigned int)-1, |
||
| std::string | childLinkIndex = "", |
||
| std::string | groupId = "" |
||
| ) |
addRow returns index of added row, always is last row return -1 on failure (throw error)
if baseNameAutoUID != "", creates a UID based on this base name and increments and appends an integer relative to the previous last row
| incrementUniqueData | leave as unsigned char rather than bool, too many things (e.g. strings) evaluate successfully to bool values |
| rowToAdd | returns index of added row, default is last row |
| childLinkIndex | to allow for handling TableViewColumnInfo::TYPE_UNIQUE_GROUP_DATA |
Definition at line 3339 of file TableView.cc.
| void TableView::addRowToGroup | ( | const unsigned int & | row, |
| const unsigned int & | col, | ||
| const std::string & | groupID | ||
| ) |
, const std::string& colDefault);
addRowToGroup Group entry can include | to place a record in multiple groups
Definition at line 1448 of file TableView.cc.
|
inline |
Lore did not like this.. wants special access through separate Supervisor for "Database Management" int addColumn(std::string name, std::string viewName, std::string viewType); //returns index of added column, always is last column unless
Definition at line 210 of file TableView.h.
| unsigned int TableView::copyRows | ( | const std::string & | author, |
| const TableView & | src, | ||
| unsigned int | srcOffsetRow = 0, |
||
| unsigned int | srcRowsToCopy = (unsigned int)-1, |
||
| unsigned int | destOffsetRow = (unsigned int)-1, |
||
| unsigned char | generateUniqueDataColumns = false, |
||
| const std::string & | baseNameAutoUID = "" |
||
| ) |
copyRows return row offset of first row copied in
| generateUniqueDataColumns | leave as unsigned char rather than bool, too many things (e.g. strings) evaluate successfully to bool values |
Definition at line 125 of file TableView.cc.
| void TableView::deleteRow | ( | int | r | ) |
deleteRow throws exception on failure
Definition at line 3424 of file TableView.cc.
| int TableView::fillFromCSV | ( | const std::string & | data, |
| const int & | dataOffset = 0, |
||
| const std::string & | author = "" |
||
| ) |
============================================================================== bool TableView::isValueTheSame(const std::string &valueStr, unsigned int r, unsigned int c) const fillFromCSV Fills the view from the CSV string.
Note: converts all %## to the ascii character, # is hex nibble (e.g. '' must be represented as "%25")
dataOffset := starting destination row
while there are row entries in the data.. replace data range from [dataOffset, dataOffset+chunkSize-1] ... note if less rows, this means rows were deleted ... if more, then rows were added.
',' next cell delimiter ';' next row delimiter
if author == "", do nothing special for author and timestamp column if author != "", assign author for any row that has been modified, and assign now as timestamp
Returns -1 if data was same and pre-existing content Returns 1 if data was same, but columns are different otherwise 0
Definition at line 3111 of file TableView.cc.
| int TableView::fillFromJSON | ( | const std::string & | json | ) |
fillFromJSON Clears and fills the view from the JSON string. Returns -1 on failure
first level keys: NAME DATA_SET
Definition at line 2337 of file TableView.cc.
| unsigned int TableView::findCol | ( | const std::string & | wildCardName | ) | const |
findCol throws exception if column not found by name
Definition at line 1935 of file TableView.cc.
| unsigned int TableView::findColByType | ( | const std::string & | type, |
| unsigned int | startingCol = 0 |
||
| ) | const |
findColByType return invalid if type not found
Definition at line 1958 of file TableView.cc.
| bool TableView::getChildLink | ( | const unsigned int & | c, |
| bool & | isGroup, | ||
| std::pair< unsigned int, unsigned int > & | linkPair | ||
| ) | const |
getChildLink ~ find the pair of columns associated with a child link.
c := a member column of the pair
returns: isGroup := indicates pair found is a group link linkPair := pair of columns that are part of the link
a unique link is defined by two columns: TYPE_START_CHILD_LINK, TYPE_START_CHILD_LINK_UID a group link is defined by two columns: TYPE_START_CHILD_LINK, TYPE_START_CHILD_LINK_GROUP_ID
returns true if column is member of a group or unique link.
Definition at line 3454 of file TableView.cc.
| unsigned int TableView::getColPriority | ( | void | ) | const |
getColPriority const version, so don't attempt to lookup if column not found throw error
Note: common for Priority column to not exist, so be quiet with printouts so as to not scare people.
Definition at line 1421 of file TableView.cc.
| unsigned int TableView::getColStatus | ( | void | ) | const |
getColStatus const version, so don't attempt to lookup if column not found throw error
Definition at line 1390 of file TableView.cc.
| unsigned int TableView::getColUID | ( | void | ) | const |
getColOfUID const version, so don't attempt to lookup if column not found throw error
Definition at line 1305 of file TableView.cc.
| unsigned int TableView::getDataColumnSize | ( | void | ) | const |
| std::string TableView::getEscapedValueAsString | ( | unsigned int | row, |
| unsigned int | col, | ||
| bool | doConvertEnvironmentVariables = true |
||
| ) | const |
getEscapedValueAsString gets the value with the proper data type and converts to string as though getValue was called. then escapes all special characters with slash. Note: this should be useful for values placed in double quotes, i.e. JSON.
Definition at line 1018 of file TableView.cc.
| std::vector< unsigned int > TableView::getGroupRows | ( | const unsigned int | groupIdCol, |
| const std::string & | groupID, | ||
| bool | onlyStatusTrue = false, |
||
| bool | orderedByPriority = false |
||
| ) | const |
getGroupRows Get the rows of all records with groupID with consideration for status on/off and priority, if enabled with flags
Note: empty group id of "" or '*' will return all rows
Definition at line 1480 of file TableView.cc.
| std::vector< std::vector< unsigned int > > TableView::getGroupRowsByPriority | ( | const unsigned int | groupIdCol, |
| const std::string & | groupID, | ||
| bool | onlyStatusTrue = false |
||
| ) | const |
getGroupRowsByPriority Get the rows of all records with groupID with consideration for status on/off and priority, if enabled with flags
Note: empty group id of "" or '*' will return all rows
Definition at line 1503 of file TableView.cc.
| unsigned int TableView::getLinkGroupIDColumn | ( | const std::string & | childLinkIndex | ) | const |
getColOfLinkGroupID const version, if column not found throw error
Definition at line 1820 of file TableView.cc.
| std::set< std::string > TableView::getSetOfGroupIDs | ( | const std::string & | childLinkIndex, |
| unsigned int | r = -1 |
||
| ) | const |
getSetOfGroupIDs if row == -1, then considers all rows else just that row returns unique set of groupIds in GroupID column associate with childLinkIndex
Note: should mirror what happens in TableView::isEntryInGroupCol
Definition at line 1719 of file TableView.cc.
| void TableView::getValue | ( | std::string & | value, |
| unsigned int | row, | ||
| unsigned int | col, | ||
| bool | doConvertEnvironmentVariables = true |
||
| ) | const |
special version of getValue for string type Note: necessary because types of std::basic_string<char> cause compiler problems if no string specific function
getValue string version Note: necessary because types of std::basic_string<char> cause compiler problems if no string specific function
Definition at line 879 of file TableView.cc.
| std::string TableView::getValueAsString | ( | unsigned int | row, |
| unsigned int | col, | ||
| bool | doConvertEnvironmentVariables = true |
||
| ) | const |
getValueAsString gets the value with the proper data type and converts to string as though getValue was called.
Definition at line 969 of file TableView.cc.
| void TableView::init | ( | void | ) |
init Should be called after table is filled to setup special members and verify consistency. e.g. identifying the UID column, checking unique data fields, etc.
Note: this function also sanitizes yes/no, on/off, and true/false types
Definition at line 189 of file TableView.cc.
| bool TableView::isEntryInGroup | ( | const unsigned int & | r, |
| const std::string & | childLinkIndex, | ||
| const std::string & | groupNeedle | ||
| ) | const |
isEntryInGroup All group link checking should use this function so that handling is consistent
Group entry can include | to place a record in multiple groups
Definition at line 1635 of file TableView.cc.
| bool TableView::removeRowFromGroup | ( | const unsigned int & | row, |
| const unsigned int & | col, | ||
| const std::string & | groupNeedle, | ||
| bool | deleteRowIfNoGroupLeft = false |
||
| ) |
removeRowFromGroup Group entry can include | to place a record in multiple groups
returns true if row was deleted because it had no group left
Definition at line 1582 of file TableView.cc.
|
inline |
Setters
Definition at line 167 of file TableView.h.
| const std::string & TableView::setUniqueColumnValue | ( | unsigned int | row, |
| unsigned int | col, | ||
| std::string | baseValueAsString = "", |
||
| bool | doMathAppendStrategy = false, |
||
| std::string | childLinkIndex = "", |
||
| std::string | groupId = "" |
||
| ) |
setUniqueColumnValue Auto-generates a unique value for the specified column and places value at row,col position (a la add row unique value handling)
Note: doMathAppendStrategy enables appending with a match string e.g. ${PORT} + 1 .. then + 2, etc. (i.e. baseValueAsString = "${PORT}")
| childLinkIndex | to allow for handling TableViewColumnInfo::TYPE_UNIQUE_GROUP_DATA |
Definition at line 1098 of file TableView.cc.
| void TableView::setURIEncodedComment | ( | const std::string & | uriComment | ) |
Setters
Definition at line 2091 of file TableView.cc.
| bool TableView::setURIEncodedValue | ( | const std::string & | value, |
| const unsigned int & | r, | ||
| const unsigned int & | c, | ||
| const std::string & | author = "" |
||
| ) |
setURIEncodedValue converts all %## to the ascii character returns true if value was different than original value
if author == "", do nothing special for author and timestamp column if author != "", assign author for any row that has been modified, and assign now as timestamp
Definition at line 3247 of file TableView.cc.
| void TableView::setValue | ( | const std::string & | value, |
| unsigned int | row, | ||
| unsigned int | col | ||
| ) |
setValue string version
Definition at line 1047 of file TableView.cc.
| void TableView::setValueAsString | ( | const std::string & | value, |
| unsigned int | row, | ||
| unsigned int | col | ||
| ) |
Careful: The setValueAsString method is used to set the value without any consistency check with the data type
setValueAsString string version
Definition at line 1078 of file TableView.cc.
| std::string TableView::validateValueForColumn | ( | const std::string & | value, |
| unsigned int | col, | ||
| bool | doConvertEnvironmentVariables = true |
||
| ) | const |
special version of getValue for string type Note: necessary because types of std::basic_string<char> cause compiler problems if no string specific function
validateValueForColumn string version Note: necessary because types of std::basic_string<char> cause compiler problems if no string specific function
Definition at line 901 of file TableView.cc.