ATLAS Offline Software
TVirtualConverter.icc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // $Id: TVirtualConverter.icc,v 1.2 2006-12-19 04:11:20 ssnyder Exp $
6 /**
7  * @file TVirtualConverter.icc
8  * @author scott snyder <snyder@bnl.gov>
9  * @date Dec, 2006
10  * @brief Base class for Root converters --- template implementations.
11  */
12 
13 
14 /**
15  * @brief Constructor, with class pointers.
16  * @param trans_cls The transient class to which we will be converting.
17  * @param pers_cls The persistent class to which we will be converting.
18  *
19  * The checksum will be calculated automatically from the provided classes.
20  *
21  * If either of the class pointers is defaulted to 0, the class pointer
22  * will be computed from the appropriate template parameter.
23  */
24 template <class TTrans, class TPers>
25 TVirtualConverter_T<TTrans, TPers>::TVirtualConverter_T
26  (TClass* trans_class /*= 0*/,
27  TClass* pers_class /*= 0*/)
28  : TVirtualConverter (trans_class ?
29  trans_class :
30  TVirtualConverter::ToClass (typeid (TTrans)),
31  pers_class ?
32  pers_class :
33  TVirtualConverter::ToClass (typeid (TPers)))
34 {}
35 
36 
37 /**
38  * @brief Constructor, with checksum and class pointers.
39  * @param checksum The Root checksum of the persistent class we'll convert.
40  * @param trans_cls The transient class to which we will be converting.
41  * @param pers_cls The persistent class to which we will be converting.
42  *
43  * If either of the class pointers is defaulted to 0, the class pointer
44  * will be computed from the appropriate template parameter.
45  */
46 template <class TTrans, class TPers>
47 TVirtualConverter_T<TTrans, TPers>::TVirtualConverter_T
48  (UInt_t checksum,
49  TClass* trans_class /*= 0*/,
50  TClass* pers_class /*= 0*/)
51  : TVirtualConverter (checksum,
52  trans_class ?
53  trans_class :
54  TVirtualConverter::ToClass (typeid (TTrans)),
55  pers_class ?
56  pers_class :
57  TVirtualConverter::ToClass (typeid (TPers)))
58 {}
59 
60 
61 /**
62  * @brief Do the conversion.
63  * @param transobj Pointer to an instance of the transient class.
64  * @param persobj Pointer to an instance of the persistent class.
65  *
66  * This implementation simply calls the @c Convert below
67  * with the appropriate casting.
68  */
69 template <class TTrans, class TPers>
70 void TVirtualConverter_T<TTrans, TPers>::ConvertVoid (void* transobj,
71  const void* persobj)
72 {
73  this->Convert (reinterpret_cast<TTrans*> (transobj),
74  reinterpret_cast<const TPers*> (persobj));
75 }
76 
77