CMS 3D CMS Logo

FWItemTVirtualCollectionProxyAccessor.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Core
4 // Class : FWItemTVirtualCollectionProxyAccessor
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: Chris Jones
10 // Created: Sat Oct 18 08:43:47 EDT 2008
11 //
12 
13 // system include files
14 #include <cassert>
17 #include "TVirtualCollectionProxy.h"
18 
19 // user include files
21 
22 
23 //
24 // constants, enums and typedefs
25 //
26 
27 //
28 // static data member definitions
29 //
30 
31 //
32 // constructors and destructor
33 //
35  const TClass* iType,
36  std::shared_ptr<TVirtualCollectionProxy> iProxy,
37  size_t iOffset)
38  : m_type(iType),
39  m_colProxy(iProxy),
40  m_data(nullptr),
41  m_offset(iOffset)
42 {
43 }
44 
45 // FWItemTVirtualCollectionProxyAccessor::FWItemTVirtualCollectionProxyAccessor(const FWItemTVirtualCollectionProxyAccessor& rhs)
46 // {
47 // // do actual copying here;
48 // }
49 
51 {
52 }
53 
54 //
55 // assignment operators
56 //
57 // const FWItemTVirtualCollectionProxyAccessor& FWItemTVirtualCollectionProxyAccessor::operator=(const FWItemTVirtualCollectionProxyAccessor& rhs)
58 // {
59 // //An exception safe implementation is
60 // FWItemTVirtualCollectionProxyAccessor temp(rhs);
61 // swap(rhs);
62 //
63 // return *this;
64 // }
65 
66 //
67 // member functions
68 //
69 void
71 {
72  if (product.address() == nullptr)
73  {
74  reset();
75  return;
76  }
77 
78  m_data = product.address();
79  assert(nullptr!=m_data);
80  m_colProxy->PushProxy(static_cast<char*>(const_cast<void*>(m_data))+m_offset);
81 }
82 
83 void
85 {
86  if (nullptr != m_data)
87  {
88  m_data=nullptr;
89  m_colProxy->PopProxy();
90  }
91 }
92 
93 //
94 // const member functions
95 //
96 const void*
98 {
99  if ( nullptr == m_data) { return m_data; }
100  return m_colProxy->At(iIndex);
101 }
102 
103 const void*
105 {
106  return m_data;
107 }
108 
109 unsigned int
111 {
112  if(m_data==nullptr) {
113  return 0;
114  }
115  return m_colProxy->Size();
116 }
117 
118 const TClass*
120 {
121  return m_colProxy->GetValueClass();
122 }
123 
124 const TClass*
126 {
127  return m_type;
128 }
129 
130 bool
132 {
133  return true;
134 }
135 
136 //
137 // static member functions
138 //
std::shared_ptr< TVirtualCollectionProxy > m_colProxy
void * address() const
#define nullptr
const void * modelData(int iIndex) const override
void setData(const edm::ObjectWithDict &) override
override if id of an object should be different than the index
FWItemTVirtualCollectionProxyAccessor(const TClass *iType, std::shared_ptr< TVirtualCollectionProxy > iProxy, size_t iOffset=0)