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  :     FWItemTVirtualCollectionProxyAccessor
0005 //
0006 // Implementation:
0007 //     <Notes on implementation>
0008 //
0009 // Original Author:  Chris Jones
0010 //         Created:  Sat Oct 18 08:43:47 EDT 2008
0011 //
0012 
0013 // system include files
0014 #include <cassert>
0015 #include "FWCore/Reflection/interface/ObjectWithDict.h"
0016 #include "FWCore/Reflection/interface/TypeWithDict.h"
0017 #include "TVirtualCollectionProxy.h"
0018 
0019 // user include files
0020 #include "Fireworks/Core/src/FWItemTVirtualCollectionProxyAccessor.h"
0021 
0022 //
0023 // constants, enums and typedefs
0024 //
0025 
0026 //
0027 // static data member definitions
0028 //
0029 
0030 //
0031 // constructors and destructor
0032 //
0033 FWItemTVirtualCollectionProxyAccessor::FWItemTVirtualCollectionProxyAccessor(
0034     const TClass* iType, std::shared_ptr<TVirtualCollectionProxy> iProxy, size_t iOffset)
0035     : m_type(iType), m_colProxy(iProxy), m_data(nullptr), m_offset(iOffset) {}
0036 
0037 // FWItemTVirtualCollectionProxyAccessor::FWItemTVirtualCollectionProxyAccessor(const FWItemTVirtualCollectionProxyAccessor& rhs)
0038 // {
0039 //    // do actual copying here;
0040 // }
0041 
0042 FWItemTVirtualCollectionProxyAccessor::~FWItemTVirtualCollectionProxyAccessor() {}
0043 
0044 //
0045 // assignment operators
0046 //
0047 // const FWItemTVirtualCollectionProxyAccessor& FWItemTVirtualCollectionProxyAccessor::operator=(const FWItemTVirtualCollectionProxyAccessor& rhs)
0048 // {
0049 //   //An exception safe implementation is
0050 //   FWItemTVirtualCollectionProxyAccessor temp(rhs);
0051 //   swap(rhs);
0052 //
0053 //   return *this;
0054 // }
0055 
0056 //
0057 // member functions
0058 //
0059 void FWItemTVirtualCollectionProxyAccessor::setData(const edm::ObjectWithDict& product) {
0060   if (product.address() == nullptr) {
0061     reset();
0062     return;
0063   }
0064 
0065   m_data = product.address();
0066   assert(nullptr != m_data);
0067   m_colProxy->PushProxy(static_cast<char*>(const_cast<void*>(m_data)) + m_offset);
0068 }
0069 
0070 void FWItemTVirtualCollectionProxyAccessor::reset() {
0071   if (nullptr != m_data) {
0072     m_data = nullptr;
0073     m_colProxy->PopProxy();
0074   }
0075 }
0076 
0077 //
0078 // const member functions
0079 //
0080 const void* FWItemTVirtualCollectionProxyAccessor::modelData(int iIndex) const {
0081   if (nullptr == m_data) {
0082     return m_data;
0083   }
0084   return m_colProxy->At(iIndex);
0085 }
0086 
0087 const void* FWItemTVirtualCollectionProxyAccessor::data() const { return m_data; }
0088 
0089 unsigned int FWItemTVirtualCollectionProxyAccessor::size() const {
0090   if (m_data == nullptr) {
0091     return 0;
0092   }
0093   return m_colProxy->Size();
0094 }
0095 
0096 const TClass* FWItemTVirtualCollectionProxyAccessor::modelType() const { return m_colProxy->GetValueClass(); }
0097 
0098 const TClass* FWItemTVirtualCollectionProxyAccessor::type() const { return m_type; }
0099 
0100 bool FWItemTVirtualCollectionProxyAccessor::isCollection() const { return true; }
0101 
0102 //
0103 // static member functions
0104 //