CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Friends

LMFColor Class Reference

#include <LMFColor.h>

Inheritance diagram for LMFColor:
LMFUnique IUniqueDBObject IDBObject

List of all members.

Public Member Functions

int getColor () const
int getColorIndex () const
std::string getLongName () const
std::string getShortName () const
bool isValid ()
 LMFColor (oracle::occi::Environment *env, oracle::occi::Connection *conn)
 LMFColor (EcalDBConnection *c, std::string col)
 LMFColor ()
 LMFColor (EcalDBConnection *c)
bool operator!= (const LMFColor &m) const
bool operator== (const LMFColor &m) const
LMFColorsetColor (int index)
LMFColorsetColor (const std::string &s="blue")
LMFColorsetName (const std::string &s="blue")
 ~LMFColor ()

Private Member Functions

LMFUniquecreateObject () const
std::string fetchAllSql (Statement *stmt) const
std::string fetchIdSql (Statement *stmt)
void getParameters (ResultSet *rset)
std::string setByIDSql (Statement *stmt, int id)

Friends

class EcalCondDBInterface

Detailed Description

Definition at line 12 of file LMFColor.h.


Constructor & Destructor Documentation

LMFColor::LMFColor ( )

Definition at line 9 of file LMFColor.cc.

Referenced by createObject().

{
  m_ID = 0;
  m_className = "LMFColor";
  m_stringFields["sname"] = "none";
  m_stringFields["lname"] = "none";
  m_intFields["color"] = -1;
}
LMFColor::LMFColor ( oracle::occi::Environment *  env,
oracle::occi::Connection *  conn 
)

Definition at line 18 of file LMFColor.cc.

References LMFUnique::m_className, IUniqueDBObject::m_ID, LMFUnique::m_intFields, and LMFUnique::m_stringFields.

                                               : LMFUnique(env, conn)
{
  m_ID = 0;
  m_className = "LMFColor";
  m_stringFields["sname"] = "none";
  m_stringFields["lname"] = "none";
  m_intFields["color"] = -1;
}
LMFColor::LMFColor ( EcalDBConnection c)

Definition at line 28 of file LMFColor.cc.

References LMFUnique::m_className, IUniqueDBObject::m_ID, LMFUnique::m_intFields, and LMFUnique::m_stringFields.

                                      : LMFUnique(c)
{
  m_ID = 0;
  m_className = "LMFColor";
  m_stringFields["sname"] = "none";
  m_stringFields["lname"] = "none";
  m_intFields["color"] = -1;
}
LMFColor::LMFColor ( EcalDBConnection c,
std::string  col 
)

Definition at line 37 of file LMFColor.cc.

References LMFUnique::m_className, IUniqueDBObject::m_ID, LMFUnique::m_intFields, LMFUnique::m_stringFields, and setName().

                                                       : LMFUnique(c)
{
  m_ID = 0;
  m_className = "LMFColor";
  m_stringFields["sname"] = "none";
  m_stringFields["lname"] = "none";
  m_intFields["color"] = -1;
  setName(color);
}
LMFColor::~LMFColor ( )

Definition at line 47 of file LMFColor.cc.

{
}

Member Function Documentation

LMFUnique * LMFColor::createObject ( ) const [private, virtual]

Reimplemented from LMFUnique.

Definition at line 57 of file LMFColor.cc.

References LMFColor(), IDBObject::m_conn, IDBObject::m_env, n, and IDBObject::setConnection().

                                         {
  LMFColor * n = new LMFColor;
  n->setConnection(m_env, m_conn);
  return n;
}
std::string LMFColor::fetchAllSql ( Statement stmt) const [private, virtual]

Reimplemented from LMFUnique.

Definition at line 51 of file LMFColor.cc.

                                                     {
  std::string sql = "SELECT COLOR_ID FROM LMF_COLOR_DEF";
  stmt->setSQL(sql);
  return sql;
}
std::string LMFColor::fetchIdSql ( Statement stmt) [private, virtual]

Reimplemented from LMFUnique.

Definition at line 63 of file LMFColor.cc.

