ATLAS Offline Software
Loading...
Searching...
No Matches
SG::Folder Class Reference

a run-time configurable list of data objects More...

#include <SGFolder.h>

Inheritance diagram for SG::Folder:
Collaboration diagram for SG::Folder:

structors

typedef IFolder::ItemList ItemList
 the list we manage
 Folder (const std::string &type, const std::string &name, const IInterface *parent)
virtual ~Folder () override

access the ItemList

typedef IFolder::const_iterator const_iterator
virtual const_iterator begin () const override
virtual const_iterator end () const override
virtual StatusCode add (const std::string &typeName, const std::string &skey) override
 add a data object identifier to the list.
virtual StatusCode add (const CLID &clid, const std::string &skey) override
 add a data object identifier to the list.
virtual void clear () override
 clear the folder contents
virtual void updateItemList (bool checkValidCLID) override final
 update contents of the ItemList

AlgTool boilerplate

ServiceHandle< IClassIDSvc > m_pCLIDSvc
BooleanProperty m_checkItems {this, "CheckItems", false, "check if item types are known to ClassIDSvc"}
StringArrayProperty m_itemList
ItemList m_list
class Folder_tester
virtual StatusCode initialize () override
void decodeItemList (Gaudi::Details::PropertyBase &)
void decodeItem (const std::string &item, bool checkValidCLID)
StatusCode add (const CLID &clid, const std::string &skey, bool checkValidCLID, bool exact)
 add a data object identifier to the list, optionally checking if the clid is known to ClassIDSvc.

Detailed Description

a run-time configurable list of data objects

the ItemList property, used to initialize the folder, is a list of class name (or clid)/key pairs. One can use '*' as key value to add all objects of a given type to the Folder. Examples:

ItemList = [ "DataHeader#*", "AthenaAttributeList#SimpleTag", "8101/Foo" ]
IFolder::ItemList ItemList
the list we manage
Definition SGFolder.h:54

Normally, an object will be written as the type as which it was recorded in StoreGate, regardless of the type used to request it in the ItemList. But if the type name ends with a !, then the object will be written as the exact type which was requested in the ItemList.

Definition at line 42 of file SGFolder.h.

Member Typedef Documentation

◆ const_iterator

Definition at line 58 of file SGFolder.h.

◆ ItemList

the list we manage

Definition at line 54 of file SGFolder.h.

Constructor & Destructor Documentation

◆ Folder()

Folder::Folder ( const std::string & type,
const std::string & name,
const IInterface * parent )

Definition at line 27 of file SGFolder.cxx.

29 :
30 base_class( type, name, parent ),
31 m_pCLIDSvc("ClassIDSvc", name)
32{
33}
ServiceHandle< IClassIDSvc > m_pCLIDSvc
Definition SGFolder.h:88

◆ ~Folder()

Folder::~Folder ( )
overridevirtual

Definition at line 36 of file SGFolder.cxx.

37{}

Member Function Documentation

◆ add() [1/3]

virtual StatusCode SG::Folder::add ( const CLID & clid,
const std::string & skey )
inlineoverridevirtual

add a data object identifier to the list.

The clid is not checked against the ClassIDSvc registry

Definition at line 69 of file SGFolder.h.

69 {
70 const bool DONTCHECKVALIDCLID(false);
71 return add(clid, skey, DONTCHECKVALIDCLID, false);
72 }
virtual StatusCode add(const std::string &typeName, const std::string &skey) override
add a data object identifier to the list.
Definition SGFolder.cxx:73

◆ add() [2/3]

StatusCode Folder::add ( const CLID & clid,
const std::string & skey,
bool checkValidCLID,
bool exact )
private

add a data object identifier to the list, optionally checking if the clid is known to ClassIDSvc.

Definition at line 95 of file SGFolder.cxx.

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}
#define endmsg
static Double_t sc
ItemList m_list
Definition SGFolder.h:108
::StatusCode StatusCode
StatusCode definition for legacy code.
msgSvc
Provide convenience handles for various services.
Definition StdJOSetup.py:36

