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.6 2010/07/23 16:02:54 eulisse Exp $
12 //
13 
14 // system include files
15 #include "Reflex/Object.h"
16 #include "TVirtualCollectionProxy.h"
17 
18 // user include files
20 
21 
22 //
23 // constants, enums and typedefs
24 //
25 
26 //
27 // static data member definitions
28 //
29 
30 //
31 // constructors and destructor
32 //
34  const TClass* iType,
35  boost::shared_ptr<TVirtualCollectionProxy> iProxy,
36  size_t iOffset)
37  : m_type(iType),
38  m_colProxy(iProxy),
39  m_data(0),
40  m_offset(iOffset)
41 {
42 }
43 
44 // FWItemTVirtualCollectionProxyAccessor::FWItemTVirtualCollectionProxyAccessor(const FWItemTVirtualCollectionProxyAccessor& rhs)
45 // {
46 // // do actual copying here;
47 // }
48 
50 {
51 }
52 
53 //
54 // assignment operators
55 //
56 // const FWItemTVirtualCollectionProxyAccessor& FWItemTVirtualCollectionProxyAccessor::operator=(const FWItemTVirtualCollectionProxyAccessor& rhs)
57 // {
58 // //An exception safe implementation is
59 // FWItemTVirtualCollectionProxyAccessor temp(rhs);
60 // swap(rhs);
61 //
62 // return *this;
63 // }
64 
65 //
66 // member functions
67 //
68 void
69 FWItemTVirtualCollectionProxyAccessor::setData(const ROOT::Reflex::Object& product)
70 {
71  if (product.Address() == 0)
72  {
73  reset();
74  return;
75  }
76 
77  using ROOT::Reflex::Object;
78  if(product.TypeOf().IsTypedef())
79  m_data = Object(product.TypeOf().ToType(),product.Address()).Address();
80  else
81  m_data = product.Address();
82 
83  assert(0!=m_data);
84  m_colProxy->PushProxy(static_cast<char*>(const_cast<void*>(m_data))+m_offset);
85 }
86 
87 void
89 {
90  if (0 != m_data)
91  {
92  m_data=0;
93  m_colProxy->PopProxy();
94  }
95 }
96 
97 //
98 // const member functions
99 //
100 const void*
102 {
103  if ( 0 == m_data) { return m_data; }
104  return m_colProxy->At(iIndex);
105 }
106 
107 const void*
109 {
110  return m_data;
111 }
112 
113 unsigned int
115 {
116  if(m_data==0) {
117  return 0;
118  }
119  return m_colProxy->Size();
120 }
121 
122 const TClass*
124 {
125  return m_colProxy->GetValueClass();
126 }
127 
128 const TClass*
130 {
131  return m_type;
132 }
133 
134 bool
136 {
137  return true;
138 }
139 
140 //
141 // static member functions
142 //
FWItemTVirtualCollectionProxyAccessor(const TClass *iType, boost::shared_ptr< TVirtualCollectionProxy > iProxy, size_t iOffset=0)
boost::shared_ptr< TVirtualCollectionProxy > m_colProxy