ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
SGComps
src
SGFolder.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include <cassert>
6
#include <cstdlib>
/* atoi */
7
#include <iostream>
8
#include <vector>
9
10
#include "GaudiKernel/IMessageSvc.h"
11
#include "GaudiKernel/MsgStream.h"
12
#include "GaudiKernel/ISvcLocator.h"
13
14
#include "
AthenaKernel/DefaultKey.h
"
15
#include "GaudiKernel/IClassIDSvc.h"
16
#include "
AthenaKernel/ClassID_traits.h
"
17
18
#include "
SGFolder.h
"
19
20
/* #define SGFOLDER_DEBUG 1 */
21
22
using namespace
SG
;
23
24
25
26
//-----------------------------------------------------------------------------
27
Folder::Folder
(
const
std::string&
type
,
28
const
std::string& name,
29
const
IInterface* parent) :
30
base_class(
type
, name, parent ),
31
m_pCLIDSvc
(
"ClassIDSvc"
, name)
32
{
33
}
34
35
//-----------------------------------------------------------------------------
36
Folder::~Folder
()
37
{}
38
39
//-----------------------------------------------------------------------------
40
StatusCode
Folder::initialize
() {
41
return
m_pCLIDSvc
.retrieve();
42
}
43
44
//-----------------------------------------------------------------------------
45
void
Folder::updateItemList
(
bool
checkValid) {
46
std::vector< std::string >::const_iterator
47
i(
m_itemList
.value().begin()), e(
m_itemList
.value().end());
48
while
(i != e)
decodeItem
(*i++, checkValid);
49
}
50
51
void
Folder::decodeItem
(
const
std::string& item,
bool
checkValid) {
52
assert( !item.empty() );
53
assert(
m_pCLIDSvc
);
54
#ifdef SGFOLDER_DEBUG
55
//can't use MsgStream (log level still not defined)
56
std::cout <<
"Folder::decodeItem("
<< item<<
") called"
<< std::endl;
57
#endif
58
std::string::size_type sep(item.rfind(
'#'
));
59
std::string typeName (item.substr(0,sep));
60
std::string skey;
61
if
(sep != std::string::npos) skey = item.substr(sep+1);
62
63
//item contains a typename OR a CLID. Try the CLID hypothesis first
64
CLID
clid(atoi(typeName.c_str()));
65
//atoi would return 0 if "typeName" is not a stringified number
66
if
( 0 == clid) {
67
//notice that if the typename is not yet in the ClassIDSvc registry the entry will be ignored
68
add
(typeName, skey).ignore();
69
}
else
add
(clid, skey, checkValid,
false
).ignore();
70
}
71
72
StatusCode
73
Folder::add
(
const
std::string& typeName,
const
std::string& skey) {
74
bool
exact =
false
;
75
std::string tn = typeName;
76
if
(tn.size() > 0 && tn[tn.size()-1] ==
'!'
) {
77
exact =
true
;
78
tn.erase (tn.end()-1);
79
}
80
81
CLID
clid;
82
//let's see if the typename is known to ClassIDSvc
83
StatusCode
sc
(
m_pCLIDSvc
->getIDOfTypeName(tn, clid));
84
//if so, add the corresponding clid (no point in checking it again)
85
if
(
sc
.isSuccess())
sc
=
add
(clid, skey,
false
, exact);
86
else
{
87
MsgStream log(msgSvc(), name());
88
log << MSG::ERROR <<
"add: can not find type ["
89
<< typeName <<
"] in clid db"
<<
endmsg
;
90
}
91
return
sc
;
92
}
93
94
StatusCode
95
Folder::add
(
const
CLID
& clid,
const
std::string& skey,
96
bool
checkValid,
bool
exact)
97
{
98
StatusCode
sc
(StatusCode::FAILURE);
99
if
( !checkValid ||
m_pCLIDSvc
->isIDInUse(clid) ) {
100
m_list
.insert(
FolderItem
(clid, skey, exact));
101
sc
= StatusCode::SUCCESS;
102
}
else
if
(0 != clid) {
103
MsgStream log(msgSvc(), name());
104
log << MSG::ERROR <<
"add: can not find clid "
105
<< clid <<
" in clid db"
<<
endmsg
;
106
}
107
#ifdef SGFOLDER_DEBUG
108
std::cout <<
"SG::Folder::add("
<< clid <<
",\""
<< skey <<
"\") returns "
109
<< (
sc
.isSuccess() ?
"SUCCESS"
:
"FAILURE"
) << std::endl;
110
#endif
111
return
sc
;
112
}
endmsg
#define endmsg
Definition
AnalysisConfig_Ntuple.cxx:54
ClassID_traits.h
a traits class that associates a CLID to a type T It also detects whether T inherits from Gaudi DataO...
DefaultKey.h
CLID
uint32_t CLID
The Class ID type.
Definition
Event/xAOD/xAODCore/xAODCore/ClassID_traits.h:47
sc
static Double_t sc
Definition
LArPhysWaveHECTool.cxx:37
SGFolder.h
a run-time configurable list of data objects
Folder::Folder
Folder(const DbConnection &theConnection, const FolderSpec &theFolder)
Definition
MakeReferenceFile.cxx:139
SG::FolderItem
a Folder item (data object) is identified by the clid/key pair
Definition
SGFolderItem.h:24
SG::Folder::add
virtual StatusCode add(const std::string &typeName, const std::string &skey) override
add a data object identifier to the list.
Definition
SGFolder.cxx:73
SG::Folder::updateItemList
virtual void updateItemList(bool checkValidCLID) override final
update contents of the ItemList
Definition
SGFolder.cxx:45
SG::Folder::~Folder
virtual ~Folder() override
Definition
SGFolder.cxx:36
SG::Folder::m_list
ItemList m_list
Definition
SGFolder.h:108
SG::Folder::decodeItem
void decodeItem(const std::string &item, bool checkValidCLID)
Definition
SGFolder.cxx:51
SG::Folder::m_pCLIDSvc
ServiceHandle< IClassIDSvc > m_pCLIDSvc
Definition
SGFolder.h:88
SG::Folder::initialize
virtual StatusCode initialize() override
Definition
SGFolder.cxx:40
SG::Folder::m_itemList
StringArrayProperty m_itemList
Definition
SGFolder.h:92
SG
Forward declaration.
Definition
CaloCellPacker_400_500.h:32
SG::type
Generated on
for ATLAS Offline Software by
1.17.0