Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:31:49

0001 #ifndef LMFCOLOR_H
0002 #define LMFCOLOR_H
0003 
0004 /*
0005  Last updated by  Giovanni.Organtini@roma1.infn.it 2010
0006  */
0007 
0008 #include <list>
0009 
0010 #include "OnlineDB/EcalCondDB/interface/LMFUnique.h"
0011 
0012 class LMFColor : public LMFUnique {
0013 public:
0014   friend class EcalCondDBInterface;
0015 
0016   LMFColor();
0017   LMFColor(oracle::occi::Environment *env, oracle::occi::Connection *conn);
0018   LMFColor(EcalDBConnection *c);
0019   LMFColor(EcalDBConnection *c, std::string col);
0020   ~LMFColor() override;
0021 
0022   LMFColor &setName(const std::string &s = "blue") {
0023     setString("sname", s);
0024     fetchID();
0025     if (m_ID <= 0) {
0026       setInt("color", -1);
0027     }
0028     return *this;
0029   }
0030   LMFColor &setColor(int index) {
0031     setInt("color", index);
0032     fetchID();
0033     if (m_ID <= 0) {
0034       setString("sname", "invalid");
0035     }
0036     return *this;
0037   }
0038   LMFColor &setColor(const std::string &s = "blue") {
0039     setName(s);
0040     return *this;
0041   }
0042 
0043   std::string getShortName() const { return getString("sname"); }
0044   std::string getLongName() const { return getString("lname"); }
0045   int getColorIndex() const { return getInt("color"); }
0046   int getColor() const { return getColorIndex(); }
0047 
0048   bool isValid() override;
0049 
0050   // Operators
0051   inline bool operator==(const LMFColor &m) const {
0052     return (getShortName() == m.getShortName() && getLongName() == m.getLongName());
0053   }
0054 
0055   inline bool operator!=(const LMFColor &m) const { return !(*this == m); }
0056 
0057 private:
0058   std::string fetchIdSql(Statement *stmt) override;
0059   std::string fetchAllSql(Statement *stmt) const override;
0060   std::string setByIDSql(Statement *stmt, int id) override;
0061   void getParameters(ResultSet *rset) override;
0062   LMFUnique *createObject() const override;
0063 };
0064 
0065 #endif