diff --git a/Control/AthenaServices/share/AthenaOutputStream_test.ref b/Control/AthenaServices/share/AthenaOutputStream_test.ref index 910343b80e401d184023842e3dafd359153c99c9..ed520a9f8c68bc424d4a9166a7c886c7e54d49de 100644 --- a/Control/AthenaServices/share/AthenaOutputStream_test.ref +++ b/Control/AthenaServices/share/AthenaOutputStream_test.ref @@ -2,7 +2,7 @@ Initializing Gaudi ApplicationMgr using job opts ../share/AthenaOutputStream_test.txt -JobOptionsSvc INFO # =======> /afs/cern.ch/user/s/ssnyder/atlas-work3/Control/AthenaServices/share/../share/AthenaOutputStream_test.txt +JobOptionsSvc INFO # =======> /home/sss/nobackup/atlas/build/../tests/../share/AthenaOutputStream_test.txt JobOptionsSvc INFO # (5,1): MessageSvc.OutputLevel = 2 JobOptionsSvc INFO # (6,1): StoreGateSvc.OutputLevel = 2 JobOptionsSvc INFO # (8,1): AthenaOutputStream.OutputLevel = 1 @@ -12,8 +12,8 @@ JobOptionsSvc INFO Job options successfully read in from ../share/AthenaO ApplicationMgr DEBUG Getting my own properties ApplicationMgr SUCCESS ==================================================================================================================================== - Welcome to ApplicationMgr (GaudiCoreSvc v28r1) - running on lxplus015.cern.ch on Sat Apr 8 17:31:22 2017 + Welcome to ApplicationMgr (GaudiCoreSvc v27r1p99) + running on karma on Fri Aug 11 15:50:39 2017 ==================================================================================================================================== ApplicationMgr INFO Application Manager Configured successfully ServiceManager DEBUG Initializing service AppMgrRunable @@ -35,9 +35,8 @@ ApplicationMgr INFO Application Manager Initialized successfully ApplicationMgr Ready ClassIDSvc DEBUG Service base class initialized successfully IncidentSvc DEBUG Adding [ModuleLoaded] listener 'ClassIDSvc' with priority 100 -ClassIDSvc INFO getRegistryEntries: read 885 CLIDRegistry entries for module ALL -ClassIDSvc DEBUG processCLIDDB: read 1356 entries from CLIDDB file: /afs/cern.ch/user/s/ssnyder/atlas-work3/build-x86_64-slc6-gcc62-dbg/x86_64-slc6-gcc62-dbg/share/clid.db -ClassIDSvc DEBUG processCLIDDB: read 1356 entries from CLIDDB file: /cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2017-04-07T2225/Athena/22.0.0/InstallArea/x86_64-slc6-gcc62-dbg/share/clid.db +ClassIDSvc INFO getRegistryEntries: read 952 CLIDRegistry entries for module ALL +ClassIDSvc DEBUG processCLIDDB: read 1342 entries from CLIDDB file: /home/sss/atlas/rootaccess/build/share/clid.db StoreGateSvc DEBUG Property update for OutputLevel : new value = 2 StoreGateSvc DEBUG Service base class initialized successfully StoreGateSvc DEBUG trying to create store SGImplSvc/StoreGateSvc_Impl @@ -46,7 +45,7 @@ StoreGateSvc_Impl DEBUG Service base class initialized successfully IncidentSvc DEBUG Adding [EndEvent] listener 'StoreGateSvc' with priority 100 IncidentSvc DEBUG Adding [BeginEvent] listener 'StoreGateSvc' with priority 100 ToolSvc DEBUG Service base class initialized successfully -ClassIDSvc INFO getRegistryEntries: read 1986 CLIDRegistry entries for module ALL +ClassIDSvc INFO getRegistryEntries: read 2098 CLIDRegistry entries for module ALL AthenaOutputStream DEBUG Property update for OutputLevel : new value = 1 AthenaOutputStreamVERBOSE ServiceLocatorHelper::service: found service EventDataSvc TimelineSvc DEBUG Service base class initialized successfully @@ -89,19 +88,12 @@ IoComponentMgr DEBUG --> io_hasitem() PoolSvc INFO io_register[PoolSvc](xmlcatalog_file:PoolFileCatalog.xml) [ok] PoolSvc INFO Set connectionsvc retry/timeout/IDLE timeout to 'ConnectionRetrialPeriod':300/ 'ConnectionRetrialTimeOut':3600/ 'ConnectionTimeOut':5 seconds with connection cleanup disabled PoolSvc INFO Frontier compression level set to 5 -DBReplicaSvc INFO Frontier server at (serverurl=http://atlasfrontier-ai.cern.ch:8000/atlr)(serverurl=http://aiatlas036.cern.ch:8000/atlr)(serverurl=http://aiatlas034.cern.ch:8000/atlr)(serverurl=http://ccfrontier.in2p3.fr:23128/ccin2p3-AtlasFrontier)(serverurl=http://ccfrontier01.in2p3.fr:23128/ccin2p3-AtlasFrontier)(serverurl=http://ccfrontier05.in2p3.fr:23128/ccin2p3-AtlasFrontier)(proxyurl=http://ca-proxy.cern.ch:3128)(proxyurl=http://ca20.cern.ch:3128)(proxyurl=http://ca17.cern.ch:3128)(proxyurl=http://atlast0fsquid.cern.ch:3128)(proxyurl=http://atlassquid1.cern.ch:3128)(proxyurl=http://atlassquid2.cern.ch:3128)(proxyurl=http://atlassquid4.cern.ch:3128) will be considered for COOL data -DBReplicaSvc INFO Read replica configuration from /cvmfs/atlas-nightlies.cern.ch/repo/sw/master/2017-04-07T2225/Athena/22.0.0/InstallArea/x86_64-slc6-gcc62-dbg/share/dbreplica.config -DBReplicaSvc DEBUG Candidate server ATLF (priority -2700) -DBReplicaSvc DEBUG Candidate server ATLAS_COOLPROD (priority -695) -DBReplicaSvc DEBUG Candidate server atlas_dd (priority -690) -DBReplicaSvc DEBUG Candidate server ATLAS_CONFIG (priority -685) -DBReplicaSvc DEBUG Candidate server INT8R (priority -680) -DBReplicaSvc DEBUG Candidate server INTR (priority -675) -DBReplicaSvc DEBUG Candidate server ATONR_COOL (priority -670) -DBReplicaSvc DEBUG Candidate server ATONR_CONF (priority -665) -DBReplicaSvc DEBUG Candidate server DEVDB11 (priority -660) -DBReplicaSvc DEBUG Candidate server ATLF (priority -2200) -DBReplicaSvc INFO Total of 10 servers found for host lxplus015.cern.ch [ATLF ATLAS_COOLPROD atlas_dd ATLAS_CONFIG INT8R INTR ATONR_COOL ATONR_CONF DEVDB11 ATLF ] +DBReplicaSvc DEBUG HOSTNAME has no domain - try hostname --fqdn +DBReplicaSvc DEBUG HOSTNAME from fqdn: karma +DBReplicaSvc INFO Read replica configuration from /home/sss/atlas/rootaccess/build/share/dbreplica.config +DBReplicaSvc INFO No specific match for domain found - use default fallback +DBReplicaSvc DEBUG Candidate server atlas_dd (priority 5) +DBReplicaSvc INFO Total of 1 servers found for host karma [atlas_dd ] PoolSvc INFO Successfully setup replica sorting algorithm PoolSvc DEBUG OutputLevel is 2 PoolSvc INFO Setting up APR FileCatalog and Streams @@ -137,6 +129,7 @@ IoComponentMgr DEBUG --> io_register(AthenaOutputStream,W,DidNotNameOutput. IoComponentMgr DEBUG --> io_hasitem() AthenaOutputStream INFO I/O reinitialization... IncidentSvc DEBUG Adding [MetaDataStop] listener 'AthenaOutputStream' with priority 50 +IncidentSvc DEBUG Adding [UpdateOutputFile] listener 'AthenaOutputStream' with priority 50 AthenaOutputStream DEBUG End initialize AthenaOutputStreamVERBOSE ServiceLocatorHelper::service: found service AlgExecStateSvc AlgExecStateSvc DEBUG preInit: will add Alg AthenaOutputStream later @@ -145,24 +138,24 @@ AthenaOutputStream DEBUG output handles: 0 AthenaOutputStream DEBUG Registering all Tools in ToolHandleArray HelperTools AthenaOutputStream DEBUG Adding private ToolHandle tool AthenaOutputStream.AthenaOutputStreamTool (AthenaOutputStreamTool) AthenaOutputStream DEBUG Data Deps for AthenaOutputStream -ClassIDSvc INFO getRegistryEntries: read 824 CLIDRegistry entries for module ALL -StoreGateSvc_Impl DEBUG Recorded object @0x3014b60 with key uno of type Foo(CLID 8101) - in DataObject @0x3014a70 +ClassIDSvc INFO getRegistryEntries: read 1025 CLIDRegistry entries for module ALL +StoreGateSvc_Impl DEBUG Recorded object @0x26b8970 with key uno of type Foo(CLID 8101) + in DataObject @0x26b89b0 object modifiable when retrieved -StoreGateSvc_Impl DEBUG Recorded object @0x2578000 with key due of type Foo(CLID 8101) - in DataObject @0x3015190 +StoreGateSvc_Impl DEBUG Recorded object @0x1b93440 with key due of type Foo(CLID 8101) + in DataObject @0x1bc8e50 object modifiable when retrieved -StoreGateSvc_Impl DEBUG Recorded object @0x3014fa0 with key uno of type Bar(CLID 8107) - in DataObject @0x256cf80 +StoreGateSvc_Impl DEBUG Recorded object @0x1ba2d60 with key uno of type Bar(CLID 8107) + in DataObject @0x1b7d340 object modifiable when retrieved -StoreGateSvc_Impl DEBUG Recorded object @0x3014f80 with key due of type Bar(CLID 8107) - in DataObject @0x25789e0 +StoreGateSvc_Impl DEBUG Recorded object @0x1b7f410 with key due of type Bar(CLID 8107) + in DataObject @0x26d0a60 object modifiable when retrieved -StoreGateSvc_Impl DEBUG Recorded object @0x3013ef0 with key quattro of type Bar(CLID 8107) - in DataObject @0x3015cb0 +StoreGateSvc_Impl DEBUG Recorded object @0x26b8e50 with key quattro of type Bar(CLID 8107) + in DataObject @0x26d1010 object modifiable when retrieved -StoreGateSvc_Impl DEBUG Recorded object @0x251ebb0 with key cinque of type Bar(CLID 8107) - in DataObject @0x3016100 +StoreGateSvc_Impl DEBUG Recorded object @0x1d9ff00 with key cinque of type Bar(CLID 8107) + in DataObject @0x26d09a0 object modifiable when retrieved AthenaOutputStr...WARNING add: can not find clid 13 in clid db AthenaOutputStream DEBUG addItemObjects(13,"*") called @@ -243,4 +236,4 @@ AthenaOutputStream DEBUG Added object 8108,"quattro" 8108 cinque 8107 quattro *** AthenaOutputStream_test OK *** -CORAL/Services/ConnectionService Info Deleting the ConnectionPool \ No newline at end of file +CORAL/Services/ConnectionService Info Deleting the ConnectionPool diff --git a/Control/AthenaServices/src/AthenaOutputStream.cxx b/Control/AthenaServices/src/AthenaOutputStream.cxx index c62d7db9fe2844b0f59aedade0e05d799428938c..0e6cf7ce2608e82b2001fe6024521743f37f6f1f 100644 --- a/Control/AthenaServices/src/AthenaOutputStream.cxx +++ b/Control/AthenaServices/src/AthenaOutputStream.cxx @@ -116,11 +116,10 @@ namespace { std::unique_ptr<SG::TransientAddress> AltDataBucket::makeTransientAddress (CLID clid, const SG::DataProxy& oldProxy) { - const SG::TransientAddress& oldTad = *oldProxy.transientAddress(); auto newTad = std::make_unique<SG::TransientAddress> - (clid, oldTad.name()); - newTad->setAlias (oldTad.alias()); - for (CLID tclid : oldTad.transientID()) { + (clid, oldProxy.name()); + newTad->setAlias (oldProxy.alias()); + for (CLID tclid : oldProxy.transientID()) { // Note: this will include derived CLIDs. // Strictly speaking, that's not right; however, filtering them // out can break ElementLinks (for example those used by @@ -163,8 +162,10 @@ AthenaOutputStream::AthenaOutputStream(const string& name, ISvcLocator* pSvcLoca declareProperty("MetadataStore", m_metadataStore); declareProperty("ProcessingTag", m_processTag=name); declareProperty("ForceRead", m_forceRead=false); - declareProperty("PersToPers", m_persToPers=false); - declareProperty("ExemptPersToPers", m_exemptPersToPers); + // pers-to-pers option not used, and not currently working. + //declareProperty("PersToPers", m_persToPers=false); + //declareProperty("ExemptPersToPers", m_exemptPersToPers); + m_persToPers = false; declareProperty("ProvideDef", m_provideDef=false); declareProperty("ExtendProvenanceRecord", m_extendProvenanceRecord=true); declareProperty("WriteOnExecute", m_writeOnExecute=true); @@ -577,13 +578,13 @@ void AthenaOutputStream::addItemObjects(const SG::FolderItem& item) this->tokenizeAtSep( keyTokens, item_key, wildCard ); ATH_MSG_VERBOSE("Done calling tokenizeAtStep( " << keyTokens << ", " << item_key << ", " << wildCard << ")" ); //std::pair<std::string, std::string> key = breakAtSep(item_key, wildCard); - SG::TransientAddress* tAddr = nullptr; // Now loop over any found proxies for (; iter != end; ++iter) { SG::DataProxy* itemProxy(iter->second); // Does this key match the proxy key name - allow for wildcarding and aliases - bool keyMatch = (item_key == "*" || item_key == itemProxy->name() - || itemProxy->alias().find(item_key) != itemProxy->alias().end()); + bool keyMatch = ( item_key == "*" || + item_key == itemProxy->name() || + itemProxy->hasAlias(item_key) ); if (!keyMatch) { ATH_MSG_VERBOSE("Calling matchKey( " << keyTokens << ", " << itemProxy->name() << ")" ); keyMatch = matchKey(keyTokens, itemProxy); @@ -728,24 +729,30 @@ void AthenaOutputStream::addItemObjects(const SG::FolderItem& item) ATH_MSG_WARNING("Unable to record item " << tns.str() << " in Svc"); } } - } else if (!m_forceRead && m_persToPers && itemProxy->isValid()) { + } +#if 0 + else if (!m_forceRead && m_persToPers && itemProxy->isValid()) { tAddr = itemProxy->transientAddress(); } //if data object there +#endif } else if (keyMatch && xkeyMatch) { removed = true; } } // proxy loop if (!added && !removed) { +#if 0 if (m_persToPers && tAddr != nullptr) { ATH_MSG_DEBUG(" Going to attempt direct persistent copy for " << item.id() << ",\"" << item_key << "\""); DataObject* ics = new DataObject(); SG::DataProxy* proxy = new SG::DataProxy(ics, tAddr); m_objects.push_back(proxy->object()); - } else if (m_provideDef) { + } else +#endif + if (m_provideDef) { ATH_MSG_DEBUG(" Going to attempt providing persistent default for " << item.id() << ",\"" << item_key << "\""); - tAddr = new SG::TransientAddress(item.id(), item_key); + SG::TransientAddress* tAddr = new SG::TransientAddress(item.id(), item_key); DataObject* ics = new DataObject(); SG::DataProxy* proxy = new SG::DataProxy(ics, tAddr); m_objects.push_back(proxy->object()); diff --git a/Control/SGComps/src/AddressRemappingSvc.cxx b/Control/SGComps/src/AddressRemappingSvc.cxx index 90b17cc83e024d635c25d8e5e4a9e7ab13783a4d..60f65d29d77f033917a54c35d9289b059299ea89 100644 --- a/Control/SGComps/src/AddressRemappingSvc.cxx +++ b/Control/SGComps/src/AddressRemappingSvc.cxx @@ -237,7 +237,8 @@ StatusCode AddressRemappingSvc::loadAddresses(StoreID::type /*storeID*/, newIter = m_newTads.begin(), oldIterEnd = m_oldTads.end(); oldIter != oldIterEnd; oldIter++, newIter++) { CLID goodCLID = newIter->clID(); //newIter are the things we are remapping to - SG::TransientAddress::TransientClidSet clidToKeep(oldIter->transientID()); + SG::TransientAddress::TransientClidSet clidvec(oldIter->transientID()); + std::set<CLID> clidToKeep (clidvec.begin(), clidvec.end()); //try dataproxy, if it fails, try data proxy of next type SG::DataProxy* dataProxy(m_proxyDict->proxy(goodCLID,newIter->name()/*the name of the address in the input file*/)); if(dataProxy==0) { diff --git a/Control/SGComps/src/ProxyProviderSvc.cxx b/Control/SGComps/src/ProxyProviderSvc.cxx index d1f52d106a2825c32990e05b67300f62d1098241..925583b5463b2193bd072daf5194467236470eb8 100644 --- a/Control/SGComps/src/ProxyProviderSvc.cxx +++ b/Control/SGComps/src/ProxyProviderSvc.cxx @@ -19,8 +19,6 @@ #include "ProxyProviderSvc.h" -#include "boost/foreach.hpp" - using namespace std; ProxyProviderSvc::ProxyProviderSvc(const std::string& name, @@ -176,9 +174,9 @@ StatusCode ProxyProviderSvc::addAddresses(IProxyRegistry& store, { proxy->setAddress(pTAD->address()); delete pTAD; - pTAD = proxy->transientAddress(); - if (pTAD->provider() == 0) - pTAD->setProvider(provider, store.storeID()); + pTAD = nullptr; + if (proxy->provider() == 0) + proxy->setProvider(provider, store.storeID()); } else { pTAD->setProvider(provider, store.storeID()); if ( 0 == addAddress(store, pTAD) ) return StatusCode::FAILURE; @@ -205,9 +203,8 @@ ProxyProviderSvc::addAddress(IProxyRegistry& store, bool addedProxy(false); // loop over all the transient CLIDs: SG::TransientAddress::TransientClidSet tClid = tAddr->transientID(); - SG::TransientAddress::TransientClidSet::const_iterator tIter = tClid.begin(); - for (; tIter != tClid.end(); tIter++) { - addedProxy |= (store.addToStore(*tIter, dp)).isSuccess(); + for (CLID clid : tClid) { + addedProxy |= (store.addToStore(clid, dp)).isSuccess(); } if (addedProxy) { @@ -219,15 +216,15 @@ ProxyProviderSvc::addAddress(IProxyRegistry& store, // Add any other allowable conversions. const SG::BaseInfoBase* bi = SG::BaseInfoBase::find (tAddr->clID()); if (bi) { - BOOST_FOREACH(CLID clid, bi->get_bases()) { - if (tClid.find (clid) == tClid.end()) { + for (CLID clid : bi->get_bases()) { + if (std::find (tClid.begin(), tClid.end(), clid) == tClid.end()) { store.addToStore (clid, dp).ignore(); tAddr->setTransientID (clid); } } - BOOST_FOREACH(CLID clid, bi->get_copy_conversions()) { - if (tClid.find (clid) == tClid.end()) { + for (CLID clid : bi->get_copy_conversions()) { + if (std::find (tClid.begin(), tClid.end(), clid) == tClid.end()) { store.addToStore (clid, dp).ignore(); tAddr->setTransientID (clid); } diff --git a/Control/SGComps/src/SGInputLoader.cxx b/Control/SGComps/src/SGInputLoader.cxx index 944367a8300409e2bd08e1a03bd070eb7b8c7a78..3e5c44744b35c9fda8f9744c9b9c7730057b226b 100644 --- a/Control/SGComps/src/SGInputLoader.cxx +++ b/Control/SGComps/src/SGInputLoader.cxx @@ -158,7 +158,7 @@ SGInputLoader::loadObjs(const DataObjIDColl& objs) const { SG::DataProxy* dp = evtStore()->proxy(obj.clid(), vhk.key()); if (dp != 0) { ATH_MSG_DEBUG(" found proxy for " << obj); - if (dp->transientAddress()->provider() == 0) { + if (dp->provider() == 0) { ATH_MSG_DEBUG(" obj " << obj << " has no provider, and is only Transient" ); } @@ -171,7 +171,7 @@ SGInputLoader::loadObjs(const DataObjIDColl& objs) const { } // ... and linked classes. - for (CLID clid2 : dp->transientAddress()->transientID()) { + for (CLID clid2 : dp->transientID()) { if (clid2 != obj.clid()) evtStore()->addedNewTransObject(clid2, vhk.key()); } diff --git a/Control/SGComps/test/AddressRemappingSvc_test.cxx b/Control/SGComps/test/AddressRemappingSvc_test.cxx index 0b15c79552c1a9f36b8412b4a11903a4f53de2f3..c7b2a0debfc30e36a69262ec9cd24bf3b2a03410 100644 --- a/Control/SGComps/test/AddressRemappingSvc_test.cxx +++ b/Control/SGComps/test/AddressRemappingSvc_test.cxx @@ -114,7 +114,7 @@ void checkTADList (const IAddressProvider::tadList& tads, assert (tad->address() == &addrs.addr2); assert (tad->clearAddress() == false); assert (tad->transientID() == - (SG::TransientAddress::TransientClidSet { fooclid, 321 })); + (SG::TransientAddress::TransientClidSet { 321, fooclid })); assert (tad->alias() == (SG::TransientAddress::TransientAliasSet { "bar2.d1", "bar2.d2", diff --git a/Control/SGComps/test/ProxyProviderSvc_test.cxx b/Control/SGComps/test/ProxyProviderSvc_test.cxx index 807caaa882f609fbea9d4b290ecc19ccec8e97ba..b50ca5aafc6e48b069521af3a1b7d71e0187bf58 100644 --- a/Control/SGComps/test/ProxyProviderSvc_test.cxx +++ b/Control/SGComps/test/ProxyProviderSvc_test.cxx @@ -108,7 +108,6 @@ public: const std::string& /*key*/) const override { return nullptr; } - std::vector<SG::TransientAddress> tads; std::vector<std::unique_ptr<SG::DataProxy> > proxies; }; @@ -116,8 +115,7 @@ public: StatusCode TestProxyRegistry::addToStore (const CLID& /*id*/, SG::DataProxy* proxy) { - tads.emplace_back (*proxy->transientAddress()); - proxies.push_back (std::unique_ptr<SG::DataProxy> (proxy)); + proxies.emplace_back (proxy); return StatusCode::SUCCESS; } @@ -128,23 +126,23 @@ TestProvider providers[NPROVIDERS]; void checkStore (const TestProxyRegistry& store) { - assert (store.tads.size() == 3); + assert (store.proxies.size() == 3); assert (providers[0].tListLen == 0); assert (providers[1].tListLen == 0); assert (providers[2].tListLen == 2); assert (providers[3].tListLen == 2); - assert (store.tads[0].clID() == 10); - assert (store.tads[0].name() == "x1"); - assert (store.tads[0].provider() == &providers[1]); + assert (store.proxies[0]->clID() == 10); + assert (store.proxies[0]->name() == "x1"); + assert (store.proxies[0]->provider() == &providers[1]); - assert (store.tads[1].clID() == 11); - assert (store.tads[1].name() == "x2"); - assert (store.tads[1].provider() == &providers[1]); + assert (store.proxies[1]->clID() == 11); + assert (store.proxies[1]->name() == "x2"); + assert (store.proxies[1]->provider() == &providers[1]); - assert (store.tads[2].clID() == 12); - assert (store.tads[2].name() == "y1"); - assert (store.tads[2].provider() == &providers[3]); + assert (store.proxies[2]->clID() == 12); + assert (store.proxies[2]->name() == "y1"); + assert (store.proxies[2]->provider() == &providers[3]); } @@ -166,7 +164,7 @@ void test1 (IProxyProviderSvc& svc) for (TestProvider& p : providers) p.tListLen = -1; - store.tads.clear(); + store.proxies.clear(); assert (svc.loadProxies (store).isSuccess()); checkStore (store); diff --git a/Control/SGTools/SGTools/DataProxy.h b/Control/SGTools/SGTools/DataProxy.h index 8f0e2b57f04e01ccbf1daf580b6483a7ed629eee..917ddc93ba6412ea85fc84311340d6930703051e 100755 --- a/Control/SGTools/SGTools/DataProxy.h +++ b/Control/SGTools/SGTools/DataProxy.h @@ -48,15 +48,22 @@ namespace SG { typedef std::string id_type; typedef TransientAddress::TransientClidSet CLIDCont_t; typedef TransientAddress::TransientAliasSet AliasCont_t; + typedef IStringPool::sgkey_t sgkey_t; // Constructors DataProxy(); // default constructor ///build from TransientAddress + ///Takes ownership of tAddr. DataProxy(TransientAddress* tAddr, IConverter* pDataLoader, bool constFlag=false, bool resetOnly=true); + ///build from TransientAddress + DataProxy(std::unique_ptr<TransientAddress> tAddr, + IConverter* pDataLoader, + bool constFlag=false, bool resetOnly=true); + ///build from DataObject DataProxy(DataObject* dObject, TransientAddress* tAddr, @@ -68,39 +75,77 @@ namespace SG { ///\name IRegistry implementation //@{ /// Add reference to object - virtual unsigned long addRef(); + virtual unsigned long addRef() override; /// release reference to object - virtual unsigned long release(); + virtual unsigned long release() override; /// return refCount unsigned long refCount() const; /// Retrieve data object key == string - virtual const name_type& name() const { return m_tAddress->name(); } + virtual const name_type& name() const override; /// Retrieve data object key == string /// duplicated for Gaudi folks does same as name() - virtual const id_type& identifier() const {return m_tAddress->name();} + virtual const id_type& identifier() const override; /// Retrieve DataObject - virtual DataObject* object() const { return m_dObject; } + virtual DataObject* object() const override; /// set an IOpaqueAddress - virtual void setAddress(IOpaqueAddress* ioa); + virtual void setAddress(IOpaqueAddress* ioa) override; /// Retrieve IOpaqueAddress - virtual IOpaqueAddress* address() const { return m_tAddress->address(); } + virtual IOpaqueAddress* address() const override; /// set DataSvc (Gaudi-specific); do nothing for us - virtual IDataProviderSvc* dataSvc() const { return 0; } + virtual IDataProviderSvc* dataSvc() const override; //@} /// Retrieve TransientAddress - virtual TransientAddress* transientAddress() const { return m_tAddress; } + TransientAddress* transientAddress() const; + + ///< Get the primary (hashed) SG key. + sgkey_t sgkey() const; + + ///< Set the primary (hashed) SG key. + void setSGKey (sgkey_t sgkey); + + ///< Return the ID of the store containing this proxy. + StoreID::type storeID() const; + + ///< check if it is a transient ID (primary or symLinked): + bool transientID (CLID id) const; + + ///< return the list of transient IDs (primary or symLinked): + CLIDCont_t transientID() const; + + /// Add a new transient ID + void setTransientID(CLID id); /// access set of proxy aliases - const AliasCont_t& alias() const { return m_tAddress->alias(); } + /// Returns a COPY of the alias set. + AliasCont_t alias() const; + + /// Test to see if a given string is in the alias set. + bool hasAlias (const std::string& key) const; + + /// Add a new proxy alias. + void setAlias(const std::string& key); + + /// remove alias from proxy + bool removeAlias(const std::string& key); + + /// Return the address provider. + IAddressProvider* provider(); + + /// Set the address provider. + void setProvider(IAddressProvider* provider, StoreID::type storeID); + + /// Set the CLID / key. + /// This will only succeed if the clid/key are currently clear. + void setID (CLID id, const std::string& key); /// Other methods of DataProxy (not in Interface IRegistry): @@ -108,8 +153,8 @@ namespace SG { /// If HARD is true, then the bound objects should also /// clear any data that depends on the identity /// of the current event store. (See IResetable.h.) - virtual void reset (bool hard = false); - virtual void finalReset(); ///called by destructor + void reset (bool hard = false); + void finalReset(); ///called by destructor /// release or reset according to resetOnly flag /// If FORCE is true, then always release. @@ -125,6 +170,8 @@ namespace SG { /// is the object valid? bool isValidObject() const; + bool updateAddress(); + /// set DataObject void setObject(DataObject* obj); @@ -145,16 +192,16 @@ namespace SG { */ std::unique_ptr<DataObject> readData (ErrNo* errNo) const; - ErrNo errNo() const { return m_errno; } + ErrNo errNo() const; /// Retrieve clid - CLID clID() const { return m_tAddress->clID(); } + CLID clID() const; /// Retrieve storage type - unsigned char svcType() const { return m_storageType; } + unsigned char svcType() const; /// Check if it is a const object - bool isConst() const { return m_const; } + bool isConst() const; /** @@ -167,17 +214,14 @@ namespace SG { /// set the reset only flag: Clear Store will reset and not delete. - void resetOnly(const bool& flag) { m_resetFlag = flag; } + void resetOnly(const bool& flag); /// Check reset only: - bool isResetOnly() const { return m_resetFlag; } + bool isResetOnly() const; bool bindHandle(IResetable* ir); void unbindHandle(IResetable* ir); - /// The following kept temporarily for backward compatibility: - const CLIDCont_t& transientID() const {return m_tAddress->transientID();} - // cache the t2p void setT2p(T2pMap* t2p); @@ -187,13 +231,13 @@ namespace SG { * * (@c IRegisterTransient interface.) */ - virtual void registerTransient (void* p); + virtual void registerTransient (void* p) override; /// Set the store of which we're a part. - void setStore (IProxyDict* store) { m_store = store; } + void setStore (IProxyDict* store); /// Return the store of which we're a part. - IProxyDict* store() const { return m_store; } + IProxyDict* store() const; /// reset the bound DataHandles /// If HARD is true, then the bound objects should also @@ -201,13 +245,13 @@ namespace SG { /// of the current event store. (See IResetable.h.) void resetBoundHandles (bool hard); - IConverter* loader() const { return m_dataLoader; } + IConverter* loader() const; private: - DataProxy(const DataProxy&); - DataProxy& operator=(const DataProxy&); + DataProxy(const DataProxy&) = delete; + DataProxy& operator=(const DataProxy&) = delete; - TransientAddress* m_tAddress; + std::unique_ptr<TransientAddress> m_tAddress; unsigned long m_refCount; @@ -256,19 +300,11 @@ namespace SG { ///const pointer version of the cast template<typename DATA> - const DATA* DataProxy_cast(const DataProxy* proxy) - { - return DataProxy_cast<DATA>(const_cast<DataProxy*>(proxy)); - } + const DATA* DataProxy_cast(const DataProxy* proxy); ///const ref version of the cast. @throws SG::ExcBadDataProxyCast. template<typename DATA> - DATA DataProxy_cast(const DataProxy& proxy) - { - const DATA* result = DataProxy_cast<DATA>(&proxy); - if (!result) SG::throwExcBadDataProxyCast(proxy.clID(), typeid(DATA)); - return *result; - } + DATA DataProxy_cast(const DataProxy& proxy); /** * @brief Try to get the pointer back from a @a DataProxy, diff --git a/Control/SGTools/SGTools/DataProxy.icc b/Control/SGTools/SGTools/DataProxy.icc index a75ae4bbc1a4312ec7e0ec3f29d8b004f2f990f2..4050fc7aaa6466fbb2bc0a95444ceaa4ac9554da 100755 --- a/Control/SGTools/SGTools/DataProxy.icc +++ b/Control/SGTools/SGTools/DataProxy.icc @@ -23,6 +23,232 @@ class DataObject; + +/// Retrieve data object key == string +inline +const SG::DataProxy::name_type& SG::DataProxy::name() const +{ + return m_tAddress->name(); +} + + +/// Retrieve data object key == string +/// duplicated for Gaudi folks does same as name() +inline +const SG::DataProxy::id_type& SG::DataProxy::identifier() const +{ + return m_tAddress->name(); +} + + +/// Retrieve DataObject +inline +DataObject* SG::DataProxy::object() const +{ + return m_dObject; +} + + +/// Retrieve IOpaqueAddress +inline +IOpaqueAddress* SG::DataProxy::address() const +{ + return m_tAddress->address(); +} + + +/// set DataSvc (Gaudi-specific); do nothing for us +inline +IDataProviderSvc* SG::DataProxy::dataSvc() const +{ + return nullptr; +} + +/// Retrieve TransientAddress +inline +SG::TransientAddress* SG::DataProxy::transientAddress() const +{ + return m_tAddress.get(); +} + +///< Get the primary (hashed) SG key. +inline +SG::sgkey_t SG::DataProxy::sgkey() const +{ + return m_tAddress->sgkey(); +} + + +/// Set the primary (hashed) SG key. +inline +void SG::DataProxy::setSGKey (sgkey_t sgkey) +{ + m_tAddress->setSGKey (sgkey); +} + + +///< Return the ID of the store containing this proxy. +inline +StoreID::type SG::DataProxy::storeID() const +{ + return m_tAddress->storeID(); +} + + +///< check if it is a transient ID (primary or symLinked): +inline +bool SG::DataProxy::transientID (CLID id) const +{ + return m_tAddress->transientID (id); +} + + +///< return the list of transient IDs (primary or symLinked): +inline +SG::DataProxy::CLIDCont_t SG::DataProxy::transientID() const +{ + return m_tAddress->transientID(); +} + + +/// Add a new transient ID +inline +void SG::DataProxy::setTransientID(CLID id) +{ + m_tAddress->setTransientID (id); +} + + +/// access set of proxy aliases +/// Returns a COPY of the alias set. +inline +SG::DataProxy::AliasCont_t SG::DataProxy::alias() const +{ + return m_tAddress->alias(); +} + + +/// Add a new proxy alias. +inline +void SG::DataProxy::setAlias(const std::string& key) +{ + m_tAddress->setAlias (key); +} + + +/// Test to see if a given string is in the alias set. +inline +bool SG::DataProxy::hasAlias(const std::string& key) const +{ + lock_t lock (m_mutex); + const AliasCont_t& alias = m_tAddress->alias(); + return alias.find(key) != alias.end(); +} + + +/// remove alias from proxy +inline +bool SG::DataProxy::removeAlias(const std::string& key) +{ + return m_tAddress->removeAlias (key); +} + + +/// Return the address provider. +inline +IAddressProvider* SG::DataProxy::provider() +{ + return m_tAddress->provider(); +} + + +/// Set the address provider. +inline +void SG::DataProxy::setProvider(IAddressProvider* provider, + StoreID::type storeID) +{ + m_tAddress->setProvider (provider, storeID); +} + + +/// Set the CLID / key. +/// This will only succeed if the clid/key are currently clear. +inline +void SG::DataProxy::setID (CLID id, const std::string& key) +{ + m_tAddress->setID (id, key); +} + + +inline +SG::DataProxy::ErrNo SG::DataProxy::errNo() const +{ + return m_errno; +} + + +/// Retrieve clid +inline +CLID SG::DataProxy::clID() const +{ + return m_tAddress->clID(); +} + + +/// Retrieve storage type +inline +unsigned char SG::DataProxy::svcType() const +{ + return m_storageType; +} + + +/// Check if it is a const object +inline +bool SG::DataProxy::isConst() const +{ + return m_const; +} + + +/// set the reset only flag: Clear Store will reset and not delete. +inline +void SG::DataProxy::resetOnly(const bool& flag) +{ + m_resetFlag = flag; +} + + +/// Check reset only: +inline +bool SG::DataProxy::isResetOnly() const +{ + return m_resetFlag; +} + + +/// Set the store of which we're a part. +inline +void SG::DataProxy::setStore (IProxyDict* store) +{ + m_store = store; +} + +/// Return the store of which we're a part. +inline +IProxyDict* SG::DataProxy::store() const +{ + return m_store; +} + + +inline +IConverter* SG::DataProxy::loader() const +{ + return m_dataLoader; +} + + template <typename DATA> DATA* SG::DataProxy_cast(SG::DataProxy* proxy) { DATA* result(0); @@ -95,3 +321,20 @@ DATA* SG::DataProxy_cast(SG::DataProxy* proxy) { } +///const pointer version of the cast +template<typename DATA> +const DATA* SG::DataProxy_cast(const SG::DataProxy* proxy) +{ + return SG::DataProxy_cast<DATA>(const_cast<SG::DataProxy*>(proxy)); +} + + +///const ref version of the cast. @throws SG::ExcBadDataProxyCast. +template<typename DATA> +DATA SG::DataProxy_cast(const SG::DataProxy& proxy) +{ + const DATA* result = SG::DataProxy_cast<DATA>(&proxy); + if (!result) SG::throwExcBadDataProxyCast(proxy.clID(), typeid(DATA)); + return *result; +} + diff --git a/Control/SGTools/SGTools/TransientAddress.h b/Control/SGTools/SGTools/TransientAddress.h index ebae14f1710f466a053668bda1df14f9ca54870a..f865007a6da5113a0ec879c0f21ad9e809773f1c 100755 --- a/Control/SGTools/SGTools/TransientAddress.h +++ b/Control/SGTools/SGTools/TransientAddress.h @@ -8,6 +8,8 @@ ///< includes: #include <string> #include <set> +#include <vector> +#include <algorithm> ///< Gaudi includes: @@ -28,7 +30,10 @@ namespace SG { public: - typedef std::set<CLID> TransientClidSet; + /// Strictly a set, but there shouldn't be more than a handful + /// of entries, so store it as a sorted vector instead. + typedef std::vector<CLID> TransientClidSet; + typedef std::set<std::string> TransientAliasSet; typedef IStringPool::sgkey_t sgkey_t; @@ -71,10 +76,10 @@ namespace SG { void setSGKey (sgkey_t sgkey); ///< check if it is a transient ID (primary or symLinked): - bool transientID (const CLID& id) const; + bool transientID (CLID id) const; ///< set transient CLID's - void setTransientID(const CLID& id); + void setTransientID(CLID id); ///< get transient CLID's const TransientClidSet& transientID() const; @@ -85,6 +90,9 @@ namespace SG { ///< set alias' void setAlias(const std::set<std::string>& keys); + ///< set alias' + void setAlias(std::set<std::string>&& keys); + /// remove alias from proxy bool removeAlias(const std::string& key); @@ -102,7 +110,9 @@ namespace SG { void consultProvider(const bool& flag); ///< Check the validity of the Transient Address. - bool isValid (IProxyDict* store); + /// If forceUpdate is true, then call @c updateAddress + /// even if we already have an address. + bool isValid (IProxyDict* store, bool forceUpdate = false); ///< cache the pointer to the Address provider which can update ///< this transient address @@ -199,16 +209,10 @@ namespace SG { /// check if it is a transient ID: inline - bool TransientAddress::transientID(const CLID& id) const - { - return 0 != m_transientID.count(id); - } - - /// set transient CLID's - inline - void TransientAddress::setTransientID(const CLID& id) - { - m_transientID.insert(id); + bool TransientAddress::transientID(CLID id) const + { + return std::find (m_transientID.begin(), m_transientID.end(), id) != + m_transientID.end(); } /// get transient CLID's @@ -232,6 +236,13 @@ namespace SG { m_transientAlias = keys; } + /// set transient Alias' + inline + void TransientAddress::setAlias(std::set<std::string>&& keys) + { + m_transientAlias = std::move(keys); + } + /// remove alias inline bool TransientAddress::removeAlias(const std::string& key) { diff --git a/Control/SGTools/src/DataProxy.cxx b/Control/SGTools/src/DataProxy.cxx index dbd973a4ae14a9ebc3b1369057306e7c4e2c0289..697819346881cbc76e9929c839a696b593596f93 100755 --- a/Control/SGTools/src/DataProxy.cxx +++ b/Control/SGTools/src/DataProxy.cxx @@ -104,9 +104,19 @@ DataProxy::DataProxy(): // DataProxy constructor with Transient Address // (typically called from Proxy Provider) DataProxy::DataProxy(TransientAddress* tAddr, + IConverter* svc, + bool constFlag, bool resetOnly) + : DataProxy (std::unique_ptr<TransientAddress> (tAddr), + svc, constFlag, resetOnly) +{ +} + +// DataProxy constructor with Transient Address +// (typically called from Proxy Provider) +DataProxy::DataProxy(std::unique_ptr<TransientAddress> tAddr, IConverter* svc, bool constFlag, bool resetOnly): - m_tAddress(tAddr), + m_tAddress(std::move(tAddr)), m_refCount(0), m_dObject(0), m_dataLoader(svc), @@ -146,7 +156,6 @@ DataProxy::DataProxy(DataObject* dObject, DataProxy::~DataProxy() { finalReset(); - delete m_tAddress; } void DataProxy::setT2p(T2pMap* t2p) @@ -440,6 +449,11 @@ bool DataProxy::isValid() const } +bool DataProxy::updateAddress() +{ + return m_tAddress->isValid(m_store, true); +} + /** * @brief Try to get the pointer back from a @a DataProxy, * converted to be of type @a clid. diff --git a/Control/SGTools/src/TestStore.cxx b/Control/SGTools/src/TestStore.cxx index 590a17a540a35d645ed615ee7afc0f90edad6e29..554aba4834b0a0dee844a72de838920d73233486 100644 --- a/Control/SGTools/src/TestStore.cxx +++ b/Control/SGTools/src/TestStore.cxx @@ -89,14 +89,14 @@ SG::DataProxy* TestStore::recordObject (SG::DataObjectSharedPtr<DataObject> obj, // Alias? m_kmap[sgkey] = proxy; proxy->addRef(); - proxy->transientAddress()->setAlias (key); + proxy->setAlias (key); return proxy; } if (key == proxy->name()) { // Symlink? m_kmap[sgkey] = proxy; proxy->addRef(); - proxy->transientAddress()->setTransientID (obj->clID()); + proxy->setTransientID (obj->clID()); return proxy; } @@ -183,7 +183,7 @@ bool TestStore::tryELRemap (sgkey_t sgkey_in, size_t index_in, StatusCode TestStore::addToStore (CLID /*id*/, SG::DataProxy* proxy) { proxy->setStore (this); - m_kmap[proxy->transientAddress()->sgkey()] = proxy; + m_kmap[proxy->sgkey()] = proxy; proxy->addRef(); return StatusCode::SUCCESS; } @@ -211,8 +211,8 @@ SG::DataProxy* TestStore::record1 (const void* p, DataObject* obj, if (m_kmap.find (sgkey) != m_kmap.end()) { SG::DataProxy* dp = m_kmap[sgkey]; dp->setObject (obj); - if (dp->transientAddress()->clID() == CLID_NULL) - dp->transientAddress()->setID (clid, key); + if (dp->clID() == CLID_NULL) + dp->setID (clid, key); m_tmap[p] = dp; return dp; } @@ -243,7 +243,7 @@ void TestStore::alias (SG::DataProxy* proxy, sgkey_t sgkey = stringToKey (newKey, proxy->clID()); m_kmap[sgkey] = proxy; proxy->addRef(); - proxy->transientAddress()->setAlias (newKey); + proxy->setAlias (newKey); } diff --git a/Control/SGTools/src/TransientAddress.cxx b/Control/SGTools/src/TransientAddress.cxx index 8930e1b23141ecb5505b2e47c0d81192263b9d96..9800394f6e14ba1893a74cfebff1a46f9b7d4033 100755 --- a/Control/SGTools/src/TransientAddress.cxx +++ b/Control/SGTools/src/TransientAddress.cxx @@ -29,7 +29,7 @@ TransientAddress::TransientAddress(const CLID& id, const std::string& key) m_sgkey(0) { if (id != CLID_NULL) - m_transientID.insert(id); + m_transientID.push_back(id); } // Constructor with CLID, string key and IOpaqueAddress: @@ -42,7 +42,7 @@ TransientAddress::TransientAddress(const CLID& id, const std::string& key, m_sgkey(0) { if (id != CLID_NULL) - m_transientID.insert(id); + m_transientID.push_back(id); setAddress(addr); } @@ -53,6 +53,19 @@ TransientAddress::~TransientAddress() } +/// set transient CLID's +void TransientAddress::setTransientID(CLID id) +{ + if (m_transientID.empty()) { + m_transientID.push_back (id); + } + else if (!transientID (id)) { + m_transientID.push_back (id); + std::sort (m_transientID.begin(), m_transientID.end()); + } +} + + /** * @brief Set the CLID / key. * @param id The new CLID. @@ -67,7 +80,7 @@ void TransientAddress::setID (CLID id, const std::string& key) m_clid = id; m_name = key; if (id != CLID_NULL) - m_transientID.insert(id); + m_transientID.push_back(id); } /// set IOpaqueAddress @@ -78,9 +91,10 @@ void TransientAddress::setAddress(IOpaqueAddress* pAddress) m_address = pAddress; } -bool TransientAddress::isValid(IProxyDict* store) +bool TransientAddress::isValid(IProxyDict* store, + bool forceUpdate /*= false*/) { - if (0 != address()) return true; + if (!forceUpdate && 0 != address()) return true; // FIXME CGL // if (!m_consultProvider) { diff --git a/Control/SGTools/test/DataStore_test.cxx b/Control/SGTools/test/DataStore_test.cxx index b2ff7978a00a4b18968d2299efbee7c0f5710cc9..fc5ca4be7b1f5598976aefaf9f5f08795c8d7814 100644 --- a/Control/SGTools/test/DataStore_test.cxx +++ b/Control/SGTools/test/DataStore_test.cxx @@ -35,10 +35,15 @@ public: }; -SG::DataProxy* make_proxy (CLID clid, const std::string& name) +SG::DataProxy* make_proxy (CLID clid, + const std::string& name, + SG::sgkey_t sgkey = 0) { - SG::TransientAddress* tad = new SG::TransientAddress (clid, name); - return new SG::DataProxy (tad, static_cast<IConverter*>(nullptr)); + auto tad = std::make_unique<SG::TransientAddress> (clid, name); + if (sgkey) { + tad->setSGKey (sgkey); + } + return new SG::DataProxy (std::move(tad), static_cast<IConverter*>(nullptr)); } @@ -67,7 +72,7 @@ void test_addToStore() assert (store.addToStore (123, dp1).isSuccess()); assert (dp1->store() == &pool); assert (dp1->refCount() == 1); - assert (dp1->transientAddress()->sgkey() == sgkey); + assert (dp1->sgkey() == sgkey); assert (store.proxy_exact (sgkey) == dp1); assert (store.proxy (123, "dp1") == dp1); @@ -81,7 +86,7 @@ void test_addToStore() SG::StringPool::sgkey_t sgkey2b = pool.stringToKey ("dp2", 124); assert (store.proxy_exact (sgkey2b) == dp2); assert (store.proxy_exact (sgkey2a) == 0); - assert (dp2->transientAddress()->sgkey() == sgkey2a); + assert (dp2->sgkey() == sgkey2a); } @@ -102,19 +107,19 @@ void test_addAlias() assert (store.proxy (123, "dp1a") == dp1); assert (store.proxy_exact (pool.stringToKey ("dp1a", 123)) == dp1); - assert (dp1->transientAddress()->alias().count ("dp1a") == 1); + assert (dp1->alias().count ("dp1a") == 1); SG::DataProxy* dp2 = make_proxy (123, "dp2"); assert (store.addToStore (123, dp2).isSuccess()); assert (store.addAlias ("dpx", dp2).isSuccess()); assert (dp2->refCount() == 2); - assert (dp2->transientAddress()->alias().count ("dpx") == 1); + assert (dp2->alias().count ("dpx") == 1); assert (store.addAlias ("dpx", dp1).isSuccess()); assert (dp1->refCount() == 4); assert (dp2->refCount() == 1); - assert (dp2->transientAddress()->alias().count ("dpx") == 0); - assert (dp1->transientAddress()->alias().count ("dpx") == 1); + assert (dp2->alias().count ("dpx") == 0); + assert (dp1->alias().count ("dpx") == 1); assert (store.addAlias ("dpx", dp1).isSuccess()); assert (dp1->refCount() == 4); assert (dp2->refCount() == 1); @@ -134,8 +139,8 @@ void test_addSymLink() assert (store.proxy_exact (123, "dp1") == dp1); assert (store.proxy_exact (124, "dp1") == dp1); - assert (dp1->transientAddress()->transientID(123)); - assert (dp1->transientAddress()->transientID(124)); + assert (dp1->transientID(123)); + assert (dp1->transientID(124)); assert (store.addSymLink (124, dp1).isSuccess()); assert (store.proxy_exact (124, "dp1") == dp1); @@ -143,7 +148,7 @@ void test_addSymLink() SG::DataProxy* dp2 = make_proxy (125, "dp1"); assert (store.addToStore (125, dp2).isSuccess()); assert (store.addSymLink (125, dp1).isFailure()); - assert (!dp1->transientAddress()->transientID(125)); + assert (!dp1->transientID(125)); } @@ -347,7 +352,7 @@ void test_keys() assert (store.addToStore (125, dp3).isSuccess()); assert (store.addToStore (125, dp4).isSuccess()); TestProvider prov; - dp4->transientAddress()->setProvider (&prov, StoreID::SPARE_STORE); + dp4->setProvider (&prov, StoreID::SPARE_STORE); store.keys (125, v, true, false); assert (v.size() == 2); @@ -486,8 +491,7 @@ void test_dummy() SG::StringPool::sgkey_t sgkey = pool.stringToKey ("dp1", 456); - SG::DataProxy* dp1 = make_proxy (0, ""); - dp1->transientAddress()->setSGKey (sgkey); + SG::DataProxy* dp1 = make_proxy (0, "", sgkey); assert (store.addToStore (0, dp1).isSuccess()); assert (dp1->refCount() == 1); assert (store.proxy_exact (sgkey) == dp1); @@ -498,8 +502,7 @@ void test_dummy() assert (dp1->refCount() == 1); SG::StringPool::sgkey_t sgkey2 = pool.stringToKey ("dp2", 456); - SG::DataProxy* dp2 = make_proxy (0, ""); - dp2->transientAddress()->setSGKey (sgkey2); + SG::DataProxy* dp2 = make_proxy (0, "", sgkey2); assert (store.addToStore (0, dp2).isSuccess()); assert (dp2->refCount() == 1); assert (store.proxy_exact (sgkey2) == dp2); diff --git a/Control/SGTools/test/TransientAddress_test.cxx b/Control/SGTools/test/TransientAddress_test.cxx index 3634ab015d6c2aff80486511cd97d4f3380dae08..a74cfcf874a621ba560ad5a346a2708ada458b4d 100644 --- a/Control/SGTools/test/TransientAddress_test.cxx +++ b/Control/SGTools/test/TransientAddress_test.cxx @@ -116,9 +116,14 @@ void test1() tad2.setAlias ("key2"); assert (tad2.alias().size() == 1); std::set<std::string> a; - a.insert ("key3"); - a.insert ("key4"); - tad2.setAlias (a); + a.insert ("key3a"); + a.insert ("key4a"); + tad2.setAlias (std::move(a)); + assert (a.size() == 0); + assert (tad2.alias().size() == 2); + assert (tad2.alias().count ("key2") == 0); + assert (tad2.alias().count ("key3a") == 1); + tad2.setAlias (std::set<std::string> {"key3", "key4"}); assert (tad2.alias().size() == 2); assert (tad2.alias().count ("key2") == 0); assert (tad2.alias().count ("key3") == 1); diff --git a/Database/PersistentDataModel/PersistentDataModel/DataHeader.h b/Database/PersistentDataModel/PersistentDataModel/DataHeader.h index 1a70e8fd63cf4b98da48e7ce364d298e58054d9d..6d9d2077ce80aa90ddb97514363d13ad151a5629 100755 --- a/Database/PersistentDataModel/PersistentDataModel/DataHeader.h +++ b/Database/PersistentDataModel/PersistentDataModel/DataHeader.h @@ -22,6 +22,7 @@ class IOpaqueAddress; namespace SG { class TransientAddress; + class DataProxy; } namespace coral { class AttributeList; @@ -37,10 +38,17 @@ public: // Constructor and Destructor DataHeaderElement(); /// Copy Constructor DataHeaderElement(const DataHeaderElement& rhs); + /// Constructor /// @param sgAddress [IN] pointer to TransientAddress for which a DataHeaderElement is created. /// @param pTag [IN] string used as key element in DataHeader (SG key for DataObjects). DataHeaderElement(const SG::TransientAddress* sgAddress, IOpaqueAddress* tokAddress, const std::string& pTag); + + /// Constructor + /// @param proxy [IN] pointer to DataProxy for which a DataHeaderElement is created. + /// @param pTag [IN] string used as key element in DataHeader (SG key for DataObjects). + DataHeaderElement(const SG::DataProxy* proxy, IOpaqueAddress* tokAddress, const std::string& pTag); + /// Constructor /// @param classID [IN] Primary ClassID of the DataObject for which a DataHeaderElement is created. /// @param key [IN] SG Key of the DataObject for which a DataHeaderElement is created. @@ -82,6 +90,14 @@ private: friend class DataHeaderElementCnv_p5; friend class DataHeaderElementCnv_p6; + /// Internal constructor. + DataHeaderElement(CLID clid, + const std::string& name, + const std::vector<CLID>& tClids, + std::set<std::string>&& alias, + IOpaqueAddress* tadAddress, + IOpaqueAddress* tokAddress, const std::string& pTag); + /// primary ClassID. CLID m_pClid; /// set of unsigned long to store ClassID's for symlinked container. @@ -144,6 +160,10 @@ public: // Non-static members /// @param pTag [IN] string to overwrite key meber of the DataHeaderElement void insert(const SG::TransientAddress* sgAddress, IOpaqueAddress* tokAddress = 0, const std::string& pTag = ""); /// Insert a new element into the "DataObject" vector. + /// @param proxy [IN] pointer to the DataProxy for the DataObject. + /// @param pTag [IN] string to overwrite key meber of the DataHeaderElement + void insert(const SG::DataProxy* proxy, IOpaqueAddress* tokAddress = 0, const std::string& pTag = ""); + /// Insert a new element into the "DataObject" vector. /// @param dhe [IN] reference to the DataHeaderElement to be inserted. void insert(const DataHeaderElement& dhe); diff --git a/Database/PersistentDataModel/src/DataHeader.cxx b/Database/PersistentDataModel/src/DataHeader.cxx index 6e9643f030374d28c9ea8817849b2324e979a88d..1e99e4ddfa5586999eeb1d5d01e77c6a0fe213c1 100755 --- a/Database/PersistentDataModel/src/DataHeader.cxx +++ b/Database/PersistentDataModel/src/DataHeader.cxx @@ -11,6 +11,7 @@ #include "PersistentDataModel/TokenAddress.h" #include "SGTools/TransientAddress.h" +#include "SGTools/DataProxy.h" #include "AthenaKernel/IStringPool.h" //______________________________________________________________________________ @@ -30,34 +31,58 @@ DataHeaderElement::DataHeaderElement(const DataHeaderElement& rhs) : m_pClid(rhs } //______________________________________________________________________________ DataHeaderElement::DataHeaderElement(const SG::TransientAddress* sgAddress, IOpaqueAddress* tokAddress, - const std::string& pTag) : m_pClid(0), m_clids(), m_key(), m_alias(), m_token(0), m_ownToken(false), m_hashes() { - if (sgAddress != 0) { - m_pClid = sgAddress->clID(); - std::set<CLID> tClids = sgAddress->transientID(); - std::set<CLID>::iterator lastClid = m_clids.begin(); - for (std::set<CLID>::const_iterator iter = tClids.begin(), last = tClids.end(); - iter != last; iter++) { - lastClid = m_clids.insert(lastClid, *iter); - } - m_clids.erase(m_pClid); - m_key = (pTag.empty()) ? sgAddress->name() : pTag; - m_alias = sgAddress->alias(); - TokenAddress* tokAddr = dynamic_cast<TokenAddress*>(tokAddress); - if (tokAddr != 0 && tokAddr->getToken() != 0) { - m_token = new Token(tokAddr->getToken()); m_ownToken = true; - } else { - tokAddr = dynamic_cast<TokenAddress*>(sgAddress->address()); - if (tokAddr != 0 && tokAddr->getToken() != 0) { - m_token = tokAddr->getToken(); - } else if (tokAddress != 0) { - m_token = new Token; m_ownToken = true; - const_cast<Token*>(m_token)->fromString(*(tokAddress->par())); - } else if (sgAddress->address() != 0) { - m_token = new Token; m_ownToken = true; - const_cast<Token*>(m_token)->fromString(*(sgAddress->address()->par())); - } - } - } + const std::string& pTag) + : DataHeaderElement (sgAddress->clID(), + sgAddress->name(), + sgAddress->transientID(), + SG::DataProxy::AliasCont_t (sgAddress->alias()), + sgAddress->address(), + tokAddress, pTag) +{ +} +//______________________________________________________________________________ +DataHeaderElement::DataHeaderElement(const SG::DataProxy* proxy, IOpaqueAddress* tokAddress, + const std::string& pTag) + : DataHeaderElement (proxy->clID(), + proxy->name(), + proxy->transientID(), + proxy->alias(), + proxy->address(), + tokAddress, pTag) +{ +} +//______________________________________________________________________________ +DataHeaderElement::DataHeaderElement(CLID clid, + const std::string& name, + const std::vector<CLID>& tClids, + std::set<std::string>&& alias, + IOpaqueAddress* tadAddress, + IOpaqueAddress* tokAddress, + const std::string& pTag) + : m_pClid(clid), + m_clids(tClids.begin(), tClids.end()), + m_key((pTag.empty()) ? name : pTag), + m_alias(std::move(alias)), + m_token(0), m_ownToken(false), m_hashes() +{ + m_clids.erase(m_pClid); + TokenAddress* tokAddr = dynamic_cast<TokenAddress*>(tokAddress); + if (tokAddr != 0 && tokAddr->getToken() != 0) { + m_token = new Token(tokAddr->getToken()); m_ownToken = true; + } else { + tokAddr = dynamic_cast<TokenAddress*>(tadAddress); + if (tokAddr != 0 && tokAddr->getToken() != 0) { + m_token = tokAddr->getToken(); + } else if (tokAddress != 0) { + Token* token = new Token; + m_token = token; m_ownToken = true; + token->fromString(*(tokAddress->par())); + } else if (tadAddress != 0) { + Token* token = new Token; + m_token = token; m_ownToken = true; + token->fromString(*(tadAddress->par())); + } + } } //______________________________________________________________________________ DataHeaderElement::DataHeaderElement(const CLID classID, @@ -93,14 +118,9 @@ CLID DataHeaderElement::getPrimaryClassID() const { } //______________________________________________________________________________ const std::set<CLID> DataHeaderElement::getClassIDs() const { - std::set<CLID> allClids; - std::set<CLID>::iterator lastClid = allClids.begin(); - for (std::set<CLID>::const_iterator iter = m_clids.begin(), last = m_clids.end(); - iter != last; iter++) { - lastClid = allClids.insert(lastClid, *iter); - } - allClids.insert(m_pClid); - return(allClids); + std::set<CLID> allClids (m_clids); + allClids.insert(m_pClid); + return(allClids); } //______________________________________________________________________________ const std::string& DataHeaderElement::getKey() const { @@ -227,11 +247,14 @@ const std::vector<DataHeaderElement>& DataHeader::elements() const { //______________________________________________________________________________ void DataHeader::insert(const SG::TransientAddress* sgAddress, IOpaqueAddress* tokAddress, const std::string& pTag) { if (sgAddress != 0) { - DataHeaderElement dhElement(sgAddress, tokAddress, pTag); - m_dataHeader.push_back(dhElement); + m_dataHeader.emplace_back(sgAddress, tokAddress, pTag); } } //______________________________________________________________________________ +void DataHeader::insert(const SG::DataProxy* proxy, IOpaqueAddress* tokAddress, const std::string& pTag) { + m_dataHeader.emplace_back(proxy, tokAddress, pTag); +} +//______________________________________________________________________________ void DataHeader::insert(const DataHeaderElement& dhe) { m_dataHeader.push_back(dhe); }