36 StringProperty containerPrefixProp(
"PoolContainerPrefix",
"CollectionTree");
37 StringProperty containerNameHintProp(
"TopLevelContainerName",
"");
38 StringProperty branchNameHintProp(
"SubLevelBranchName",
"<type>/<key>");
40 propertyServer->getProperty(&containerPrefixProp).ignore();
41 propertyServer->getProperty(&containerNameHintProp).ignore();
42 propertyServer->getProperty(&branchNameHintProp).ignore();
47 return StatusCode::SUCCESS;
55 return(::Converter::finalize());
65 bool ownTokAddr =
false;
66 if (tokAddr ==
nullptr || tokAddr->
getToken() ==
nullptr) {
68 auto token = std::make_unique<Token>();
69 token->fromString(*(pAddr->par()));
70 GenericAddress* genAddr =
dynamic_cast<GenericAddress*
>(pAddr);
74 return StatusCode::FAILURE;
80 const std::string contextStr = std::format(
"[CTXT={:08X}]",
static_cast<int>(*(pAddr->ipar())));
81 std::strncpy(text, contextStr.c_str(),
sizeof(text) - 1);
82 text[
sizeof(text) - 1] =
'\0';
90 std::string key = pAddr->par()[1];
95 }
catch (std::exception& e) {
99 if (pObj ==
nullptr) {
103 delete tokAddr; tokAddr =
nullptr;
106 if (pObj ==
nullptr) {
107 return StatusCode::FAILURE;
109 return StatusCode::SUCCESS;
114 if (proxy ==
nullptr) {
115 ATH_MSG_ERROR(
"AthenaPoolConverter CreateRep failed to cast DataProxy, key = " << pObj->name());
116 return StatusCode::FAILURE;
122 return StatusCode::FAILURE;
124 }
catch (std::exception& e) {
126 return StatusCode::FAILURE;
129 if (pAddr ==
nullptr) {
131 pAddr =
new TokenAddress(this->
storageType(), clid,
"",
"", 0, 0);
133 GenericAddress* gAddr =
dynamic_cast<GenericAddress*
>(pAddr);
134 if (gAddr !=
nullptr) {
138 return StatusCode::SUCCESS;
146 return StatusCode::FAILURE;
148 }
catch (std::exception& e) {
149 ATH_MSG_ERROR(
"fillRepRefs - caught exception: " << e.what());
150 return StatusCode::FAILURE;
152 return StatusCode::SUCCESS;
162 ::
AthMessaging((pSvcLocator != nullptr ? msgSvc() : nullptr),
163 name ? name :
"AthenaPoolConverter"),
164 m_detStore(
"DetectorStore", name ? name :
"AthenaPoolConverter"),
165 m_athenaPoolCnvSvc(pSvcLocator && pSvcLocator->existsService(
"AthenaPoolSharedIOCnvSvc") ?
"AthenaPoolSharedIOCnvSvc" :
"AthenaPoolCnvSvc", name ? name :
"AthenaPoolConverter"),
179 std::string::size_type pos1 = output.find(
'[');
180 std::string outputConnectionSpec = output.substr(0, pos1);
187 if( containerPrefix ==
"Default" ) {
191 std::string containerName;
194 std::size_t colonPos = containerPrefix.find(
':');
195 if (colonPos != std::string::npos) {
196 dhContainerPrefix = containerPrefix.substr(0, colonPos + 1) + dhContainerPrefix;
202 std::string containerFriendPostfix;
203 while (pos1 != std::string::npos) {
204 const std::string::size_type pos2 = output.find(
'=', pos1);
205 const std::string thisKey = output.substr(pos1 + 1, pos2 - pos1 - 1);
206 const std::string::size_type pos3 = output.find(
']', pos2);
207 const std::string value = output.substr(pos2 + 1, pos3 - pos2 - 1);
208 if (thisKey ==
"OutputCollection") {
209 dhContainerPrefix = std::move(value);
210 }
else if (thisKey ==
"PoolContainerPrefix") {
211 containerPrefix = std::move(value);
212 }
else if (thisKey ==
"TopLevelContainerName") {
213 containerNameHint = std::move(value);
214 }
else if (thisKey ==
"SubLevelBranchName") {
215 branchNameHint = std::move(value);
216 }
else if (thisKey ==
"PoolContainerFriendPostfix") {
217 containerFriendPostfix = std::move(value);
219 pos1 = output.find(
'[', pos3);
223 if( tname.compare(0, 10,
"DataHeader") == 0 ) {
224 if( tname.compare(10, 4,
"Form") == 0 ) {
225 containerName = dhContainerPrefix +
"Form" +
"(" + tname +
")";
227 if (key[key.size() - 1] ==
'/') {
228 containerName = dhContainerPrefix +
"(" + key + tname +
")";
230 containerName = dhContainerPrefix +
"(" + tname +
")";
235 else if (tname.compare(0, 13,
"AttributeList") == 0) {
248 const std::string typeTok =
"<type>", keyTok =
"<key>";
249 containerName = containerPrefix + containerFriendPostfix + containerNameHint;
250 if (!branchNameHint.empty()) {
251 containerName +=
"(" + branchNameHint +
")";
253 const std::size_t pos1 = containerName.find(typeTok);
254 if (pos1 != std::string::npos) {
255 containerName.replace(pos1, typeTok.size(), tname);
257 const std::size_t pos2 = containerName.find(keyTok);
258 if (pos2 != std::string::npos) {
260 containerName.replace(pos2, keyTok.size(), tname);
262 containerName.replace(pos2, keyTok.size(), key);
281 ATH_MSG_DEBUG(
"AthenaPoolConverter cleanUp called for base class.");
282 return StatusCode::SUCCESS;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
This file contains the class definition for the AthenaPoolConverter class.
uint32_t CLID
The Class ID type.
This file contains the class definition for the Guid class (migrated from POOL).
This file contains the class definition for the IAthenaPoolCnvSvc interface class.
This file contains the class definition for the Placement class (migrated from POOL).
This file contains the class definition for the TokenAddress class.
This file contains the class definition for the Token class (migrated from POOL).
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
virtual StatusCode initialize() override
Gaudi Service Interface method implementations:
ServiceHandle< StoreGateSvc > m_detStore
virtual ~AthenaPoolConverter()
Destructor.
ServiceHandle< IAthenaPoolCnvSvc > m_athenaPoolCnvSvc
std::string m_branchNameHint
virtual Placement setPlacementWithType(const std::string &tname, const std::string &key, const std::string &output)
Set POOL placement hint for a given type.
virtual long repSvcType() const override
virtual StatusCode PoolToDataObject(DataObject *&pObj, const Token *token, const std::string &key)=0
Read an object from POOL.
const Token * m_i_poolToken
virtual const DataObject * getDataObject() const
bool compareClassGuid(const Guid &guid) const
std::string m_containerNameHint
virtual StatusCode DataObjectToPool(IOpaqueAddress *pAddr, DataObject *pObj)=0
Write an object into POOL.
virtual StatusCode DataObjectToPers(DataObject *pObj, IOpaqueAddress *&pAddr)=0
Convert an object into Persistent.
AthenaPoolConverter(const CLID &id, ISvcLocator *pSvcLocator, const char *name=nullptr)
Standard Service Constructor.
virtual StatusCode fillRepRefs(IOpaqueAddress *pAddr, DataObject *pObj) override
Create a POOL persistent representation for a transient object.
const DataObject * m_dataObject
virtual StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&pObj) override
Create a transient object from a POOL persistent representation.
virtual StatusCode cleanUp(const std::string &output) override
Implement cleanUp for AthenaPoolConverter to do nothing.
virtual StatusCode createRep(DataObject *pObj, IOpaqueAddress *&pAddr) override
Create a POOL persistent representation for a transient object.
static long storageType()
virtual StatusCode finalize() override
std::string m_containerPrefix
This class provides a encapsulation of a GUID/UUID/CLSID/IID data structure (128 bit number).
This class holds all the necessary information to guide the writing of an object in a physical place.
Placement & setContainerName(const std::string &containerName)
Set container name.
Placement & setFileName(const std::string &fileName)
Set file name.
Placement & setTechnology(int technology)
Set technology type.
This class provides a Generic Transient Address for POOL tokens.
const std::string & auxString() const
Access auxiliary string.
Token & setAuxString(const std::string &auxString)
Set auxiliary string.
virtual const std::string toString() const
Retrieve the string representation of the token.
static const DbType ROOTTREE_StorageType
static const DbType ROOTRNTUPLE_StorageType
static const DbType POOL_StorageType
static constexpr const char * EventData
static constexpr const char * EventTag
static constexpr const char * DataHeader
static constexpr const char * DataHeader
static constexpr const char * EventTag
static constexpr const char * EventData