| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

StructureConverter.cc

Go to the documentation of this file.
00001 /*
00002  *  StructureConverter.cc
00003  *  DaqFormatModules
00004  *
00005  *  Created by Simon Patton on 7/22/10.
00006  *  Copyright 2010 DayaBay Collaboration. All rights reserved.
00007  *
00008  */
00009 #include "StructureConverter.h"
00010 
00011 #include "DaqFormatConversionSvc.h"
00012 #include "DaqEventConverter.h"
00013 #include "Event/ReadoutHeader.h"
00014 #include "GaudiKernel/DataObject.h"
00015 #include "GaudiKernel/IDataManagerSvc.h"
00016 
00017 using DybDaq::DaqFormatContext;
00018 using DybDaq::DaqEventConverter;
00019 using DybDaq::StructureConverter;
00020 
00021 const unsigned int StructureConverter::kEvent = 0;
00022 const unsigned int StructureConverter::kReadout = StructureConverter::kEvent + 1;
00023 const unsigned int StructureConverter::kLastElement = StructureConverter::kReadout;
00024 
00025 const char* paths[] = {
00026     "Readout",
00027     "ReadoutHeader"
00028 };
00029 
00030 StructureConverter::Address::Address(const DaqFormatContext& context,
00031                                      const unsigned int element) :
00032     GenericAddress(storageType(),
00033                    classID()),
00034     m_context(context),
00035     m_element(element) {
00036 }
00037 
00038 StructureConverter::Address::~Address() {
00039 }
00040 
00041 const DaqFormatContext& StructureConverter::Address::context() const {
00042     return m_context;
00043 }
00044 
00045 unsigned int StructureConverter::Address::element() const {
00046     return m_element;
00047 }
00048 
00049 StructureConverter::StructureConverter(unsigned char storageType,
00050                                        const CLID& clid,
00051                                        ISvcLocator* svc) :
00052     Converter(storageType,
00053               clid,
00054               svc) {
00055 }
00056 
00057 StructureConverter::StructureConverter(ISvcLocator* svc) :
00058     Converter(storageType(),
00059               classID(),
00060               svc) {
00061 }
00062 
00063 StructureConverter::~StructureConverter() {
00064 }
00065 
00066 const long StructureConverter::storageType() {
00067     return DaqFormatConversionSvc::DAQ_FORMAT_DATA;
00068 }
00069 
00070 const CLID& StructureConverter::classID() {
00071     return CLID_DataObject;
00072 }
00073 
00074 StatusCode StructureConverter::createObj(IOpaqueAddress* addr,
00075                                          DataObject*& pObject) {
00076     Address* address = dynamic_cast<Address*>(addr);
00077     if (0 == address) {
00078         return StatusCode::FAILURE;
00079     }
00080     pObject = new DataObject();
00081     if (0 == pObject) {
00082         return StatusCode::FAILURE;
00083     }
00084     return StatusCode::SUCCESS;
00085     
00086 }
00087 
00088 StatusCode StructureConverter::fillObjRefs(IOpaqueAddress* addr,
00089                                            DataObject* pObject) {
00090     Address* address = dynamic_cast<Address*>(addr);
00091     const unsigned int element = address->element();
00092     const char* path = paths[element];
00093     if (kLastElement == element) {
00094         dataManager()->registerAddress(pObject,
00095                                        path,
00096                                        new DaqEventConverter::Address(address->context()));
00097     } else {
00098         dataManager()->registerAddress(pObject,
00099                                        path,
00100                                        new Address(address->context(),
00101                                                    element + 1));
00102     }
00103     return StatusCode::SUCCESS;
00104 }
00105 
00106 long StructureConverter::repSvcType() const {
00107     return i_repSvcType();
00108 }
00109 
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Mon Apr 11 20:46:28 2011 for DaqFormatModules by doxygen 1.4.7