/scratch0/jsnuveri/BDSIM/BDSIMgit/bdsim/include/BDSMySQLTable.hh

00001 /* * BDSIM code.    Version 1.0
00002    * Author: Grahame A. Blair, Royal Holloway, Univ. of London.
00003    * Last modified 24.7.2002
00004    * Copyright (c) 2002 by G.A.Blair.  ALL RIGHTS RESERVED. 
00005 
00006 
00007    Author of this code: John C. Carter, Royal Holloway, Univ. of London.
00008    Last modified 12.10.2005
00009 */
00010 
00011 
00012 #ifndef BDSMySQLTable_h
00013 #define BDSMySQLTable_h 1
00014 
00015 #include "globals.hh"
00016 #include <vector>
00017 
00018 class BDSMySQLVariable
00019 {
00020 
00021 public:
00022   
00023   BDSMySQLVariable(G4String aVarName, G4String aVarType);
00024 
00025   void AddValue(G4double aVarValue);
00026   void AddValue(G4String aVarValue);
00027   void AddValue(G4int aVarValue);
00028 
00029   G4String GetStrValue(G4int itemN);
00030   G4double GetDblValue(G4int itemN);
00031   G4int GetIntValue(G4int itemN);
00032 
00033   void SetStrValue(G4int itemN, G4String newValue);
00034   void SetDblValue(G4int itemN, G4double newValue);
00035   void SetIntValue(G4int itemN, G4int newValue);
00036 
00037   G4int GetNVariables();
00038 
00039   G4String GetVarType();
00040   G4String GetName();
00041 
00042   void Print();
00043 
00044   ~BDSMySQLVariable(){};
00045   
00046 protected:
00047 
00048 private:
00049 
00050   G4int itsNVariables;
00051   G4String itsVarName;
00052   G4String itsVarType;
00053   std::vector<G4double> itsDblVar;
00054   std::vector<G4String> itsStrVar;
00055   std::vector<G4int> itsIntVar;
00056 
00057 };
00058 
00059 inline BDSMySQLVariable::BDSMySQLVariable(G4String aVarName, G4String aVarType)
00060 {
00061   itsVarName=aVarName;
00062   itsVarType=aVarType;
00063   itsNVariables=0;
00064 }
00065 
00066 inline G4int BDSMySQLVariable::GetNVariables()
00067 {return itsNVariables;}
00068 
00069 inline G4String BDSMySQLVariable::GetName()
00070 {return itsVarName;}
00071 
00072 inline G4String BDSMySQLVariable::GetVarType()
00073 {return itsVarType;}
00074 
00075 inline void BDSMySQLVariable::AddValue(G4double aVarValue)
00076 {
00077   itsNVariables++;
00078   // Check is to avoid unecessary confusion
00079   if(itsVarType=="DOUBLE")
00080     itsDblVar.push_back(aVarValue);
00081 }
00082 
00083 inline void BDSMySQLVariable::AddValue(G4int aVarValue)
00084 {
00085   itsNVariables++;
00086   // Check is to avoid unecessary confusion
00087   if(itsVarType=="INTEGER")
00088     itsIntVar.push_back(aVarValue);
00089 }
00090 
00091 inline void BDSMySQLVariable::AddValue(G4String aVarValue)
00092 {
00093   itsNVariables++;
00094   itsStrVar.push_back(aVarValue);
00095 }
00096 
00097 inline  G4String BDSMySQLVariable::GetStrValue(G4int itemN)
00098 {return itsStrVar[itemN];}
00099 
00100 inline  G4double BDSMySQLVariable::GetDblValue(G4int itemN)
00101 {
00102   return itsDblVar[itemN];
00103 }
00104 
00105 inline  G4int BDSMySQLVariable::GetIntValue(G4int itemN)
00106 {return itsIntVar[itemN];}
00107 
00108 inline  void BDSMySQLVariable::SetStrValue(G4int itemN, G4String newValue)
00109 {itsStrVar[itemN] = newValue;}
00110 
00111 inline  void BDSMySQLVariable::SetDblValue(G4int itemN, G4double newValue)
00112 {itsDblVar[itemN] = newValue;}
00113 
00114 inline  void BDSMySQLVariable::SetIntValue(G4int itemN, G4int newValue)
00115 {itsIntVar[itemN] = newValue;}
00116 
00117 class BDSMySQLTable 
00118 {
00119 public:
00120   BDSMySQLTable (G4String aTableName);
00121   ~BDSMySQLTable();
00122   
00123 
00124   void AddVariable(G4String aVarName, G4String aType);
00125 
00126   G4String GetName();
00127   G4int GetNVariables();
00128 
00129   BDSMySQLVariable* GetVariable(G4String aVarName);
00130   BDSMySQLVariable* GetVariable(G4int aVarN);
00131 
00132   void Print();
00133 
00134 protected:
00135   
00136 private:
00137   G4int itsNVariables;
00138   G4String itsTableName;
00139   std::vector<BDSMySQLVariable*> itsVar;
00140 
00141   //A list of valid variable types (STRING, DOUBLE, INTEGER...)
00142   void SetValidVarTypes();
00143   std::vector<G4String> _validVarTypes;
00144   //To check is a var type is valid...
00145   G4bool isValidVarType(G4String);
00146 };
00147 
00148 inline G4String BDSMySQLTable::GetName()
00149 {return itsTableName;}
00150 
00151 inline G4int BDSMySQLTable::GetNVariables()
00152 {return itsNVariables;}
00153 
00154 #endif

Generated on 28 Jun 2015 for BDSIM by  doxygen 1.4.7