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.8 2012/06/26 22:09:35 wmtan 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 Reflex::Object& product)
70 {
71  if (product.Address() == 0)
72  {
73  reset();
74  return;
75  }
76 
77  if(product.TypeOf().IsTypedef())
78  m_data = Reflex::Object(product.TypeOf().ToType(),product.Address()).Address();
79  else
80  m_data = product.Address();
81 
82  assert(0!=m_data);
83  m_colProxy->PushProxy(static_cast<char*>(const_cast<void*>(m_data))+m_offset);
84 }
85 
86 void
88 {
89  if (0 != m_data)
90  {
91  m_data=0;
92  m_colProxy->PopProxy();
93  }
94 }
95 
96 //
97 // const member functions
98 //
99 const void*
101 {
102  if ( 0 == m_data) { return m_data; }
103  return m_colProxy->At(iIndex);
104 }
105 
106 const void*
108 {
109  return m_data;
110 }
111 
112 unsigned int
114 {
115  if(m_data==0) {
116  return 0;
117  }
118  return m_colProxy->Size();
119 }
120 
121 const TClass*
123 {
124  return m_colProxy->GetValueClass();
125 }
126 
127 const TClass*
129 {
130  return m_type;
131 }
132 
133 bool
135 {
136  return true;
137 }
138 
139 //
140 // static member functions
141 //
FWItemTVirtualCollectionProxyAccessor(const TClass *iType, boost::shared_ptr< TVirtualCollectionProxy > iProxy, size_t iOffset=0)
boost::shared_ptr< TVirtualCollectionProxy > m_colProxy
void setData(const Reflex::Object &)
override if id of an object should be different than the index