CMS 3D CMS Logo

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FWItemRandomAccessor.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Core
4 // Class : FWItemRandomAccessor
5 //
6 // Implementation:
7 // A generic helper class which can be used to create
8 // a specialized FWItemAccessorBase plugin for
9 // all the classes that expose a std::vector like interface.
10 //
11 // Original Author: Giulio Eulisse
12 // Created: Thu Feb 18 15:19:44 EDT 2008
13 // $Id: FWItemRandomAccessor.cc,v 1.4 2012/06/26 22:09:35 wmtan Exp $
14 //
15 
16 // system include files
17 #include <assert.h>
18 #include "TClass.h"
19 
20 // user include files
22 
23 // forward declarations
24 
25 FWItemRandomAccessorBase::FWItemRandomAccessorBase(const TClass *type, const type_info &modelTypeName)
26 :m_type(type),
27  m_modelType(TClass::GetClass(modelTypeName)),
28  m_data(0)
29 {
30 }
31 
32 // FWItemRandomAccessor::FWItemRandomAccessor(const FWItemRandomAccessor& rhs)
33 // {
34 // // do actual copying here;
35 // }
36 
38 {
39 }
40 
41 //
42 // assignment operators
43 //
44 // const FWItemRandomAccessor& FWItemRandomAccessor::operator=(const FWItemRandomAccessor& rhs)
45 // {
46 // //An exception safe implementation is
47 // FWItemRandomAccessor temp(rhs);
48 // swap(rhs);
49 //
50 // return *this;
51 // }
52 
53 //
54 // member functions
55 //
56 void
57 FWItemRandomAccessorBase::setData(const Reflex::Object& product)
58 {
59  if (product.Address() == 0)
60  {
61  reset();
62  return;
63  }
64 
65  if(product.TypeOf().IsTypedef())
66  m_data = Reflex::Object(product.TypeOf().ToType(),product.Address()).Address();
67  else
68  m_data = product.Address();
69  assert(0!=m_data);
70 }
71 
72 void
74 {
75  m_data = 0;
76 }
77 
78 //
79 // const member functions
80 //
81 const void*
83 {
84  return m_data;
85 }
86 
87 void*
89 {
90  return m_data;
91 }
92 
93 const TClass*
95 {
96  return m_type;
97 }
98 
99 const TClass*
101 {
102  assert(m_modelType);
103  return m_modelType;
104 }
105 
106 bool
108 {
109  return true;
110 }
111 //
112 // static member functions
113 //
type
Definition: HCALResponse.h:22
const TClass * type() const
const void * data() const
FWItemRandomAccessorBase(const TClass *type, const type_info &modelTypeName)
void setData(const Reflex::Object &)
override if id of an object should be different than the index
const TClass * modelType() const