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.2 2010/06/18 10:17:15 yana 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 ROOT::Reflex::Object& product)
58 {
59  if (product.Address() == 0)
60  {
61  reset();
62  return;
63  }
64 
65  using ROOT::Reflex::Object;
66  if(product.TypeOf().IsTypedef())
67  m_data = Object(product.TypeOf().ToType(),product.Address()).Address();
68  else
69  m_data = product.Address();
70  assert(0!=m_data);
71 }
72 
73 void
75 {
76  m_data = 0;
77 }
78 
79 //
80 // const member functions
81 //
82 const void*
84 {
85  return m_data;
86 }
87 
88 void*
90 {
91  return m_data;
92 }
93 
94 const TClass*
96 {
97  return m_type;
98 }
99 
100 const TClass*
102 {
103  assert(m_modelType);
104  return m_modelType;
105 }
106 
107 bool
109 {
110  return true;
111 }
112 //
113 // static member functions
114 //
type
Definition: HCALResponse.h:22
const TClass * type() const
void setData(const ROOT::Reflex::Object &)
const void * data() const
FWItemRandomAccessorBase(const TClass *type, const type_info &modelTypeName)
const TClass * modelType() const