Go to the documentation of this file.00001 #ifndef LMFDAT_H
00002 #define LMFDAT_H
00003
00004
00005
00006
00007
00008
00009 #include "OnlineDB/EcalCondDB/interface/LMFUnique.h"
00010 #include "OnlineDB/EcalCondDB/interface/LMFRunIOV.h"
00011 #include "OnlineDB/EcalCondDB/interface/EcalLogicID.h"
00012 #include "OnlineDB/EcalCondDB/interface/EcalDBConnection.h"
00013
00014 #include <map>
00015
00019 class LMFDat : public LMFUnique {
00020 public:
00021 friend class EcalCondDBInterface;
00022
00023 LMFDat();
00024 LMFDat(EcalDBConnection *c);
00025 LMFDat(oracle::occi::Environment* env,
00026 oracle::occi::Connection* conn);
00027 ~LMFDat() { }
00028
00029 virtual std::string foreignKeyName() const;
00030
00031 LMFDat& setLMFRunIOV(const LMFRunIOV &iov) {
00032 setInt(foreignKeyName(), iov.getID());
00033 attach(foreignKeyName(), (LMFUnique*)&iov);
00034 return *this;
00035 }
00036 LMFRunIOV getLMFRunIOV() const {
00037 LMFRunIOV runiov(m_env, m_conn);
00038 runiov.setByID(getInt(foreignKeyName()));
00039 return runiov;
00040 }
00041
00042 Tm getSubrunStart() const {
00043 return getLMFRunIOV().getSubRunStart();
00044 }
00045
00046 void getPrevious(LMFDat *dat) throw(std::runtime_error);
00047 void getNext(LMFDat *dat) throw(std::runtime_error);
00048
00049 virtual std::string getTableName() const {
00050 return m_tableName;
00051 }
00052 virtual std::string getIovIdFieldName() const ;
00053 int getLMFRunIOVID();
00054
00055 LMFDat& setData(int logic_id, const std::vector<float> &data) {
00056 m_data[logic_id] = data;
00057 return *this;
00058 }
00059 LMFDat& setData(const EcalLogicID &logic_id,
00060 const std::vector<float> &data) {
00061 m_data[logic_id.getLogicID()] = data;
00062 return *this;
00063 }
00064 LMFDat& setData(const EcalLogicID &logic_id, const std::string &key,
00065 float v) {
00066 int id = logic_id.getLogicID();
00067 m_data[id].resize(m_keys.size());
00068 m_data[id][m_keys[key]] = v;
00069 return *this;
00070 }
00071 int size() const { return m_data.size(); }
00072
00073 std::map<unsigned int, std::string> getReverseMap() const;
00074
00075
00076 std::vector<float> getData(int id);
00077 std::vector<float> operator[](int id);
00078 std::vector<float> getData(const EcalLogicID &id);
00079
00080
00081 bool getData(int id, std::vector<float> &ret);
00082 bool getData(const EcalLogicID &id, std::vector<float> &ret);
00083
00084
00085 std::map<int, std::vector<float> > getData();
00086
00087
00088 float getData(int id, unsigned int k);
00089 float getData(const EcalLogicID &id, unsigned int k);
00090 float getData(const EcalLogicID &id, const std::string &key);
00091 float getData(int id, const std::string &key);
00092
00093
00094 bool getData(int id, unsigned int k, float &ret);
00095 bool getData(const EcalLogicID &id, unsigned int k, float &ret);
00096 bool getData(int id, const std::string &key, float &ret);
00097 bool getData(const EcalLogicID &id, const std::string &key, float &ret);
00098
00099 std::list<int> getLogicIds() {
00100 std::list<int> l;
00101 std::map<int, std::vector<float> >::const_iterator i = m_data.begin();
00102 std::map<int, std::vector<float> >::const_iterator e = m_data.end();
00103 while (i != e) {
00104 l.push_back(i->first);
00105 i++;
00106 }
00107 return l;
00108 }
00109
00110 std::map<std::string, unsigned int> getKeys() {
00111 return m_keys;
00112 }
00113 std::list<std::string> getKeyList() {
00114 std::list<std::string> l;
00115 std::map<std::string, unsigned int>::const_iterator i = m_keys.begin();
00116 std::map<std::string, unsigned int>::const_iterator e = m_keys.end();
00117 while (i != e) {
00118 l.push_back(i->first);
00119 i++;
00120 }
00121 return l;
00122 }
00123 LMFDat& setMaxDataToDump(int n);
00124 void dump() const ;
00125 void dump(int n) const ;
00126 virtual void dump(int n, int max) const ;
00127 std::map<int, std::vector<float> > fetchData() throw(std::runtime_error);
00128 void fetch() throw(std::runtime_error);
00129 void fetch(int logic_id) throw(std::runtime_error);
00130 void fetch(int logic_id, const Tm &tm) throw(std::runtime_error);
00131 void fetch(int logic_id, const Tm *timestamp, int dir) throw(std::runtime_error);
00132 void fetch(const EcalLogicID &id, const Tm &tm) throw(std::runtime_error);
00133 void fetch(const EcalLogicID &id, const Tm &tm, int dir) throw(std::runtime_error);
00134 void fetch(const EcalLogicID &id)
00135 throw(std::runtime_error);
00136
00137 virtual bool isValid();
00138 protected:
00139 void getNeighbour(LMFDat *dat, int which) throw(std::runtime_error);
00140 int writeDB() throw(std::runtime_error);
00141 bool check();
00142 std::string buildInsertSql();
00143 std::string buildSelectSql(int logic_id = 0, int direction = 0);
00144 void getKeyTypes() throw(std::runtime_error);
00145
00146 int m_max;
00147 std::vector<std::string> m_type;
00148
00149
00150 std::map<int, std::vector<float> > m_data;
00151
00152 std::map<std::string, unsigned int> m_keys;
00153 std::string m_tableName;
00154 std::string m_Error;
00155 };
00156
00157 #endif