CMS 3D CMS Logo

LMFColor.h
Go to the documentation of this file.
1 #ifndef LMFCOLOR_H
2 #define LMFCOLOR_H
3 
4 /*
5  Last updated by Giovanni.Organtini@roma1.infn.it 2010
6  */
7 
8 #include <list>
9 
11 
12 class LMFColor : public LMFUnique {
13  public:
14  friend class EcalCondDBInterface;
15 
16  LMFColor();
17  LMFColor(oracle::occi::Environment* env,
18  oracle::occi::Connection* conn);
21  ~LMFColor() override;
22 
23  LMFColor& setName(const std::string &s = "blue") {
24  setString("sname", s);
25  fetchID();
26  if (m_ID <= 0) {
27  setInt("color", -1);
28  }
29  return *this;
30  }
32  setInt("color", index);
33  fetchID();
34  if (m_ID <= 0) {
35  setString("sname", "invalid");
36  }
37  return *this;
38  }
39  LMFColor& setColor(const std::string &s = "blue") {
40  setName(s);
41  return *this;
42  }
43 
44  std::string getShortName() const { return getString("sname"); }
45  std::string getLongName() const { return getString("lname"); }
46  int getColorIndex() const { return getInt("color"); }
47  int getColor() const { return getColorIndex(); }
48 
49  bool isValid() override;
50 
51  // Operators
52  inline bool operator==(const LMFColor &m) const
53  {
54  return ( getShortName() == m.getShortName() &&
55  getLongName() == m.getLongName());
56  }
57 
58  inline bool operator!=(const LMFColor &m) const { return !(*this == m); }
59 
60  private:
62  std::string fetchAllSql(Statement *stmt) const override;
63  std::string setByIDSql(Statement *stmt, int id) override;
64  void getParameters(ResultSet *rset) override;
65  LMFUnique *createObject() const override;
66 };
67 
68 #endif
LMFUnique & setInt(std::string key, int value)
Definition: LMFUnique.cc:33
LMFColor & setName(const std::string &s="blue")
Definition: LMFColor.h:23
oracle::occi::ResultSet ResultSet
Definition: LMFUnique.h:19
bool operator==(const LMFColor &m) const
Definition: LMFColor.h:52
std::string fetchIdSql(Statement *stmt) override
Definition: LMFColor.cc:64
int getInt(std::string fieldname) const
Definition: LMFUnique.cc:203
std::string getLongName() const
Definition: LMFColor.h:45
bool isValid() override
Definition: LMFColor.cc:101
oracle::occi::Connection * conn
std::string setByIDSql(Statement *stmt, int id) override
Definition: LMFColor.cc:87
oracle::occi::Statement Statement
Definition: LMFUnique.h:20
void getParameters(ResultSet *rset) override
Definition: LMFColor.cc:95
std::string getShortName() const
Definition: LMFColor.h:44
~LMFColor() override
Definition: LMFColor.cc:47
LMFUnique & setString(std::string key, std::string value)
Definition: LMFUnique.cc:15
int getColor() const
Definition: LMFColor.h:47
LMFColor & setColor(const std::string &s="blue")
Definition: LMFColor.h:39
LMFUnique * createObject() const override
Definition: LMFColor.cc:58
LMFColor()
Definition: LMFColor.cc:9
int getColorIndex() const
Definition: LMFColor.h:46
col
Definition: cuy.py:1010
oracle::occi::Statement * stmt
std::string getString(std::string fieldname) const
Definition: LMFUnique.cc:194
bool operator!=(const LMFColor &m) const
Definition: LMFColor.h:58
LMFColor & setColor(int index)
Definition: LMFColor.h:31
int fetchID() noexcept(false) override
Definition: LMFUnique.cc:213
std::string fetchAllSql(Statement *stmt) const override
Definition: LMFColor.cc:51