Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Data Structures | File List | Namespace Members | Data Fields | Related Pages

IsPutCommand.cpp

00001 #include "IsPutCommand.h"
00002 #include "Archiver.h"
00003 #include "SerializableWrappers.h"
00004 #include "Sct/IS/IOManagerIS.h"
00005 #include "Sct/LogicErrors.h"
00006 #include "Sct/IoExceptions.h"
00007 #include "Sct/ISProxy/IOManagerISProxy.h"
00008 // Summary stuff:
00009 #include "SummaryWriter/TestSummaryIS.h"
00010 #include "SummaryWriter/SummaryManager.h"
00011 #include "SctData/TestResult.h"
00012 
00013 #include "is/isinfoany.h"
00014 
00015 #include <boost/timer.hpp>
00016 #include <sstream>
00017 
00018 namespace SctArchiving{
00019   IsPutCommand::IsPutCommand(boost::shared_ptr<Sct::Serializable> ob)
00020     : PutCommand(ob)  {
00021   }
00022 
00023   IsPutCommand::IsPutCommand() {}
00024 
00025   IsPutCommand::~IsPutCommand() {}
00026 
00027   void IsPutCommand::setServer(const string& name){
00028     m_server=name;
00029   }
00030 
00031   boost::shared_ptr<ArchivingCommand> IsPutCommand::create()const{
00032     boost::shared_ptr<ArchivingCommand> cmd(new IsPutCommand() );
00033     return cmd;
00034   }
00035   
00036   void IsPutCommand::execute(){
00037     boost::timer t;
00038 
00039     if (!m_ob.get()) throw Sct::IllegalStateError("Null pointer", __FILE__, __LINE__);
00040     if (m_server=="") m_server = Archiver::instance().getRetrieveIsServer();
00041 
00042     if (m_ob->getClassName()=="TestData" || m_ob->getClassName()=="SequenceData") {
00043       shared_ptr<Sct::ISSerializableWrapperI> wrap = boost::dynamic_pointer_cast<Sct::ISSerializableWrapperI>(m_ob);
00044       if (!wrap.get()) throw Sct::IllegalStateError(m_ob->getClassName() + 
00045                             " couldnt be cast as a ISSerializableWrapperI", __FILE__, __LINE__);
00046       wrap->publishWrappedObjectToServer( m_server );
00047     }else{
00048       Sct::IS::IOParamsIS params( m_server );
00049       Sct::ISProxy::IOManagerISProxy::instance().write(*m_ob, &params);      
00050     }
00051 
00052      // if TestResult publish summary too.
00053     if (m_ob->getClassName().find("TestResult")!=std::string::npos){
00054       try{
00055     shared_ptr<SctData::TestResult> r = boost::dynamic_pointer_cast<SctData::TestResult>(m_ob);
00056     TestSummaryIS t;
00057     t.dataString = SctData::TestSummary::SummaryManager::instance().write(*r);
00058     std::string name = m_server;
00059     name += ".";
00060     name += "Summary.";
00061     name += m_ob->getUniqueID();
00062     ISInfoDictionary& is = SctNames::getISDictionary();
00063     ISInfo::Status stat;
00064     if (is.contains(name.c_str())) {
00065       stat = is.update(name.c_str(), t);
00066     } else {
00067       stat = is.insert(name.c_str(), t);
00068     }
00069       }catch(Sct::Throwable& e){
00070     e.sendToMrs(MRS_DIAGNOSTIC);
00071       }
00072       
00073       Archiver::instance().addISTime(t.elapsed());
00074     }
00075   }
00076 }

Generated on Thu Jul 15 09:50:47 2004 for SCT DAQ/DCS Software - C++ by doxygen 1.3.5