Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

BeamMonCuts.cxx

Go to the documentation of this file.
00001 #include "BeamMonCuts.h"
00002 
00003 #include <DatabaseInterface/DbiResultSet.h>
00004 #include <DatabaseInterface/DbiOutRowStream.h>
00005 #include "Registry/Registry.h"
00006 
00007 #include <sstream>
00008 
00009 #include <MessageService/MsgService.h>
00010 CVSID("$Id: BeamMonCuts.cxx,v 1.2 2006/11/22 20:28:23 mdier Exp $");
00011 
00012 
00013 #include <DatabaseInterface/DbiResultPtr.tpl>
00014 template class  DbiResultPtr<BeamMonCuts>;
00015 
00016 
00017 BeamMonCuts::BeamMonCuts(const string& cutValues)
00018     : fCutValues(cutValues)
00019 {}
00020 
00021 BeamMonCuts::BeamMonCuts(const Registry* reg)
00022 {
00023     if (reg) this->SetCutValues(reg);
00024 }
00025 
00026 
00027 BeamMonCuts::~BeamMonCuts()
00028 {}
00029 
00030 DbiTableRow* BeamMonCuts::CreateTableRow() const
00031 {
00032     return new BeamMonCuts;
00033 }
00034 
00035 void BeamMonCuts::Fill(DbiResultSet& rs, const DbiValidityRec* /*vrec*/)
00036 {
00037     rs >> fCutValues;
00038 }
00039 
00040 void BeamMonCuts::Store(DbiOutRowStream& ors, const DbiValidityRec* /*vrec*/) const
00041 {
00042     ors << fCutValues;
00043 }
00044 
00045 void BeamMonCuts::FillRegistry(Registry* reg) const
00046 {
00047     // Do nothing if pointer to registry is 0
00048     if (!reg) return;
00049 
00050     // Record the current state of reg and then clear it
00051     Bool_t keysLocked = reg->KeysLocked();
00052     Bool_t valuesLocked = reg->ValuesLocked();
00053     reg->UnLockKeys();
00054     reg->UnLockValues();
00055     reg->Clear();
00056 
00057     // use the owned BeamMonCuts to fill reg
00058     std::istringstream is(fCutValues);
00059     reg->ReadStream(is);
00060 
00061     if ( keysLocked   ) reg->LockKeys();
00062     if ( valuesLocked ) reg->LockValues();
00063 
00064 }
00065 
00066 void BeamMonCuts::SetCutValues(const Registry* reg)
00067 {
00068     if (!reg){
00069         MAXMSG("BeamMonCuts",Msg::kError,20) << "No valid registry to use!" << endl;
00070         return;
00071     }
00072 
00073     std::ostringstream os;
00074     reg->PrintStream(os);
00075     fCutValues = os.str();              
00076 }
00077 
00078 
00079 ClassImp(BeamMonCuts)

Generated on Mon Feb 15 11:06:24 2010 for loon by  doxygen 1.3.9.1