◆ add() [3/3]

StatusCode Folder::add ( const std::string & typeName,
const std::string & skey )
overridevirtual

add a data object identifier to the list.

Notice that if the typename is not yet in the ClassIDSvc registry the entry will be ignored and and add will return StatusCode::FAILURE

Definition at line 73 of file SGFolder.cxx.

73 {
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}
uint32_t CLID
The Class ID type.

◆ begin()

virtual const_iterator SG::Folder::begin ( ) const
inlineoverridevirtual

Definition at line 59 of file SGFolder.h.

59{ return m_list.begin(); }

◆ clear()

virtual void SG::Folder::clear ( )
inlineoverridevirtual

clear the folder contents

Definition at line 75 of file SGFolder.h.

75{ m_list.clear(); }

◆ decodeItem()

void Folder::decodeItem ( const std::string & item,
bool checkValidCLID )
private

Definition at line 51 of file SGFolder.cxx.

51 {
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}
int atoi(std::string_view str)
Helper functions to unpack numbers decoded in string into integers and doubles The strings are requir...

◆ decodeItemList()

void SG::Folder::decodeItemList ( Gaudi::Details::PropertyBase & )
inlineprivate

Definition at line 97 of file SGFolder.h.

97 {
98 const bool DONTCHECKVALIDCLID(false);
99 Folder::updateItemList(DONTCHECKVALIDCLID);
100 }
virtual void updateItemList(bool checkValidCLID) override final
update contents of the ItemList
Definition SGFolder.cxx:45

◆ end()

virtual const_iterator SG::Folder::end ( ) const
inlineoverridevirtual

Definition at line 60 of file SGFolder.h.

60{ return m_list.end(); }

◆ initialize()

StatusCode Folder::initialize ( )
overridevirtual

Definition at line 40 of file SGFolder.cxx.

40 {
41 return m_pCLIDSvc.retrieve();
42}

◆ updateItemList()

void Folder::updateItemList ( bool checkValidCLID)
finaloverridevirtual

update contents of the ItemList

Definition at line 45 of file SGFolder.cxx.

45 {
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}
void decodeItem(const std::string &item, bool checkValidCLID)
Definition SGFolder.cxx:51
StringArrayProperty m_itemList
Definition SGFolder.h:92

◆ Folder_tester

friend class Folder_tester
friend

Definition at line 102 of file SGFolder.h.

Member Data Documentation

◆ m_checkItems

BooleanProperty SG::Folder::m_checkItems {this, "CheckItems", false, "check if item types are known to ClassIDSvc"}
private

Definition at line 90 of file SGFolder.h.

90{this, "CheckItems", false, "check if item types are known to ClassIDSvc"};

◆ m_itemList

StringArrayProperty SG::Folder::m_itemList
private
Initial value:
{this, "ItemList", {}, &Folder::decodeItemList,
"List of data objects identified by a class name (or clid)#key pairs. One can use '*' as key value to "
"add all objects of a given type to the Folder. If the type name ends with !, then write the object as "
"exactly that type (and not as any derived class)."}
void decodeItemList(Gaudi::Details::PropertyBase &)
Definition SGFolder.h:97

Definition at line 92 of file SGFolder.h.

92 {this, "ItemList", {}, &Folder::decodeItemList,
93 "List of data objects identified by a class name (or clid)#key pairs. One can use '*' as key value to "
94 "add all objects of a given type to the Folder. If the type name ends with !, then write the object as "
95 "exactly that type (and not as any derived class)."};

◆ m_list

ItemList SG::Folder::m_list
private

Definition at line 108 of file SGFolder.h.

◆ m_pCLIDSvc

ServiceHandle<IClassIDSvc> SG::Folder::m_pCLIDSvc
private

Definition at line 88 of file SGFolder.h.


The documentation for this class was generated from the following files: