ATLAS Offline Software
T_AthenaRootConverter.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef ATHENAPOOLSERVICES_TATHENAROOTCONVERTER_H
6 #define ATHENAPOOLSERVICES_TATHENAROOTCONVERTER_H
7 
14 #include <string>
15 #include <typeinfo>
16 
18 public:
19 
22  void SetClassNameAndChecksum(const std::string &classname, unsigned checksum);
25  virtual void Convert(const void *old_obj, void *new_obj) = 0;
26 
27  const std::string& ClassName() { return m_className; }
28  unsigned StreamerChecksum() { return m_streamerChecksum; }
29 
31  virtual void* InstantiateOld() = 0;
33  virtual const std::type_info& TypeIDOld() = 0;
34 
36 
37 protected:
39 
40  std::string m_className;
42 };
43 
44 
45 
46 inline
48  : m_className(),
49  m_streamerChecksum(0)
50 {
51 }
52 
53 
54 inline
55 void T_AthenaRootConverterBase::SetClassNameAndChecksum(const std::string &classname, unsigned checksum)
56 {
57  m_className = classname;
58  m_streamerChecksum = checksum;
59 }
60 
61 
62 
63 
64 template<class NEW, class OLD>
66 public:
72  }
73 
78  virtual void CopyOldToNew( const OLD &old_obj, NEW &new_obj ) {
79  new_obj = *(NEW*)&old_obj;
80  }
81 
84  virtual void Convert(const void *old_obj, void *new_obj) {
85  CopyOldToNew( *(const OLD*)old_obj, *(NEW*)new_obj);
86  }
87 
89  virtual void* InstantiateOld() { return new OLD(); }
91  virtual const std::type_info& TypeIDOld() { return typeid(OLD); }
92 };
93 
94 
95 #endif
T_AthenaRootConverterBase
Definition: T_AthenaRootConverter.h:17
T_AthenaRootConverterBase::m_streamerChecksum
unsigned m_streamerChecksum
Definition: T_AthenaRootConverter.h:41
T_AthenaRootConverter::InstantiateOld
virtual void * InstantiateOld()
Create an instance of the old object.
Definition: T_AthenaRootConverter.h:89
T_AthenaRootConverterBase::ClassName
const std::string & ClassName()
Definition: T_AthenaRootConverter.h:27
T_AthenaRootConverterBase::InstantiateOld
virtual void * InstantiateOld()=0
Create an instance of the old object.
T_AthenaRootConverter
Definition: T_AthenaRootConverter.h:65
T_AthenaRootConverterBase::StreamerChecksum
unsigned StreamerChecksum()
Definition: T_AthenaRootConverter.h:28
T_AthenaRootConverterBase::T_AthenaRootConverterBase
T_AthenaRootConverterBase()
Definition: T_AthenaRootConverter.h:47
T_AthenaRootConverterBase::TypeIDOld
virtual const std::type_info & TypeIDOld()=0
Get typeinfo of the old object type.
T_AthenaRootConverterBase::~T_AthenaRootConverterBase
virtual ~T_AthenaRootConverterBase()
Definition: T_AthenaRootConverter.h:35
T_AthenaRootConverter::T_AthenaRootConverter
T_AthenaRootConverter()
Set the name of the class for which this converter is implemented and the particualar ROOT streamerIn...
Definition: T_AthenaRootConverter.h:70
T_AthenaRootConverter::Convert
virtual void Convert(const void *old_obj, void *new_obj)
General (typeless) invocation of the convertion function it calls the actual user implemenation with ...
Definition: T_AthenaRootConverter.h:84
T_AthenaRootConverter::TypeIDOld
virtual const std::type_info & TypeIDOld()
Get typeinfo of the old object type.
Definition: T_AthenaRootConverter.h:91
T_AthenaRootConverterBase::m_className
std::string m_className
Definition: T_AthenaRootConverter.h:40
T_AthenaRootConverterBase::SetClassNameAndChecksum
void SetClassNameAndChecksum(const std::string &classname, unsigned checksum)
Set the name of the class for which this converter is implemented and the particualar ROOT streamerIn...
Definition: T_AthenaRootConverter.h:55
T_AthenaRootConverterBase::Convert
virtual void Convert(const void *old_obj, void *new_obj)=0
General (typeless) invocation of the convertion function in the derived templated class it calls the ...
T_AthenaRootConverter::CopyOldToNew
virtual void CopyOldToNew(const OLD &old_obj, NEW &new_obj)
The converter function which copies the content of the object from its old shape to the new shape To ...
Definition: T_AthenaRootConverter.h:78