$treeview $search $mathjax
TraDemGen Logo  1.00.0
$projectbrief
$projectbrief
$searchbox

DBParams.hpp

Go to the documentation of this file.
00001 #ifndef __TRADEMGEN_DBPARAMS_HPP
00002 #define __TRADEMGEN_DBPARAMS_HPP
00003 
00004 // //////////////////////////////////////////////////////////////////////
00005 // Import section
00006 // //////////////////////////////////////////////////////////////////////
00007 // STL
00008 #include <iosfwd>
00009 #include <string>
00010 // Trademgen
00011 #include <trademgen/TRADEMGEN_Types.hpp>
00012 #include <trademgen/TRADEMGEN_Abstract.hpp>
00013 
00014 namespace TRADEMGEN {
00015 
00017   typedef std::list<std::string> DBParamsNameList_T;
00018 
00019   
00021   struct DBParams : public TRADEMGEN_Abstract {
00022   public:
00023     // ///////// Getters ////////
00025     std::string getUser() const {
00026       return _user;
00027     }
00028     
00030     std::string getPassword() const {
00031       return _passwd;
00032     }
00033     
00035     std::string getHost() const {
00036       return _host;
00037     }
00038     
00040     std::string getPort() const {
00041       return _port;
00042     }
00043     
00045     std::string getDBName() const {
00046       return _dbname;
00047     }
00048     
00049     
00050     // ///////// Setters //////////
00052     void setUser (const std::string& iUser) {
00053       _user = iUser;
00054     }
00055 
00057     void setPassword (const std::string& iPasswd) {
00058       _passwd = iPasswd;
00059     }
00060 
00062     void setHost (const std::string& iHost) {
00063       _host = iHost;
00064     }
00065 
00067     void setPort (const std::string& iPort) {
00068       _port = iPort;
00069     }
00070 
00072     void setDBName (const std::string& iDBName) {
00073       _dbname = iDBName;
00074     }
00075 
00076     
00077   public:
00078     // ///////// Busines methods ////////
00080     bool check () const {
00081       if (_user.empty() == true || _passwd.empty() == true
00082           || _host.empty() == true || _port.empty()
00083           || _dbname.empty() == true) {
00084         return false;
00085       }
00086       return true;
00087     }
00088     
00089   public:
00090     // ///////// Display methods ////////
00093     void toStream (std::ostream& ioOut) const {
00094       ioOut << toString();
00095     }
00096 
00099     void fromStream (std::istream&) {
00100     }
00101 
00103     std::string toShortString() const {
00104       std::ostringstream oStr;
00105       oStr << _dbname << "." << _user << "@" << _host << ":" << _port;
00106       return oStr.str();
00107     }
00108     
00110     std::string toString() const {
00111       std::ostringstream oStr;
00112       oStr << _dbname << "." << _user << "@" << _host << ":" << _port;
00113       return oStr.str();
00114     }
00115 
00116     
00117   public:
00119     DBParams (const std::string& iDBUser, const std::string& iDBPasswd,
00120               const std::string& iDBHost, const std::string& iDBPort,
00121               const std::string& iDBName)
00122       : _user (iDBUser), _passwd (iDBPasswd), _host (iDBHost), _port (iDBPort),
00123         _dbname (iDBName) {
00124     }
00125 
00127     // DBParams ();
00129     // DBParams (const DBParams&);
00130     
00132     virtual ~DBParams() {}
00133 
00134     
00135   private:
00136     // /////// Attributes /////////
00138     std::string _user;
00140     std::string _passwd;
00142     std::string _host;
00144     std::string _port;
00146     std::string _dbname;
00147   };
00148 
00149 }
00150 #endif // __TRADEMGEN_DBPARAMS_HPP