ATLAS Offline Software
CaloIDHelper_IDDetDescrCnv.icc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 // $Id$
6 /**
7  * @file CaloIdCnv/CaloIDHelper_IDDetDescrCnv.icc
8  * @author scott snyder <snyder@bnl.gov>
9  * @date Aug, 2012
10  * @brief Common code for creating calo ID helpers in the detector store.
11  */
12 
13 
14 #include "AthenaKernel/StorableConversions.h"
15 #include "AthenaKernel/errorcheck.h"
16 
17 
18 namespace CaloIdCnv {
19 
20 
21 /**
22  * @brief Helper function to actually create a new helper.
23  * @param svcloc Gaudi service locator.
24  * @param helperKey The StoreGate key of the helper being created.
25  * @param idhelper[out] Set to the created helper.
26  *
27  * The default implementation just does @c new with the default constructor;
28  * however, this function may be overridden for specific types.
29  */
30 template <class T>
31 StatusCode make_CaloIDHelper (ISvcLocator* /*svcloc*/,
32  const std::string& /*helperKey*/,
33  T* & idhelper)
34 {
35  idhelper = new T;
36  return StatusCode::SUCCESS;
37 }
38 
39 
40 /**
41  * @brief Return the CLID of the class we create.
42  * Required by the converter infrastructure.
43  */
44 template <class T>
45 const CLID& CaloIDHelper_IDDetDescrCnv_T<T>::classID()
46 {
47  return ClassID_traits<T>::ID();
48 }
49 
50 
51 /**
52  * @brief Constructor.
53  * @param svcloc Gaudi service locator.
54  */
55 template <class T>
56 CaloIDHelper_IDDetDescrCnv_T<T>::CaloIDHelper_IDDetDescrCnv_T
57  (ISvcLocator* svcloc)
58  : CaloIDHelper_IDDetDescrCnv (classID(), svcloc)
59 {
60 }
61 
62 
63 /**
64  * @brief Create the helper object.
65  * @param helperKey StoreGate key of the helper.
66  * @param idhelper[out] Set to a pointer to the new helper.
67  * @param pObj[out] Set to a reference to the created helper.
68  */
69 template <class T>
70 StatusCode
71 CaloIDHelper_IDDetDescrCnv_T<T>::createHelper (const std::string& helperKey,
72  IdHelper* & idhelper,
73  DataObject*& pObj)
74 {
75  T* helper = 0;
76  CHECK( make_CaloIDHelper (serviceLocator(), helperKey, helper) );
77  idhelper = helper;
78  pObj = SG::asStorable(helper);
79  return StatusCode::SUCCESS;
80 }
81 
82 
83 } // namespace CaloIdCnv