otsdaq  3.03.00
TableViewColumnInfo.cc
1 #include "otsdaq/TableCore/TableViewColumnInfo.h"
2 
3 #include "otsdaq/Macros/CoutMacros.h"
4 #include "otsdaq/Macros/StringMacros.h"
5 
6 #include <iostream>
7 #include <sstream>
8 #include <stdexcept>
9 
10 #include "otsdaq/TableCore/TableView.h"
11 
12 using namespace ots;
13 
14 // clang-format off
15 
17 const std::string TableViewColumnInfo::TYPE_UID = "UID";
18 
19 const std::string TableViewColumnInfo::TYPE_DATA = "Data";
20 const std::string TableViewColumnInfo::TYPE_UNIQUE_DATA = "UniqueData";
21 const std::string TableViewColumnInfo::TYPE_UNIQUE_GROUP_DATA = "UniqueGroupData";
22 const std::string TableViewColumnInfo::TYPE_MULTILINE_DATA = "MultilineData";
23 const std::string TableViewColumnInfo::TYPE_FIXED_CHOICE_DATA = "FixedChoiceData";
24 const std::string TableViewColumnInfo::TYPE_BITMAP_DATA = "BitMap";
25 
26 const std::string TableViewColumnInfo::TYPE_ON_OFF = "OnOff";
27 const std::string TableViewColumnInfo::TYPE_TRUE_FALSE = "TrueFalse";
28 const std::string TableViewColumnInfo::TYPE_YES_NO = "YesNo";
29 
30 const std::string TableViewColumnInfo::TYPE_START_CHILD_LINK = "ChildLink";
31 const std::string TableViewColumnInfo::TYPE_START_CHILD_LINK_UID = "ChildLinkUID";
32 const std::string TableViewColumnInfo::TYPE_START_CHILD_LINK_GROUP_ID = "ChildLinkGroupID";
33 const std::string TableViewColumnInfo::TYPE_START_GROUP_ID = "GroupID";
34 const std::string TableViewColumnInfo::TYPE_COMMENT = "Comment";
35 const std::string TableViewColumnInfo::TYPE_AUTHOR = "Author";
36 const std::string TableViewColumnInfo::TYPE_TIMESTAMP = "Timestamp";
39 const std::string TableViewColumnInfo::DATATYPE_NUMBER = "NUMBER";
40 const std::string TableViewColumnInfo::DATATYPE_STRING = "STRING";
41 const std::string TableViewColumnInfo::DATATYPE_TIME = "TIMESTAMP WITH TIMEZONE";
42 
43 const std::string TableViewColumnInfo::TYPE_VALUE_YES = "Yes";
44 const std::string TableViewColumnInfo::TYPE_VALUE_NO = "No";
45 const std::string TableViewColumnInfo::TYPE_VALUE_TRUE = "True";
46 const std::string TableViewColumnInfo::TYPE_VALUE_FALSE = "False";
47 const std::string TableViewColumnInfo::TYPE_VALUE_ON = "On";
48 const std::string TableViewColumnInfo::TYPE_VALUE_OFF = "Off";
49 
50 const std::string TableViewColumnInfo::DATATYPE_STRING_DEFAULT = "DEFAULT";
51 const std::string TableViewColumnInfo::DATATYPE_COMMENT_DEFAULT = "No comment.";
52 const std::string TableViewColumnInfo::DATATYPE_COMMENT_OLD_DEFAULT = "No Comment";
53 const std::string TableViewColumnInfo::DATATYPE_BOOL_DEFAULT = "0";
54 const std::string TableViewColumnInfo::DATATYPE_NUMBER_DEFAULT = "0";
55 
56 const std::string TableViewColumnInfo::DATATYPE_NUMBER_MIN_DEFAULT = "";
57 const std::string TableViewColumnInfo::DATATYPE_NUMBER_MAX_DEFAULT = "";
58 
59 const std::string TableViewColumnInfo::DATATYPE_TIME_DEFAULT = "0";
60 const std::string TableViewColumnInfo::DATATYPE_LINK_DEFAULT = "NO_LINK";
61 
62 const std::string TableViewColumnInfo::COL_NAME_STATUS = "Status";
63 const std::string TableViewColumnInfo::COL_NAME_ENABLED = "Enabled";
64 const std::string TableViewColumnInfo::COL_NAME_PRIORITY = "Priority";
65 const std::string TableViewColumnInfo::COL_NAME_COMMENT = "CommentDescription";
66 const std::string TableViewColumnInfo::COL_NAME_AUTHOR = "Author";
67 const std::string TableViewColumnInfo::COL_NAME_CREATION = "RecordInsertionTime";
68 
69 // clang-format on
70 
71 //==============================================================================
75 TableViewColumnInfo::TableViewColumnInfo(const std::string& type,
76  const std::string& name,
77  const std::string& storageName,
78  const std::string& dataType,
79  const std::string* defaultValue,
80  const std::string& dataChoicesCSV,
81  const std::string* minValue,
82  const std::string* maxValue,
83  std::string* capturedExceptionString)
84  : type_(type)
85  , name_(name)
86  , storageName_(storageName)
87  , dataType_(/*convert antiquated*/ dataType == "VARCHAR2" ? DATATYPE_STRING
88  : dataType)
89  , defaultValue_(defaultValue ? *defaultValue
90  : getDefaultDefaultValue(type_, dataType_))
91  , // if default pointer, take input default value
92  dataChoices_(getDataChoicesFromString(dataChoicesCSV))
93  , minValue_(minValue ? ((*minValue) == "null" ? "" : (*minValue))
94  : getMinDefaultValue(dataType_))
95  , // there was a time during JS GUI development when "null" was being injected into data files rather than empty strings. Because this member variable is
96  // constant, this is the single cleansing point.
97  maxValue_(maxValue ? ((*maxValue) == "null" ? "" : (*maxValue))
98  : getMaxDefaultValue(dataType_))
99  , // there was a time during JS GUI development when "null" was being injected into data files rather than empty strings. Because this member variable is
100  // constant, this is the single cleansing point.
101  bitMapInfoP_(nullptr)
102 {
103  //keep lightweight because tables+columns get copied around a lot
104 
105  // verify type
106  if((type_ != TYPE_UID) && (type_ != TYPE_DATA) && (type_ != TYPE_UNIQUE_DATA) &&
107  (type_ != TYPE_UNIQUE_GROUP_DATA) && (type_ != TYPE_MULTILINE_DATA) &&
108  (type_ != TYPE_FIXED_CHOICE_DATA) && (type_ != TYPE_BITMAP_DATA) &&
109  (type_ != TYPE_ON_OFF) && (type_ != TYPE_TRUE_FALSE) && (type_ != TYPE_YES_NO) &&
110  (type_ != TYPE_COMMENT) && (type_ != TYPE_AUTHOR) && (type_ != TYPE_TIMESTAMP) &&
112  {
113  __SS__ << "The type for column " << name_ << " is " << type_
114  << ", while the only accepted types are: " << TYPE_DATA << " "
115  << TYPE_UNIQUE_DATA << " " << TYPE_UNIQUE_GROUP_DATA << " "
116  << TYPE_MULTILINE_DATA << " " << TYPE_FIXED_CHOICE_DATA << " " << TYPE_UID
117  << " " << TYPE_ON_OFF << " " << TYPE_TRUE_FALSE << " " << TYPE_YES_NO
118  << " " << TYPE_START_CHILD_LINK << "-* " << TYPE_START_CHILD_LINK_UID
119  << "-* " << TYPE_START_CHILD_LINK_GROUP_ID << "-* " << TYPE_START_GROUP_ID
120  << "-* " << std::endl;
121  if(capturedExceptionString)
122  *capturedExceptionString = ss.str();
123  else
124  __SS_THROW__;
125  }
126  else if(capturedExceptionString)
127  *capturedExceptionString = ""; // indicates no error found
128 
129  // enforce that type only
130  // allows letters, numbers, dash, underscore
131  for(unsigned int i = 0; i < type_.size(); ++i)
132  if(!((type_[i] >= 'A' && type_[i] <= 'Z') ||
133  (type_[i] >= 'a' && type_[i] <= 'z') ||
134  (type_[i] >= '0' && type_[i] <= '9') ||
135  (type_[i] == '-' || type_[i] == '_' || type_[i] == '.' || type_[i] == ' ')))
136  {
137  __SS__ << "The column type for column " << name_ << " is '" << type_
138  << "'. Column types must contain only letters, numbers, "
139  << "dashes, underscores, periods, and spaces." << std::endl;
140  if(capturedExceptionString)
141  *capturedExceptionString += ss.str();
142  else
143  __SS_THROW__;
144  }
145 
146  // verify data type
147  if((dataType_ != DATATYPE_NUMBER) && (dataType_ != DATATYPE_STRING) &&
148  (dataType_ != DATATYPE_TIME))
149  {
150  __SS__ << "The data type for column " << name_ << " is " << dataType_
151  << ", while the only accepted types are: " << DATATYPE_NUMBER << " "
152  << DATATYPE_STRING << " " << DATATYPE_TIME << std::endl;
153  if(capturedExceptionString)
154  *capturedExceptionString += ss.str();
155  else
156  __SS_THROW__;
157  }
158 
159  if(dataType_.size() == 0)
160  {
161  __SS__ << "The data type for column " << name_ << " is '" << dataType_
162  << "'. Data types must contain at least 1 character." << std::endl;
163  if(capturedExceptionString)
164  *capturedExceptionString += ss.str();
165  else
166  __SS_THROW__;
167  }
168 
169  // enforce that data type only
170  // allows letters, numbers, dash, underscore
171  for(unsigned int i = 0; i < dataType_.size(); ++i)
172  if(!((dataType_[i] >= 'A' && dataType_[i] <= 'Z') ||
173  (dataType_[i] >= 'a' && dataType_[i] <= 'z') ||
174  (dataType_[i] >= '0' && dataType_[i] <= '9') ||
175  (dataType_[i] == '-' || dataType_[i] == '_' || dataType_[i] == ' ')))
176  {
177  __SS__ << "The data type for column " << name_ << " is '" << dataType_
178  << "'. Data types must contain only letters, numbers, "
179  << "dashes, underscores, and spaces." << std::endl;
180  if(capturedExceptionString)
181  *capturedExceptionString += ss.str();
182  else
183  __SS_THROW__;
184  }
185 
186  if(name_.size() == 0)
187  {
188  __SS__ << "There is a column named " << name_
189  << "'. Column names must contain at least 1 character." << std::endl;
190  if(capturedExceptionString)
191  *capturedExceptionString += ss.str();
192  else
193  __SS_THROW__;
194  }
195 
196  // enforce that col name only
197  // allows letters, numbers, dash, underscore
198  for(unsigned int i = 0; i < name_.size(); ++i)
199  if(!((name_[i] >= 'A' && name_[i] <= 'Z') ||
200  (name_[i] >= 'a' && name_[i] <= 'z') ||
201  (name_[i] >= '0' && name_[i] <= '9') ||
202  (name_[i] == '-' || name_[i] == '_')))
203  {
204  __SS__ << "There is a column named " << name_
205  << "'. Column names must contain only letters, numbers, "
206  << "dashes, and underscores." << std::endl;
207  if(capturedExceptionString)
208  *capturedExceptionString += ss.str();
209  else
210  __SS_THROW__;
211  }
212 
213  if(storageName_.size() == 0)
214  {
215  __SS__ << "The storage name for column " << name_ << " is '" << storageName_
216  << "'. Storage names must contain at least 1 character." << std::endl;
217  if(capturedExceptionString)
218  *capturedExceptionString += ss.str();
219  else
220  __SS_THROW__;
221  }
222 
223  // enforce that col storage name only
224  // allows capital letters, numbers, dash, underscore
225  for(unsigned int i = 0; i < storageName_.size(); ++i)
226  if(!((storageName_[i] >= 'A' && storageName_[i] <= 'Z') ||
227  (storageName_[i] >= '0' && storageName_[i] <= '9') ||
228  (storageName_[i] == '-' || storageName_[i] == '_')))
229  {
230  __SS__ << "The storage name for column " << name_ << " is '" << storageName_
231  << "'. Storage names must contain only capital letters, numbers,"
232  << "dashes, and underscores." << std::endl;
233  if(capturedExceptionString)
234  *capturedExceptionString += ss.str();
235  else
236  __SS_THROW__;
237  }
238 
239  try
240  {
241  extractBitMapInfo();
242  }
243  catch(std::runtime_error& e)
244  {
245  if(capturedExceptionString)
246  *capturedExceptionString += e.what();
247  else
248  throw;
249  }
250 } //end TableViewColumnInfo() constructor
251 
252 //==============================================================================
253 std::vector<std::string> TableViewColumnInfo::getDataChoicesFromString(
254  const std::string& dataChoicesCSV) const
255 {
256  std::vector<std::string> dataChoices;
257  // build data choices vector from URI encoded data
258  //__COUT__ << "dataChoicesCSV " << dataChoicesCSV << std::endl;
259  {
260  std::istringstream f(dataChoicesCSV);
261  std::string s;
262  while(getline(f, s, ','))
263  dataChoices.push_back(StringMacros::decodeURIComponent(s));
264  // for(const auto &dc: dataChoices_)
265  // __COUT__ << dc << std::endl;
266  }
267  return dataChoices;
268 } // end getDataChoicesFromString()
269 
270 //==============================================================================
271 void TableViewColumnInfo::extractBitMapInfo()
272 {
273  // create BitMapInfo if this is a bitmap column
274  if(type_ == TYPE_BITMAP_DATA)
275  {
276  if(bitMapInfoP_)
277  delete bitMapInfoP_;
278  bitMapInfoP_ = new BitMapInfo();
279 
280  // extract bitMapInfo parameters:
281  // must match TableEditor js handling:
282 
283  // [ //types => 0:string, 1:bool (default no),
284  // //2:bool (default yes), 3:color
285  //
286  // 0 0,//"Number of Rows",
287  // 1 0,//"Number of Columns",
288  // 2 0,//"Cell Bit-field Size",
289  // 3 0,//"Min-value Allowed",
290  // 4 0,//"Max-value Allowed",
291  // 5 0,//"Value step-size Allowed",
292  // 6 0,//"Display Aspect H:W",
293  // 7 3,//"Min-value Cell Color",
294  // 8 3,//"Mid-value Cell Color",
295  // 9 3,//"Max-value Cell Color",
296  // 10 3,//"Absolute Min-value Cell Color",
297  // 11 3,//"Absolute Max-value Cell Color",
298  // 12 1,//"Display Rows in Ascending Order",
299  // 13 2,//"Display Columns in Ascending Order",
300  // 14 1,//"Snake Double Rows",
301  // 15 1,//"Snake Double Columns",
302  // 16 1,//"Allow Floating Point",
303  // 17 0 //"Value Map to Strings"
304  // ];
305 
306  if(dataChoices_.size() < 16)
307  {
308  __SS__ << "The Bit-Map data parameters for column " << name_
309  << " should be size 16, but is size " << dataChoices_.size()
310  << ". Bit-Map parameters should be e.g. rows, cols, cellBitSize, and "
311  "min, "
312  "mid, max color, etc."
313  << std::endl;
314  __SS_THROW__;
315  }
316  if(dataChoices_.size() > 18)
317  {
318  __SS__ << "The Bit-Map data parameters for column " << name_
319  << " should be size 18, but is size " << dataChoices_.size()
320  << ". Bit-Map parameters should be e.g. rows, cols, cellBitSize, and "
321  "min, "
322  "mid, max color, etc."
323  << std::endl;
324  __SS_THROW__;
325  }
326 
327  sscanf(dataChoices_[0].c_str(), "%u", &(bitMapInfoP_->numOfRows_));
328  sscanf(dataChoices_[1].c_str(), "%u", &(bitMapInfoP_->numOfColumns_));
329  sscanf(dataChoices_[2].c_str(), "%u", &(bitMapInfoP_->cellBitSize_));
330 
331  sscanf(dataChoices_[3].c_str(), "%lu", &(bitMapInfoP_->minValue_));
332  sscanf(dataChoices_[4].c_str(), "%lu", &(bitMapInfoP_->maxValue_));
333  sscanf(dataChoices_[5].c_str(), "%lu", &(bitMapInfoP_->stepValue_));
334 
335  bitMapInfoP_->aspectRatio_ = dataChoices_[6];
336  bitMapInfoP_->minColor_ = dataChoices_[7];
337  bitMapInfoP_->midColor_ = dataChoices_[8];
338  bitMapInfoP_->maxColor_ = dataChoices_[9];
339  bitMapInfoP_->absMinColor_ = dataChoices_[10];
340  bitMapInfoP_->absMaxColor_ = dataChoices_[11];
341 
342  bitMapInfoP_->rowsAscending_ = dataChoices_[12] == "Yes" ? 1 : 0;
343  bitMapInfoP_->colsAscending_ = dataChoices_[13] == "Yes" ? 1 : 0;
344  bitMapInfoP_->snakeRows_ = dataChoices_[14] == "Yes" ? 1 : 0;
345  bitMapInfoP_->snakeCols_ = dataChoices_[15] == "Yes" ? 1 : 0;
346 
347  bitMapInfoP_->snakeCols_ = dataChoices_[15] == "Yes" ? 1 : 0;
348  if(dataChoices_.size() > 16)
349  bitMapInfoP_->floatingPoint_ = dataChoices_[16] == "Yes" ? 1 : 0;
350  if(dataChoices_.size() > 17)
351  bitMapInfoP_->mapToStrings_ = dataChoices_[17];
352 
353  if(bitMapInfoP_->floatingPoint_ &&
354  bitMapInfoP_->cellBitSize_ != 32) //check floating point
355  {
356  __SS__ << "Illegal Bit-Map data parameters for column " << name_
357  << " - if floating point is allowed, the Bit-field size must be 32."
358  << std::endl;
359  __SS_THROW__;
360  }
361 
362  if(bitMapInfoP_->mapToStrings_ != "" &&
363  bitMapInfoP_->mapToStrings_ != TableViewColumnInfo::DATATYPE_STRING_DEFAULT)
364  {
365  if(bitMapInfoP_->floatingPoint_)
366  {
367  __SS__ << "Illegal Bit-Map data parameters for column " << name_
368  << " - if floating point is allowed, then Value Map to Strings "
369  "must be empty or set to 'DEFAULT.' "
370  << "Please disable floating point or clear the Value Map to "
371  "Strings value."
372  << std::endl;
373  __SS_THROW__;
374  }
375  bitMapInfoP_->mapsToStrings_ = true;
376  }
377  else
378  bitMapInfoP_->mapsToStrings_ = false;
379  }
380 } //end extractBitMapInfo()
381 
382 //==============================================================================
384 TableViewColumnInfo::TableViewColumnInfo(void) {}
385 
386 //==============================================================================
387 TableViewColumnInfo::TableViewColumnInfo(
388  const TableViewColumnInfo& c) // copy constructor because of bitmap pointer
389  : type_(c.type_)
390  , name_(c.name_)
391  , storageName_(c.storageName_)
392  , dataType_(c.dataType_)
393  , defaultValue_(c.defaultValue_)
394  , dataChoices_(c.dataChoices_)
395  , minValue_(c.minValue_)
396  , maxValue_(c.maxValue_)
397  , bitMapInfoP_(nullptr)
398 {
399  // extract bitmap info if necessary
400  extractBitMapInfo();
401 } // end copy constructor
402 
403 //==============================================================================
405  const TableViewColumnInfo&) // assignment operator because of bitmap pointer
406 {
407  __COUT__ << "OPERATOR= COPY CONSTRUCTOR " << std::endl;
408  // Note: Members of the ConfigurationTree are declared constant.
409  // (Refer to comments at top of class declaration for solutions)
410  // So this operator cannot work.. SO I am going to crash just in case it is
411  // called by mistake
412  __COUT__ << "OPERATOR= COPY CONSTRUCTOR CANNOT BE USED - TableViewColumnInfo is a "
413  "const class. SO YOUR CODE IS WRONG! You should probably instantiate "
414  "and initialize another TableViewColumnInfo, rather than assigning to "
415  "an existing TableViewColumnInfo. Crashing now."
416  << std::endl;
417  __COUT__ << "OPERATOR= COPY CONSTRUCTOR CANNOT BE USED - TableViewColumnInfo is a "
418  "const class. SO YOUR CODE IS WRONG! You should probably instantiate "
419  "and initialize another TableViewColumnInfo, rather than assigning to "
420  "an existing TableViewColumnInfo. Crashing now."
421  << std::endl;
422  __COUT__ << "OPERATOR= COPY CONSTRUCTOR CANNOT BE USED - TableViewColumnInfo is a "
423  "const class. SO YOUR CODE IS WRONG! You should probably instantiate "
424  "and initialize another TableViewColumnInfo, rather than assigning to "
425  "an existing TableViewColumnInfo. Crashing now."
426  << std::endl;
427  __COUT__ << "OPERATOR= COPY CONSTRUCTOR CANNOT BE USED - TableViewColumnInfo is a "
428  "const class. SO YOUR CODE IS WRONG! You should probably instantiate "
429  "and initialize another TableViewColumnInfo, rather than assigning to "
430  "an existing TableViewColumnInfo. Crashing now."
431  << std::endl;
432  __COUT__ << "OPERATOR= COPY CONSTRUCTOR CANNOT BE USED - TableViewColumnInfo is a "
433  "const class. SO YOUR CODE IS WRONG! You should probably instantiate "
434  "and initialize another TableViewColumnInfo, rather than assigning to "
435  "an existing TableViewColumnInfo. Crashing now."
436  << std::endl;
437 
438  __COUT__ << StringMacros::stackTrace() << __E__;
439  exit(0);
440  // TableViewColumnInfo* retColInfo = new TableViewColumnInfo();
441  // retColInfo->type_ = c.type_;
442  // retColInfo->name_ = c.name_;
443  // retColInfo->storageName_ = c.storageName_;
444  // retColInfo->dataType_ = c.dataType_;
445  // retColInfo->dataChoices_ = c.dataChoices_;
446  // retColInfo->bitMapInfoP_ = 0;
447 
448  // extract bitmap info if necessary
449  // retColInfo->extractBitMapInfo();
450 
451  extractBitMapInfo();
452  return *this; //*retColInfo;
453 } // end assignment operator
454 
455 //==============================================================================
456 TableViewColumnInfo::~TableViewColumnInfo(void)
457 {
458  if(bitMapInfoP_)
459  delete bitMapInfoP_;
460 } //end destructor
461 
462 //==============================================================================
463 const std::string& TableViewColumnInfo::getType(void) const { return type_; }
464 
465 //==============================================================================
467 const std::string& TableViewColumnInfo::getDefaultValue(void) const
468 {
469  return defaultValue_;
470 }
471 const std::string& TableViewColumnInfo::getMinValue(void) const { return minValue_; }
472 const std::string& TableViewColumnInfo::getMaxValue(void) const { return maxValue_; }
473 
474 //==============================================================================
478  const std::string& type, const std::string& dataType)
479 {
480  if(dataType == TableViewColumnInfo::DATATYPE_STRING)
481  {
482  if(type == TableViewColumnInfo::TYPE_ON_OFF ||
483  type == TableViewColumnInfo::TYPE_TRUE_FALSE ||
484  type == TableViewColumnInfo::TYPE_YES_NO)
485  return (
486  TableViewColumnInfo::DATATYPE_BOOL_DEFAULT); // default to OFF, NO, FALSE
487  else if(TableViewColumnInfo::isChildLink(type)) // call static version
488  return (TableViewColumnInfo::DATATYPE_LINK_DEFAULT);
489  else if(type == TableViewColumnInfo::TYPE_COMMENT)
490  return (TableViewColumnInfo::DATATYPE_COMMENT_DEFAULT);
491  else
492  return (TableViewColumnInfo::DATATYPE_STRING_DEFAULT);
493  }
494  else if(dataType == TableViewColumnInfo::DATATYPE_NUMBER)
495  return (TableViewColumnInfo::DATATYPE_NUMBER_DEFAULT);
496  else if(dataType == TableViewColumnInfo::DATATYPE_TIME)
497  return (TableViewColumnInfo::DATATYPE_TIME_DEFAULT);
498  else
499  {
500  __SS__ << "\tUnrecognized View data type: " << dataType << std::endl;
501  __COUT_ERR__ << "\n" << ss.str();
502  __SS_THROW__;
503  }
504 } // end getDefaultDefaultValue()
505 
506 //==============================================================================
508 const std::string& TableViewColumnInfo::getMinDefaultValue(const std::string& dataType)
509 {
510  if(dataType == TableViewColumnInfo::DATATYPE_STRING)
511  return (TableViewColumnInfo::
512  DATATYPE_NUMBER_MIN_DEFAULT); // default to OFF, NO, FALSE
513 
514  else if(dataType == TableViewColumnInfo::DATATYPE_NUMBER)
515  {
516  return (TableViewColumnInfo::DATATYPE_NUMBER_MIN_DEFAULT);
517  }
518 
519  else if(dataType == TableViewColumnInfo::DATATYPE_TIME)
520  return (TableViewColumnInfo::DATATYPE_NUMBER_MIN_DEFAULT);
521  else
522  {
523  __SS__ << "\tUnrecognized View data type: " << dataType << std::endl;
524  __COUT_ERR__ << "\n" << ss.str();
525  __SS_THROW__;
526  }
527 }
528 
529 //==============================================================================
531 const std::string& TableViewColumnInfo::getMaxDefaultValue(const std::string& dataType)
532 {
533  if(dataType == TableViewColumnInfo::DATATYPE_STRING)
534  return (TableViewColumnInfo::DATATYPE_NUMBER_MAX_DEFAULT);
535 
536  else if(dataType == TableViewColumnInfo::DATATYPE_NUMBER)
537  {
538  return (TableViewColumnInfo::DATATYPE_NUMBER_MAX_DEFAULT);
539  }
540  else if(dataType == TableViewColumnInfo::DATATYPE_TIME)
541  return (TableViewColumnInfo::DATATYPE_NUMBER_MAX_DEFAULT);
542  else
543  {
544  __SS__ << "\tUnrecognized View data type: " << dataType << std::endl;
545  __COUT_ERR__ << "\n" << ss.str();
546  __SS_THROW__;
547  }
548 }
549 
550 //==============================================================================
551 std::vector<std::string> TableViewColumnInfo::getAllTypesForGUI(void)
552 {
553  std::vector<std::string> all;
554  all.push_back(TYPE_DATA);
555  all.push_back(TYPE_UNIQUE_DATA);
556  all.push_back(TYPE_UNIQUE_GROUP_DATA);
557  all.push_back(TYPE_FIXED_CHOICE_DATA);
558  all.push_back(TYPE_MULTILINE_DATA);
559  all.push_back(TYPE_BITMAP_DATA);
560  all.push_back(TYPE_ON_OFF);
561  all.push_back(TYPE_TRUE_FALSE);
562  all.push_back(TYPE_YES_NO);
563  all.push_back(TYPE_START_CHILD_LINK_UID);
564  all.push_back(TYPE_START_CHILD_LINK_GROUP_ID);
565  all.push_back(TYPE_START_CHILD_LINK);
566  all.push_back(TYPE_START_GROUP_ID);
567  return all;
568 } // end getAllTypesForGUI()
569 
570 //==============================================================================
571 std::vector<std::string> TableViewColumnInfo::getAllDataTypesForGUI(void)
572 {
573  std::vector<std::string> all;
574  all.push_back(DATATYPE_STRING);
575  all.push_back(DATATYPE_NUMBER);
576  all.push_back(DATATYPE_TIME);
577  return all;
578 }
579 
580 //==============================================================================
582 std::map<std::pair<std::string, std::string>, std::string>
584 {
585  std::map<std::pair<std::string, std::string>, std::string> all;
586  all[std::pair<std::string, std::string>(DATATYPE_NUMBER, "*")] =
587  DATATYPE_NUMBER_DEFAULT;
588  all[std::pair<std::string, std::string>(DATATYPE_TIME, "*")] = DATATYPE_TIME_DEFAULT;
589 
590  all[std::pair<std::string, std::string>(DATATYPE_STRING, TYPE_ON_OFF)] =
591  DATATYPE_BOOL_DEFAULT;
592  all[std::pair<std::string, std::string>(DATATYPE_STRING, TYPE_TRUE_FALSE)] =
593  DATATYPE_BOOL_DEFAULT;
594  all[std::pair<std::string, std::string>(DATATYPE_STRING, TYPE_YES_NO)] =
595  DATATYPE_BOOL_DEFAULT;
596 
597  all[std::pair<std::string, std::string>(DATATYPE_STRING, TYPE_START_CHILD_LINK)] =
598  DATATYPE_LINK_DEFAULT;
599  all[std::pair<std::string, std::string>(DATATYPE_STRING, "*")] =
600  DATATYPE_STRING_DEFAULT;
601  return all;
602 }
604 //==============================================================================
607 {
608  return (type_ == TYPE_ON_OFF || type_ == TYPE_TRUE_FALSE || type_ == TYPE_YES_NO);
609 } // end isBoolType()
610 
611 //==============================================================================
614 {
615  return (dataType_ == DATATYPE_NUMBER);
616 } // end isBoolType()
617 
618 //==============================================================================
619 const std::string& TableViewColumnInfo::getName(void) const { return name_; }
620 
621 //==============================================================================
622 const std::string& TableViewColumnInfo::getStorageName(void) const
623 {
624  return storageName_;
625 }
626 
627 //==============================================================================
628 const std::string& TableViewColumnInfo::getDataType(void) const { return dataType_; }
629 
630 //==============================================================================
631 const std::vector<std::string>& TableViewColumnInfo::getDataChoices(void) const
632 {
633  return dataChoices_;
634 }
635 
636 //==============================================================================
640 {
641  if(bitMapInfoP_)
642  return *bitMapInfoP_;
643 
644  // throw error at this point!
645  {
646  __SS__ << "getBitMapInfo request for non-BitMap column of type: " << getType()
647  << std::endl;
648  __COUT_ERR__ << "\n" << ss.str();
649  __SS_THROW__;
650  }
651 }
652 
653 //==============================================================================
657 bool TableViewColumnInfo::isChildLink(const std::string& type)
658 {
659  return (type.find(TYPE_START_CHILD_LINK) == 0 &&
660  type.length() > TYPE_START_CHILD_LINK.length() &&
661  type[TYPE_START_CHILD_LINK.length()] == '-');
662 }
663 
664 //==============================================================================
669 {
670  return (type_.find(TYPE_START_CHILD_LINK) == 0 &&
671  type_.length() > TYPE_START_CHILD_LINK.length() &&
672  type_[TYPE_START_CHILD_LINK.length()] == '-');
673 }
674 
675 //==============================================================================
680 {
681  return (type_.find(TYPE_START_CHILD_LINK_UID) == 0 &&
682  type_.length() > TYPE_START_CHILD_LINK_UID.length() &&
683  type_[TYPE_START_CHILD_LINK_UID.length()] == '-');
684 }
685 
686 //==============================================================================
691 {
692  return (type_.find(TYPE_START_CHILD_LINK_GROUP_ID) == 0 &&
693  type_.length() > TYPE_START_CHILD_LINK_GROUP_ID.length() &&
694  type_[TYPE_START_CHILD_LINK_GROUP_ID.length()] == '-');
695 }
696 
697 //==============================================================================
702 {
703  return (type_.find(TYPE_START_GROUP_ID) == 0 &&
704  type_.length() > TYPE_START_GROUP_ID.length() &&
705  type_[TYPE_START_GROUP_ID.length()] == '-');
706 }
707 
708 //==============================================================================
710 bool TableViewColumnInfo::isUID(void) const { return (type_ == TYPE_UID); }
711 
712 //==============================================================================
715 {
716  // note: +1 to skip '-'
717  if(isChildLink())
718  return type_.substr(TYPE_START_CHILD_LINK.length() + 1);
719  else if(isChildLinkUID())
720  return type_.substr(TYPE_START_CHILD_LINK_UID.length() + 1);
721  else if(isChildLinkGroupID())
722  return type_.substr(TYPE_START_CHILD_LINK_GROUP_ID.length() + 1);
723  else if(isGroupID())
724  return type_.substr(TYPE_START_GROUP_ID.length() + 1);
725  else
726  {
727  __SS__
728  << ("Requesting a Link Index from a column that is not a child link member!")
729  << std::endl;
730  __COUT_ERR__ << ss.str();
731  __SS_THROW__;
732  }
733 }
static const std::string DATATYPE_NUMBER
static std::map< std::pair< std::string, std::string >, std::string > getAllDefaultsForGUI(void)
map of datatype,type to default value
std::string getChildLinkIndex(void) const
getChildLinkIndex
TableViewColumnInfo & operator=(const TableViewColumnInfo &c)
assignment operator because of bitmap pointer
bool isUID(void) const
isUID
static const std::string & getDefaultDefaultValue(const std::string &type, const std::string &dataType)
static const std::string TYPE_UID
NOTE: Do NOT put '-' in static const TYPEs because it will mess up javascript handling in the web gui...
static const std::string & getMaxDefaultValue(const std::string &dataType)
function to get max default value
const BitMapInfo & getBitMapInfo(void) const
uses dataChoices CSV fields if type is TYPE_BITMAP_DATA
static const std::string & getMinDefaultValue(const std::string &dataType)
function to get min default value
bool isBoolType(void) const
TODO check if min and max values need a function called getallminmaxforgui or something like that for...
bool isNumberDataType(void) const
isNumberDataType
bool isChildLinkGroupID(void) const
const std::string & getDefaultValue(void) const
returns the configued default value value for this particular column
static std::string decodeURIComponent(const std::string &data)
static std::string stackTrace(void)
< uses dataChoices CSV fields if type is TYPE_BITMAP_DATA