1 #ifndef _ots_TableView_h_
2 #define _ots_TableView_h_
4 #include "otsdaq/Macros/CoutMacros.h"
5 #include "otsdaq/Macros/StringMacros.h"
6 #include "otsdaq/MessageFacility/MessageFacility.h"
14 #include "otsdaq/TableCore/TableVersion.h"
15 #include "otsdaq/TableCore/TableViewColumnInfo.h"
23 static const unsigned int INVALID;
24 typedef std::vector<std::vector<std::string> > DataView;
25 typedef DataView::iterator iterator;
26 typedef DataView::const_iterator const_iterator;
34 const std::string& author);
35 unsigned int copyRows (
const std::string& author,
37 unsigned int srcOffsetRow = 0,
38 unsigned int srcRowsToCopy = (
unsigned int)-1,
39 unsigned int destOffsetRow = (
unsigned int)-1,
40 unsigned char generateUniqueDataColumns =
false,
43 const std::string& baseNameAutoUID =
""
49 unsigned int offsetRow = 0,
50 bool doNotThrow =
false)
const;
51 unsigned int findRow (
unsigned int col,
52 const std::string& value,
53 unsigned int offsetRow = 0,
54 bool doNotThrow =
false)
const;
59 const std::string& groupId,
60 const std::string& childLinkIndex,
61 unsigned int offsetRow = 0)
const;
63 const std::string& value,
64 const std::string& groupId,
65 const std::string& childLinkIndex,
66 unsigned int offsetRow = 0)
const;
67 unsigned int findCol (
const std::string& name)
const;
68 unsigned int findColByType (
const std::string& type,
unsigned int startingCol = 0)
const;
72 const std::string& getTableName (
void)
const {
return tableName_; }
73 const TableVersion& getVersion (
void)
const {
return version_; }
74 const std::string& getComment (
void)
const {
return comment_; }
75 const std::string& getAuthor (
void)
const {
return author_; }
76 const time_t& getCreationTime (
void)
const {
return creationTime_; }
77 const time_t& getLastAccessTime (
void)
const {
return lastAccessTime_; }
78 const bool& getLooseColumnMatching (
void)
const {
return fillWithLooseColumnMatching_; }
80 const unsigned int& getSourceColumnMismatch (
void)
const {
return sourceColumnMismatchCount_; }
81 const unsigned int& getSourceColumnMissing (
void)
const {
return sourceColumnMissingCount_; }
82 const std::set<std::string >& getSourceColumnNames (
void)
const {
return sourceColumnNames_; }
83 std::set<std::string > getColumnNames (
void)
const;
84 std::map<std::string,
unsigned int > getColumnNamesMap (
void)
const;
85 std::set<std::string > getColumnStorageNames (
void)
const;
86 const std::vector<std::string >& getDefaultRowValues (
void)
const {
return rowDefaultValues_; }
87 std::string getMismatchColumnInfo (
void)
const;
89 unsigned int getNumberOfRows (
void)
const {
return theDataView_.size(); }
90 unsigned int getNumberOfColumns (
void)
const {
return columnsInfo_.size(); }
99 bool isEntryInGroupCol (
const unsigned int& row,
100 const unsigned int& groupCol,
101 const std::string& groupNeedle,
102 std::set<std::string>* groupIDList = 0)
const;
106 std::set<std::string >
getSetOfGroupIDs (
const std::string& childLinkIndex,
unsigned int row = -1)
const;
107 std::set<std::string >
getSetOfGroupIDs (
const unsigned int& col,
unsigned int row = -1)
const;
109 const std::string& childLinkIndex,
110 const std::string& groupNeedle)
const;
113 std::pair<
unsigned int ,
114 unsigned int >& linkPair)
const;
116 std::vector<
unsigned int >
getGroupRows (
const unsigned int groupIdCol,
const std::string& groupID,
bool onlyStatusTrue =
false,
bool orderedByPriority =
false)
const;
117 std::vector<std::vector<
unsigned int >>
getGroupRowsByPriority (
const unsigned int groupIdCol,
const std::string& groupID,
bool onlyStatusTrue =
false)
const;
119 std::vector<std::vector<
unsigned int >> getGroupRowsInVectors (
const unsigned int groupIdCol,
const std::string& groupID,
bool onlyStatusTrue,
bool orderedByPriority)
const;
122 const unsigned int& col,
123 const std::string& groupID);
125 const unsigned int& col,
126 const std::string& groupID,
127 bool deleteRowIfNoGroupLeft =
false);
133 bool doConvertEnvironmentVariables =
true)
const;
140 bool doConvertEnvironmentVariables =
true)
const;
145 bool doConvertEnvironmentVariables =
true)
const;
151 bool convertEnvironmentVariables =
true)
const;
154 bool convertEnvironmentVariables =
true)
const;
157 bool convertEnvironmentVariables =
true)
const;
158 bool isURIEncodedCommentTheSame (
const std::string& comment)
const;
160 const DataView& getDataView (
void)
const {
return theDataView_; }
161 const std::vector<TableViewColumnInfo>& getColumnsInfo (
void)
const {
return columnsInfo_; }
162 std::vector<TableViewColumnInfo>* getColumnsInfoP (
void) {
return &columnsInfo_; }
163 const TableViewColumnInfo& getColumnInfo (
unsigned int column)
const;
168 void setComment (
const std::string& comment) { comment_ = comment; }
170 void setAuthor (
const std::string& author);
171 void setCreationTime (time_t t);
172 void setLastAccessTime (time_t t = time(0));
173 void setLooseColumnMatching (
bool setValue);
174 void doGetSourceRawData (
bool setValue);
175 const std::string& getSourceRawData (
void) {
return sourceRawData_; }
180 void setValue (
const T& value,
unsigned int row,
unsigned int col);
181 void setValue (
const std::string& value,
unsigned int row,
unsigned int col);
182 void setValue (
const char* value,
unsigned int row,
unsigned int col);
186 void setValueAsString (
const std::string& value,
unsigned int row,
unsigned int col);
187 const std::string&
setUniqueColumnValue (
unsigned int row,
unsigned int col, std::string baseValueAsString =
"",
188 bool doMathAppendStrategy =
false,
189 std::string childLinkIndex =
"",
190 std::string groupId =
"");
191 void resizeDataView (
unsigned int nRows,
unsigned int nCols);
192 unsigned int addRow (
const std::string& author =
"",
193 unsigned char incrementUniqueData =
false,
196 const std::string& baseNameAutoUID =
"",
197 unsigned int rowToAdd =
199 std::string childLinkIndex =
"",
200 std::string groupId =
"");
202 void deleteAllRows (
void) {theDataView_.clear();}
210 iterator
begin (
void) {
return theDataView_.begin(); }
211 iterator end (
void) {
return theDataView_.end(); }
212 const_iterator
begin (
void)
const {
return theDataView_.begin(); }
213 const_iterator end (
void)
const {
return theDataView_.end(); }
215 void print (std::ostream& out = std::cout)
const;
216 void printJSON (std::ostream& out = std::cout)
const;
219 const int& dataOffset = 0,
220 const std::string& author =
"");
222 const unsigned int& row,
223 const unsigned int& col,
224 const std::string& author =
"");
227 unsigned int initColUID (
void);
228 unsigned int initColStatus (
void);
229 unsigned int initColPriority (
void);
230 const std::vector<std::string >& initRowDefaults (
void);
236 std::string storageData_;
237 const std::string tableName_;
238 TableVersion version_;
239 std::string comment_;
241 time_t creationTime_;
242 time_t lastAccessTime_;
244 std::vector<std::string> rowDefaultValues_;
245 unsigned int colUID_, colStatus_, colPriority_;
246 std::map<std::string, unsigned int> colLinkGroupIDs_;
248 bool fillWithLooseColumnMatching_;
249 bool getSourceRawData_;
250 std::string sourceRawData_;
251 unsigned int sourceColumnMismatchCount_, sourceColumnMissingCount_;
252 std::set<std::string> sourceColumnNames_;
254 std::vector<TableViewColumnInfo> columnsInfo_;
255 DataView theDataView_;
258 #include "otsdaq/TableCore/TableView.icc"
unsigned int findRow(unsigned int col, const T &value, unsigned int offsetRow=0, bool doNotThrow=false) const
< in included .icc source
bool isEntryInGroup(const unsigned int &row, const std::string &childLinkIndex, const std::string &groupNeedle) const
void setValueAsString(const std::string &value, unsigned int row, unsigned int col)
std::vector< std::vector< unsigned int > > getGroupRowsByPriority(const unsigned int groupIdCol, const std::string &groupID, bool onlyStatusTrue=false) const
T validateValueForColumn(const std::string &value, unsigned int col, bool doConvertEnvironmentVariables=true) const
< in included .icc source
TableView(const std::string &tableName)
= "");
std::string getEscapedValueAsString(unsigned int row, unsigned int col, bool convertEnvironmentVariables=true) const
unsigned int getColStatus(void) const
unsigned int getLinkGroupIDColumn(const std::string &childLinkIndex) const
int fillFromCSV(const std::string &data, const int &dataOffset=0, const std::string &author="")
bool removeRowFromGroup(const unsigned int &row, const unsigned int &col, const std::string &groupID, bool deleteRowIfNoGroupLeft=false)
unsigned int findColByType(const std::string &type, unsigned int startingCol=0) const
bool getChildLink(const unsigned int &col, bool &isGroup, std::pair< unsigned int, unsigned int > &linkPair) const
void addRowToGroup(const unsigned int &row, const unsigned int &col, const std::string &groupID)
, const std::string& colDefault);
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="")
void setVersion(const T &version)
< in included .icc source
unsigned int getColPriority(void) const
const std::string & setUniqueColumnValue(unsigned int row, unsigned int col, std::string baseValueAsString="", bool doMathAppendStrategy=false, std::string childLinkIndex="", std::string groupId="")
std::string getValueAsString(unsigned int row, unsigned int col, bool convertEnvironmentVariables=true) const
std::vector< unsigned int > getGroupRows(const unsigned int groupIdCol, const std::string &groupID, bool onlyStatusTrue=false, bool orderedByPriority=false) const
const std::string & getCustomStorageData(void) const
Getters.
std::set< std::string > getSetOfGroupIDs(const std::string &childLinkIndex, unsigned int row=-1) const
void getValue(T &value, unsigned int row, unsigned int col, bool doConvertEnvironmentVariables=true) const
< in included .icc source
unsigned int getDataColumnSize(void) const
getDataColumnSize
int fillFromJSON(const std::string &json)
unsigned int getColUID(void) const
bool setURIEncodedValue(const std::string &value, const unsigned int &row, const unsigned int &col, const std::string &author="")
unsigned int findCol(const std::string &name) const
void setValue(const T &value, unsigned int row, unsigned int col)
< in included .icc source
void setURIEncodedComment(const std::string &uriComment)
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="")
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
void setCustomStorageData(const std::string &storageData)