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 =
""
47 unsigned int findRow (
unsigned int col,
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;
57 unsigned int findRowInGroup (
unsigned int col,
59 const std::string& groupId,
60 const std::string& childLinkIndex,
61 unsigned int offsetRow = 0)
const;
62 unsigned int findRowInGroup (
unsigned int col,
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,
int startingCol = 0)
const;
71 const std::string& getUniqueStorageIdentifier (
void)
const;
72 const std::string& getTableName (
void)
const;
74 const std::string& getComment (
void)
const;
75 const std::string& getAuthor (
void)
const;
76 const time_t& getCreationTime (
void)
const;
77 const time_t& getLastAccessTime (
void)
const;
78 const bool& getLooseColumnMatching (
void)
const;
79 unsigned int getDataColumnSize (
void)
const;
80 const unsigned int& getSourceColumnMismatch (
void)
const;
81 const unsigned int& getSourceColumnMissing (
void)
const;
82 const std::set<std::string >& getSourceColumnNames (
void)
const;
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 std::vector<std::string > getDefaultRowValues (
void)
const;
88 unsigned int getNumberOfRows (
void)
const;
89 unsigned int getNumberOfColumns (
void)
const;
90 unsigned int getColUID (
void)
const;
91 unsigned int getColStatus (
void)
const;
92 unsigned int getColPriority (
void)
const;
98 bool isEntryInGroupCol (
const unsigned int& row,
99 const unsigned int& groupCol,
100 const std::string& groupNeedle,
101 std::set<std::string>* groupIDList = 0)
const;
105 std::set<std::string > getSetOfGroupIDs (
const std::string& childLinkIndex,
unsigned int row = -1)
const;
106 std::set<std::string > getSetOfGroupIDs (
const unsigned int& col,
unsigned int row = -1)
const;
107 bool isEntryInGroup (
const unsigned int& row,
108 const std::string& childLinkIndex,
109 const std::string& groupNeedle)
const;
110 bool getChildLink (
const unsigned int& col,
112 std::pair<
unsigned int ,
113 unsigned int >& linkPair)
const;
114 unsigned int getLinkGroupIDColumn (
const std::string& childLinkIndex)
const;
115 std::vector<
unsigned int > getGroupRows (
const unsigned int groupIdCol,
const std::string& groupID,
bool onlyStatusTrue =
false,
bool orderedByPriority =
false)
const;
116 std::vector<std::vector<
unsigned int >> getGroupRowsByPriority (
const unsigned int groupIdCol,
const std::string& groupID,
bool onlyStatusTrue =
false)
const;
118 std::vector<std::vector<
unsigned int >> getGroupRowsInVectors (
const unsigned int groupIdCol,
const std::string& groupID,
bool onlyStatusTrue,
bool orderedByPriority)
const;
120 void addRowToGroup (
const unsigned int& row,
121 const unsigned int& col,
122 const std::string& groupID);
123 bool removeRowFromGroup (
const unsigned int& row,
124 const unsigned int& col,
125 const std::string& groupID,
126 bool deleteRowIfNoGroupLeft =
false);
129 void getValue (T& value,
132 bool doConvertEnvironmentVariables =
true)
const;
136 void getValue (std::string& value,
139 bool doConvertEnvironmentVariables =
true)
const;
142 T validateValueForColumn (
const std::string& value,
144 bool doConvertEnvironmentVariables =
true)
const;
148 std::string validateValueForColumn (
const std::string& value,
150 bool convertEnvironmentVariables =
true)
const;
151 std::string getValueAsString (
unsigned int row,
153 bool convertEnvironmentVariables =
true)
const;
154 std::string getEscapedValueAsString (
unsigned int row,
156 bool convertEnvironmentVariables =
true)
const;
157 bool isURIEncodedCommentTheSame (
const std::string& comment)
const;
159 const DataView& getDataView (
void)
const;
160 const std::vector<TableViewColumnInfo>& getColumnsInfo (
void)
const;
161 std::vector<TableViewColumnInfo>* getColumnsInfoP (
void);
166 void setUniqueStorageIdentifier (
const std::string& storageUID);
168 void setComment (
const std::string& comment);
169 void setURIEncodedComment (
const std::string& uriComment);
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);
176 void setVersion (
const T& version);
178 void setValue (
const T& value,
unsigned int row,
unsigned int col);
179 void setValue (
const std::string& value,
unsigned int row,
unsigned int col);
180 void setValue (
const char* value,
unsigned int row,
unsigned int col);
184 void setValueAsString (
const std::string& value,
unsigned int row,
unsigned int col);
185 const std::string& setUniqueColumnValue (
unsigned int row,
unsigned int col, std::string baseValueAsString =
"",
bool doMathAppendStrategy =
false);
187 void resizeDataView (
unsigned int nRows,
unsigned int nCols);
188 unsigned int addRow (
const std::string& author =
"",
189 unsigned char incrementUniqueData =
false,
192 const std::string& baseNameAutoUID =
"",
193 unsigned int rowToAdd =
195 void deleteRow (
int r);
196 void deleteAllRows (
void) {theDataView_.clear();}
204 iterator begin (
void) {
return theDataView_.begin(); }
205 iterator end (
void) {
return theDataView_.end(); }
206 const_iterator begin (
void)
const {
return theDataView_.begin(); }
207 const_iterator end (
void)
const {
return theDataView_.end(); }
209 void print (std::ostream& out = std::cout)
const;
210 void printJSON (std::ostream& out = std::cout)
const;
211 int fillFromJSON (
const std::string& json);
212 int fillFromCSV (
const std::string& data,
213 const int& dataOffset = 0,
214 const std::string& author =
"");
215 bool setURIEncodedValue (
const std::string& value,
216 const unsigned int& row,
217 const unsigned int& col,
218 const std::string& author =
"");
221 unsigned int initColUID (
void);
222 unsigned int initColStatus (
void);
223 unsigned int initColPriority (
void);
229 std::string uniqueStorageIdentifier_;
230 const std::string tableName_;
232 std::string comment_;
234 time_t creationTime_;
235 time_t lastAccessTime_;
237 unsigned int colUID_, colStatus_, colPriority_;
238 std::map<std::string, unsigned int> colLinkGroupIDs_;
240 bool fillWithLooseColumnMatching_;
241 unsigned int sourceColumnMismatchCount_, sourceColumnMissingCount_;
242 std::set<std::string> sourceColumnNames_;
244 std::vector<TableViewColumnInfo> columnsInfo_;
245 DataView theDataView_;
248 #include "otsdaq/TableCore/TableView.icc"