CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 // $Id: FWItemTVirtualCollectionProxyAccessor.cc,v 1.11 2013/02/10 22:12:04 wmtan Exp $
12 //
13 
14 // system include files
15 #include <cassert>
18 #include "TVirtualCollectionProxy.h"
19 
20 // user include files
22 
23 
24 //
25 // constants, enums and typedefs
26 //
27 
28 //
29 // static data member definitions
30 //
31 
32 //
33 // constructors and destructor
34 //
36  const TClass* iType,
37  boost::shared_ptr<TVirtualCollectionProxy> iProxy,
38  size_t iOffset)
39  : m_type(iType),
40  m_colProxy(iProxy),
41  m_data(0),
42  m_offset(iOffset)
43 {
44 }
45 
46 // FWItemTVirtualCollectionProxyAccessor::FWItemTVirtualCollectionProxyAccessor(const FWItemTVirtualCollectionProxyAccessor& rhs)
47 // {
48 // // do actual copying here;
49 // }
50 
52 {
53 }
54 
55 //
56 // assignment operators
57 //
58 // const FWItemTVirtualCollectionProxyAccessor& FWItemTVirtualCollectionProxyAccessor::operator=(const FWItemTVirtualCollectionProxyAccessor& rhs)
59 // {
60 // //An exception safe implementation is
61 // FWItemTVirtualCollectionProxyAccessor temp(rhs);
62 // swap(rhs);
63 //
64 // return *this;
65 // }
66 
67 //
68 // member functions
69 //
70 void
72 {
73  if (product.address() == 0)
74  {
75  reset();
76  return;
77  }
78 
79  m_data = product.address();
80  assert(0!=m_data);
81  m_colProxy->PushProxy(static_cast<char*>(const_cast<void*>(m_data))+m_offset);
82 }
83 
84 void
86 {
87  if (0 != m_data)
88  {
89  m_data=0;
90  m_colProxy->PopProxy();
91  }
92 }
93 
94 //
95 // const member functions
96 //
97 const void*
99 {
100  if ( 0 == m_data) { return m_data; }
101  return m_colProxy->At(iIndex);
102 }
103 
104 const void*
106 {
107  return m_data;
108 }
109 
110 unsigned int
112 {
113  if(m_data==0) {
114  return 0;
115  }
116  return m_colProxy->Size();
117 }
118 
119 const TClass*
121 {
122  return m_colProxy->GetValueClass();
123 }
124 
125 const TClass*
127 {
128  return m_type;
129 }
130 
131 bool
133 {
134  return true;
135 }
136 
137 //
138 // static member functions
139 //
void * address() const
FWItemTVirtualCollectionProxyAccessor(const TClass *iType, boost::shared_ptr< TVirtualCollectionProxy > iProxy, size_t iOffset=0)
virtual const void * modelData(int iIndex) const
boost::shared_ptr< TVirtualCollectionProxy > m_colProxy
void setData(const edm::ObjectWithDict &)
override if id of an object should be different than the index