Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:27:16

0001 // -*- C++ -*-
0002 //
0003 // Package:     Core
0004 // Class  :     FWItemRandomAccessor
0005 //
0006 // Implementation:
0007 //    A generic helper class which can be used to create
0008 //    a specialized FWItemAccessorBase plugin for
0009 //    all the classes that expose a std::vector like interface.
0010 //
0011 // Original Author:  Giulio Eulisse
0012 //         Created:  Thu Feb 18 15:19:44 EDT 2008
0013 //
0014 
0015 // system include files
0016 #include <cassert>
0017 #include "TClass.h"
0018 
0019 // user include files
0020 #include "Fireworks/Core/interface/FWItemRandomAccessor.h"
0021 
0022 // forward declarations
0023 
0024 FWItemRandomAccessorBase::FWItemRandomAccessorBase(const TClass* type, const std::type_info& modelTypeName)
0025     : m_type(type), m_modelType(TClass::GetClass(modelTypeName)), m_data(nullptr) {}
0026 
0027 // FWItemRandomAccessor::FWItemRandomAccessor(const FWItemRandomAccessor& rhs)
0028 // {
0029 //    // do actual copying here;
0030 // }
0031 
0032 FWItemRandomAccessorBase::~FWItemRandomAccessorBase() {}
0033 
0034 //
0035 // assignment operators
0036 //
0037 // const FWItemRandomAccessor& FWItemRandomAccessor::operator=(const FWItemRandomAccessor& rhs)
0038 // {
0039 //   //An exception safe implementation is
0040 //   FWItemRandomAccessor temp(rhs);
0041 //   swap(rhs);
0042 //
0043 //   return *this;
0044 // }
0045 
0046 //
0047 // member functions
0048 //
0049 void FWItemRandomAccessorBase::setData(const edm::ObjectWithDict& product) {
0050   if (product.address() == nullptr) {
0051     reset();
0052     return;
0053   }
0054 
0055   m_data = product.address();
0056   assert(nullptr != m_data);
0057 }
0058 
0059 void FWItemRandomAccessorBase::reset() { m_data = nullptr; }
0060 
0061 //
0062 // const member functions
0063 //
0064 const void* FWItemRandomAccessorBase::data() const { return m_data; }
0065 
0066 void* FWItemRandomAccessorBase::getDataPtr() const { return m_data; }
0067 
0068 const TClass* FWItemRandomAccessorBase::type() const { return m_type; }
0069 
0070 const TClass* FWItemRandomAccessorBase::modelType() const {
0071   assert(m_modelType);
0072   return m_modelType;
0073 }
0074 
0075 bool FWItemRandomAccessorBase::isCollection() const { return true; }
0076 //
0077 // static member functions
0078 //