$treeview $search $mathjax $extrastylesheet
otsdaq
v2_03_00
$projectbrief
|
$projectbrief
|
$searchbox |
00001 /* 00002 * RegisterView.h 00003 * 00004 * Created on: Jul 29, 2015 00005 * Author: parilla 00006 */ 00007 00008 #ifndef _ots_RegisterView_h_ 00009 #define _ots_RegisterView_h_ 00010 #include "otsdaq-core/ConfigurationDataFormats/ViewRegisterInfo.h" 00011 #include "otsdaq-core/ConfigurationDataFormats/ViewRegisterSequencerInfo.h" 00012 #include "otsdaq-core/Macros/CoutMacros.h" 00013 #include "otsdaq-core/MessageFacility/MessageFacility.h" 00014 00015 #include <stdlib.h> 00016 #include <cassert> 00017 #include <iostream> 00018 #include <sstream> // std::stringstream, std::stringbuf 00019 #include <string> 00020 #include <typeinfo> 00021 #include <vector> 00022 namespace ots 00023 { 00024 class RegisterView 00025 { 00026 public: 00027 typedef std::vector<std::vector<std::string> > DataView; 00028 typedef DataView::iterator iterator; 00029 typedef DataView::const_iterator const_iterator; 00030 00031 RegisterView(std::string name = ""); 00032 virtual ~RegisterView(); 00033 00034 unsigned int findRow(unsigned int col, const std::string value) const; 00035 unsigned int findRow(unsigned int col, const unsigned int value) const; 00036 00037 // Getters 00038 std::string getName() const; 00039 int getVersion() const; 00040 std::string getComment() const; 00041 std::string getAuthor() const; 00042 time_t getCreationTime() const; 00043 unsigned int getNumberOfRows() const; 00044 unsigned int getNumberOfColumns() const; 00045 const std::vector<ViewRegisterInfo>& getRegistersInfo() const; 00046 std::vector<ViewRegisterInfo>* getRegistersInfoPointer(); 00047 const std::vector<ViewRegisterSequencerInfo>& getRegistersSequencerInfo() const; 00048 std::vector<ViewRegisterSequencerInfo>* getRegistersSequencerInfoPointer(); 00049 00050 /*template<class T> 00051 void getValue(T& value, unsigned int row, unsigned int col) const 00052 { 00053 assert(col < columnsInfo_.size() && row < getNumberOfRows()); 00054 if(columnsInfo_[col].getDataType() == TableViewColumnInfo::DATATYPE_NUMBER) 00055 if(typeid(double) == typeid(value)) 00056 value = strtod(theDataView_[row][col].c_str(),0); 00057 else if(typeid(float) == typeid(value)) 00058 value = strtof(theDataView_[row][col].c_str(),0); 00059 else 00060 value = strtol(theDataView_[row][col].c_str(),0,10); 00061 else 00062 { 00063 std::cout << __COUT_HDR_FL__ << "\tUnrecognized View data type: " << 00064 columnsInfo_[col].getDataType() << std::endl; assert(0); 00065 } 00066 } 00067 void getValue(std::string& value, unsigned int row, unsigned int col) const 00068 { 00069 assert(col < columnsInfo_.size() && row < getNumberOfRows()); 00070 if(columnsInfo_[col].getDataType() == TableViewColumnInfo::DATATYPE_STRING) 00071 value = theDataView_[row][col]; 00072 else if(columnsInfo_[col].getDataType() == TableViewColumnInfo::DATATYPE_TIME) 00073 value = theDataView_[row][col]; 00074 else 00075 { 00076 std::cout << __COUT_HDR_FL__ << "\tUnrecognized View data type: " << 00077 columnsInfo_[col].getDataType() << std::endl; assert(0); 00078 } 00079 }*/ 00080 00081 // Setters 00082 void setName(std::string name); 00083 void setVersion(int version); 00084 void setVersion(char* version); 00085 void setComment(std::string name); 00086 void setAuthor(std::string name); 00087 void setCreationTime(time_t t); 00088 00089 /* template<class T> 00090 void setValue(T value, unsigned int row, unsigned int col) 00091 { 00092 assert(col < columnsInfo_.size() && row < getNumberOfRows()); 00093 if(columnsInfo_[col].getDataType() == TableViewColumnInfo::DATATYPE_NUMBER) 00094 { 00095 std::stringstream ss; 00096 ss << value; 00097 theDataView_[row][col] = ss.str(); 00098 //TODO: Should this number be forced to a long int???.. currently getValue 00099 only gets long int. 00100 } 00101 else 00102 { 00103 std::cout << __COUT_HDR_FL__ << "\tUnrecognized View data type: " << 00104 columnsInfo_[col].getDataType() << std::endl; assert(0); 00105 } 00106 }*/ 00107 /*void setValue(std::string value, unsigned int row, unsigned int col) 00108 { 00109 assert(col < columnsInfo_.size() && row < getNumberOfRows()); 00110 if(columnsInfo_[col].getDataType() == TableViewColumnInfo::DATATYPE_STRING) 00111 theDataView_[row][col] = value; 00112 else if(columnsInfo_[col].getDataType() == TableViewColumnInfo::DATATYPE_TIME) 00113 theDataView_[row][col] = value; 00114 else 00115 { 00116 std::cout << __COUT_HDR_FL__ << "\tUnrecognized View data type: " << 00117 columnsInfo_[col].getDataType() << std::endl; assert(0); 00118 } 00119 }*/ 00120 00121 int addRow(); // returns index of added row, always is last row unless 00122 bool deleteRow(int r); // returns true on success 00123 00124 private: 00125 std::string name_; // View name (extensionTableName in xml) 00126 int version_; // Configuration version 00127 std::string comment_; // Configuration version comment 00128 std::string author_; 00129 time_t creationTime_; 00130 std::vector<ViewRegisterInfo> registersInfo_; 00131 std::vector<ViewRegisterSequencerInfo> registersSequencerInfo_; 00132 DataView theDataView_; 00133 }; 00134 00135 } // namespace ots 00136 00137 #endif /* REGISTERVIEW_H_ */