/search.css" rel="stylesheet" type="text/css"/> /search.js">
00001 /* 00002 * DaqFormatSelector.cc 00003 * DaqFormatModules 00004 * 00005 * Created by Simon Patton on 8/8/10. 00006 * Copyright 2010 DayaBay Collaboration. All rights reserved. 00007 * 00008 */ 00009 #include "DaqFormatSelector.h" 00010 00011 #include "DaqFormatContext.h" 00012 #include "StructureConverter.h" 00013 00014 #include "DaqReadoutSvc/IDaqReadoutSvc.h" 00015 00016 using DybDaq::DaqFormatContext; 00017 using DybDaq::DaqFormatSelector; 00018 using DybDaq::StructureConverter; 00019 using std::vector; 00020 using std::string; 00021 00022 DaqFormatSelector::DaqFormatSelector(const std::string& name, 00023 ISvcLocator* svc) : 00024 Service(name, 00025 svc), 00026 m_inputFiles(new vector<string>()) { 00027 declareProperty("InputFiles", 00028 *m_inputFiles, 00029 "List of input data files"); 00030 } 00031 00032 DaqFormatSelector::~DaqFormatSelector() { 00033 if (0 != m_inputFiles) { 00034 delete m_inputFiles; 00035 } 00036 } 00037 00038 StatusCode DaqFormatSelector::initialize() { 00039 StatusCode status = Service::initialize(); 00040 if (status.isFailure()) { 00041 return status; 00042 } 00043 return service("DaqReadoutSvc", 00044 "DaqReadoutSvc", 00045 m_daqSvc); 00046 } 00047 00048 StatusCode DaqFormatSelector::finalize() 00049 { 00050 if (0 != m_daqSvc) { 00051 m_daqSvc->release(); 00052 } 00053 return Service::finalize(); 00054 } 00055 00056 StatusCode DaqFormatSelector::createContext(Context*& context) const { 00057 context = new DaqFormatContext(*m_inputFiles, 00058 *msgSvc(), 00059 *m_daqSvc); 00060 return StatusCode::SUCCESS; 00061 } 00062 00063 StatusCode DaqFormatSelector::next(Context& context) const { 00064 return next(context, 00065 m_daqSvc->samplingInterval()); 00066 } 00067 00068 00069 StatusCode DaqFormatSelector::next(Context& context, 00070 int jump) const { 00071 DaqFormatContext* ctxt = dynamic_cast<DaqFormatContext*>(&context); 00072 return ctxt->jump(jump); 00073 } 00074 00075 00076 StatusCode DaqFormatSelector::createAddress(const Context& context, 00077 IOpaqueAddress*& iop) const { 00078 const DaqFormatContext* ctxt = dynamic_cast<const DaqFormatContext*>(&context); 00079 StatusCode status = ctxt->isGoodEvent(); 00080 if (status.isFailure()) { 00081 return status; 00082 } 00083 iop = new StructureConverter::Address(*ctxt, 00084 StructureConverter::kEvent); 00085 return StatusCode::SUCCESS; 00086 } 00087 00088 00089 StatusCode DaqFormatSelector::releaseContext(Context*& context) const { 00090 if (0 != context) { 00091 delete context; 00092 } 00093 return StatusCode::SUCCESS; 00094 } 00095 00096 00097 StatusCode DaqFormatSelector::queryInterface(const InterfaceID& id, 00098 void** interface) { 00099 if (IEvtSelector::interfaceID().versionMatch(id)) { 00100 // Good enough. Return this object 00101 *interface = dynamic_cast<IEvtSelector*>(this); 00102 addRef(); 00103 return StatusCode::SUCCESS; 00104 } 00105 // Try base class 00106 return Service::queryInterface(id, 00107 interface); 00108 } 00109 00110 StatusCode DaqFormatSelector::previous(Context& /* context */) const { 00111 return StatusCode::FAILURE; 00112 } 00113 00114 StatusCode DaqFormatSelector::previous(Context& /* context */, 00115 int /* jump */) const { 00116 return StatusCode::FAILURE; 00117 } 00118 00119 StatusCode DaqFormatSelector::last(Context& /* context */) const { 00120 return StatusCode::FAILURE; 00121 } 00122 00123 StatusCode DaqFormatSelector::rewind(Context& /* context */) const { 00124 return StatusCode::FAILURE; 00125 } 00126 00127 StatusCode DaqFormatSelector::resetCriteria(const std::string& /* criteria */, 00128 Context& /* context */) const { 00129 return StatusCode::FAILURE; 00130 }