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

IsGetCommand.cpp

00001 #include "IsGetCommand.h"
00002 #include "Archiver.h"
00003 #include "Sct/IS/IOManagerIS.h"
00004 #include "Sct/IoExceptions.h"
00005 #include "SerializableWrappers.h"
00006 #include "is/isinfoany.h"
00007 #include <boost/timer.hpp>
00008 
00009 namespace SctArchiving{
00010   IsGetCommand::IsGetCommand(boost::shared_ptr<Sct::IS::IONameIS> name)
00011     : GetCommand(name)
00012   {}
00013 
00014   IsGetCommand::IsGetCommand() {}
00015 
00016   IsGetCommand::~IsGetCommand(){}
00017 
00018   void IsGetCommand::execute(){
00019     boost::timer t;
00020     if (m_name->getIOName().find("SctData")==std::string::npos) {
00021       // IS object
00022       m_ob = retrieveISOB( m_name->getIOName() );
00023     }else{
00024       // Serializable
00025       m_ob = Sct::IS::IOManagerIS::instance().read(m_name->getIOName());
00026     }
00027     
00028     Archiver::instance().addISTime(t.elapsed());
00029   }
00030 
00031   boost::shared_ptr<ArchivingCommand> IsGetCommand::create()const{
00032     boost::shared_ptr<ArchivingCommand> cmd(new IsGetCommand() );
00033     return cmd;
00034   }  
00035   
00037   shared_ptr<Sct::Serializable> IsGetCommand::retrieveISOB(const std::string& name) const {
00038     ISInfoAny infoany;
00039     ISInfo::Status result = SctNames::getISDictionary().findValue(name.c_str(), infoany);
00040     if (result != ISInfo::Success) {
00041       std::ostringstream oss;
00042       oss << "Error reading from IS server.  Couldn't get: "
00043       << name << " expected class TestData";
00044       throw Sct::IsException(result, oss.str(), __FILE__, __LINE__);
00045     }
00046     const std::string& classname=infoany.type().name();
00047 
00048     if (classname == "TestData") {
00049       shared_ptr<TestData> td ( new TestData() );
00050       ISInfo::Status result = SctNames::getISDictionary().findValue(name.c_str(), *td);
00051       if (result != ISInfo::Success) {
00052     std::ostringstream oss;
00053     oss << "Error reading from IS server.  Couldn't get: "
00054         << name << " expected class TestData";
00055             throw IsException(result, oss.str(), __FILE__, __LINE__);
00056       }
00057       return shared_ptr<Sct::Serializable> ( new Sct::ISSerializableWrapper<TestData>(td) );
00058     } else if (classname == "SequenceData"){
00059       shared_ptr<SequenceData> td ( new SequenceData() );
00060       ISInfo::Status result = SctNames::getISDictionary().findValue(name.c_str(), *td);
00061       if (result != ISInfo::Success) {
00062     std::ostringstream oss;
00063     oss << "Error reading from IS server.  Couldn't get: "
00064         << name << " expected class SequenceData";
00065             throw Sct::IsException(result, oss.str(), __FILE__, __LINE__);
00066       }
00067       return shared_ptr<Sct::Serializable> ( new Sct::ISSerializableWrapper<SequenceData>(td) );   
00068     } else {
00069       throw Sct::IoException(string("I don't know how to retrieve ") + name, __FILE__, __LINE__);
00070     }
00071   }
00072 
00073 }

Generated on Fri Sep 16 18:01:52 2005 for SCT DAQ/DCS Software - C++ by doxygen 1.3.5