References getColorIndex(), LMFUnique::getInt(), getShortName(), and LMFUnique::getString().

                                              {
  // the query depends on the object status
  std::string sql;
  if ((getInt("color") >= 0) && (getString("sname") != "none")) {
    sql = "SELECT COLOR_ID FROM LMF_COLOR_DEF "
          "WHERE SNAME   = :1 AND COLOR_INDEX = :2";
    stmt->setSQL(sql);
    stmt->setString(1, getShortName());
    stmt->setInt(2, getColorIndex());
  } else if (getInt("color") >= 0) {
    sql = "SELECT COLOR_ID FROM LMF_COLOR_DEF "
          "WHERE COLOR_INDEX = :1";
    stmt->setSQL(sql);
    stmt->setInt(1, getColorIndex());
  } else if (getString("sname") != "") {
    sql = "SELECT COLOR_ID FROM LMF_COLOR_DEF "
          "WHERE SNAME   = :1";
    stmt->setSQL(sql);
    stmt->setString(1, getShortName());
  } 
  return sql;
}
int LMFColor::getColor ( ) const [inline]

Definition at line 47 of file LMFColor.h.

References getColorIndex().

{ return getColorIndex(); }
int LMFColor::getColorIndex ( ) const [inline]

Definition at line 46 of file LMFColor.h.

References LMFUnique::getInt().

Referenced by fetchIdSql(), and getColor().

{ return getInt("color"); }
std::string LMFColor::getLongName ( ) const [inline]

Definition at line 45 of file LMFColor.h.

References LMFUnique::getString().

Referenced by LMFRunIOV::getColorLongName(), and operator==().

{ return getString("lname"); }
void LMFColor::getParameters ( ResultSet rset) [private, virtual]

Reimplemented from LMFUnique.

Definition at line 94 of file LMFColor.cc.

References LMFUnique::setInt(), and LMFUnique::setString().

                                            {
  setInt("color", rset->getInt(1));
  setString("sname", rset->getString(2));
  setString("lname", rset->getString(3));
}
std::string LMFColor::getShortName ( ) const [inline]

Definition at line 44 of file LMFColor.h.

References LMFUnique::getString().

Referenced by fetchIdSql(), LMFRunIOV::getColorShortName(), isValid(), and operator==().

{ return getString("sname"); }
bool LMFColor::isValid ( void  )

Definition at line 100 of file LMFColor.cc.

References trackerHits::c, LMFUnique::fetchAll(), getShortName(), i, and runTheMatrix::ret.

                       {
  boost::ptr_list<LMFUnique> listOfValidColors = fetchAll();
  boost::ptr_list<LMFUnique>::const_iterator i = listOfValidColors.begin();
  boost::ptr_list<LMFUnique>::const_iterator e = listOfValidColors.end();
  bool ret = false;
  while (i != e) {
    LMFColor *c = (LMFColor*)&(*i);
    if (c->getShortName() == getShortName()) {
      ret = true;
      i = e;
    }
    i++;
  }
  return ret;
}
bool LMFColor::operator!= ( const LMFColor m) const [inline]

Definition at line 58 of file LMFColor.h.

References m.

{ return !(*this == m); }
bool LMFColor::operator== ( const LMFColor m) const [inline]

Definition at line 52 of file LMFColor.h.

References getLongName(), and getShortName().

    {
      return ( getShortName()   == m.getShortName() &&
               getLongName()    == m.getLongName());
    }
std::string LMFColor::setByIDSql ( Statement stmt,
int  id 
) [private, virtual]

Reimplemented from LMFUnique.

Definition at line 86 of file LMFColor.cc.

                                                      { 
  std::string sql = "SELECT COLOR_INDEX, SNAME, LNAME "
    "FROM LMF_COLOR_DEF WHERE COLOR_ID = :1";
  stmt->setSQL(sql);
  stmt->setInt(1, id);
  return sql;
}     
LMFColor& LMFColor::setColor ( const std::string &  s = "blue") [inline]

Definition at line 39 of file LMFColor.h.

References asciidump::s, and setName().

                                                  {
    setName(s);
    return *this;
  }
LMFColor& LMFColor::setColor ( int  index) [inline]

Definition at line 31 of file LMFColor.h.

References LMFUnique::fetchID(), IUniqueDBObject::m_ID, LMFUnique::setInt(), and LMFUnique::setString().

                                {
    setInt("color", index);
    fetchID();
    if (m_ID <= 0) {
      setString("sname", "invalid");
    }
    return *this;
  }
LMFColor& LMFColor::setName ( const std::string &  s = "blue") [inline]

Definition at line 23 of file LMFColor.h.

References LMFUnique::fetchID(), IUniqueDBObject::m_ID, asciidump::s, LMFUnique::setInt(), and LMFUnique::setString().

Referenced by LMFColor(), and setColor().

                                                 {
    setString("sname", s);
    fetchID();
    if (m_ID <= 0) {
      setInt("color", -1);
    }
    return *this;
  }

Friends And Related Function Documentation

friend class EcalCondDBInterface [friend]

Reimplemented from LMFUnique.

Definition at line 14 of file LMFColor.h.