Commits

ca...@4525493e-7705-40b1-a816-d608a930855b  committed bb156bf

tag 00-00-01. Still very unstable: see ChangeLog for details

  • Participants
  • Parent commits 4af4a32

Comments (0)

Files changed (11)

File AthenaKernel/IAddressProvider.h

-/***************************************************************************
- interface for IAO providers
+/** interface for IOA providers
  ---------------------------
  ATLAS Collaboration
+
+/// $Id: IAddressProvider.h,v 1.2 2002-12-04 22:56:04 calaf Exp $
  ***************************************************************************/
 
-// $Id: IAddressProvider.h,v 1.1.1.1 2002-11-27 23:35:04 calaf Exp $
-
-#ifndef PROXYPROVIDER_IADDRESSPROVIDER_H
-# define PROXYPROVIDER_IADDRESSPROVIDER_H
+#ifndef ATHENAKERNEL_IADDRESSPROVIDER_H
+# define ATHENAKERNEL_IADDRESSPROVIDER_H
 
 //<<<<<< INCLUDES                                                       >>>>>>
 #include <list>
 #include "GaudiKernel/StatusCode.h"
 
+//<<<<<< FORWARD DECLARATIONS                                           >>>>>>
 class IOpaqueAddress;
+class TransientID;
 
 //<<<<<< CLASS DECLARATIONS                                             >>>>>>
-//FIXME can't forward-declare tdef// class TransientID;
-#include "AthenaKernel/TransientID.h"
-
 class IAddressProvider {
 public:
   typedef std::list<IOpaqueAddress*> IOAList;
   virtual StatusCode declareAddresses(IOAListIterator& firstIOA, 
 				      IOAListIterator& endIOA)=0;
   ///get a specific address, plus all others  the provider wants to load in SG maps
-  virtual StatusCode declareAddresses(const TransientID& key,  
-				      IOAListIterator& firstIOA, 
-				      IOAListIterator& endIOA)=0;
-
-  // SR: add retrieveAddress() for distniguishing loading proxies
-  // SR: at beginning of job vs loading proxies on demand.
-
+  virtual StatusCode getAddresses(const TransientID& key,  
+				  IOAListIterator& firstIOA, 
+				  IOAListIterator& endIOA)=0;
+  virtual ~IAddressProvider() {}
 };
 
 //<<<<<< INLINE PUBLIC FUNCTIONS                                        >>>>>>
 //<<<<<< INLINE MEMBER FUNCTIONS                                        >>>>>>
 
-#endif // PROXYPROVIDER_IADDRESSPROVIDER_H
+#endif // ATHENAKERNEL_IADDRESSPROVIDER_H

File AthenaKernel/IAddressRegistry.h

-/***************************************************************************
- an IOA registry
- --------------------
- ATLAS Collaboration
- ***************************************************************************/
-
-// $Id: IAddressRegistry.h,v 1.1.1.1 2002-11-27 23:35:04 calaf Exp $
-
-#ifndef ATHENAKERNEL_IADDRESSREGISTRY_H
-# define ATHENAKERNEL_IADDRESSREGISTRY_H
-
-//<<<<<< INCLUDES                                                       >>>>>>
-#include "GaudiKernel/StatusCode.h"
-
-//<<<<<< CLASS DECLARATIONS                                             >>>>>>
-class IOpaqueAddress;
-class DataProxy;
-//FIXME can't forward-declare tdef// class TransientID;
-#include "AthenaKernel/TransientID.h"
-
-// Would like DataStore to sub-class from IAddressRegistry.
-
-class IAddressRegistry {
-public:
-  /// add address to store: create Proxy which owns the address
-  // SR: would just add Proxy, not IOA. DataStore knows nothing 
-  // SR: about IOA. ProxyProviderSvc creates the DataProxy.
-  // SR: recordAddress is moved from StoreGateSvc to ProxyProviderSvc.
-  // SR: and so would locatePersistent and all that stuff.
-
-  virtual StatusCode recordAddress(IOpaqueAddress* pIOA,
-				   bool isResetOnly=true)=0;
-  // SR: Would change TransientID to CLID, key to match DataStore
-  // SR: interface. TransientID then would be only behind the scenes.
-
-  virtual DataProxy* getProxy(const TransientID& id) const =0;
-
-  // SR: Removing IOpaqueAddress from this class and only having DataProxy
-  // SR: implies the class name should reflect this better: IProxyRegistry.
-
-};
-#endif // ATHENAKERNEL_IADDRESSREGISTRY_H
-
-
-

File AthenaKernel/IAlgContextSvc.h

  ATLAS Collaboration
  ***************************************************************************/
 
-// $Id: IAlgContextSvc.h,v 1.1.1.1 2002-11-27 23:35:04 calaf Exp $
+// $Id: IAlgContextSvc.h,v 1.2 2002-12-04 22:56:04 calaf Exp $
 
 #ifndef ATHENAKERNEL_IALGCONTEXTSVC_H
 # define ATHENAKERNEL_IALGCONTEXTSVC_H
 class IAlgContextSvc : virtual public IInterface {
 public:
   /// current algorithm accessors
+  //@{
   virtual void setCurrentAlg(IAlgorithm* pAlg)=0;
   virtual IAlgorithm* currentAlg()=0;
+  //@}
 
   static const InterfaceID& interfaceID();
+
+  virtual ~IAlgContextSvc() {}
 };
 
 //<<<<<< INLINE MEMBER FUNCTIONS                                        >>>>>>

File AthenaKernel/IAtRndmGenSvc.h

   * @author Paolo Calafiura <pcalafiura@lbl.gov> 
   */
 
-// $Id: IAtRndmGenSvc.h,v 1.1.1.1 2002-11-27 23:35:04 calaf Exp $
+// $Id: IAtRndmGenSvc.h,v 1.2 2002-12-04 22:56:04 calaf Exp $
 
 #ifndef ATHENAKERNEL_IATRNDMGENSVC_H
 # define ATHENAKERNEL_IATRNDMGENSVC_H
   //@}
 
   /// Gaudi boilerplate
-  static const InterfaceID& interfaceID() {
-    static const InterfaceID _IID("IAtRndmGenSvc", 1, 0);
-    return _IID;
-  }
+  static const InterfaceID& interfaceID();
+  
+  virtual ~IAtRndmGenSvc() {}
 };
+inline
+const InterfaceID& 
+IAtRndmGenSvc::interfaceID() {
+  static const InterfaceID _IID("IAtRndmGenSvc", 1, 0);
+  return _IID;
+}
+
 #endif // ATHENAKERNEL_IATRNDMGENSVC_H

File AthenaKernel/IProxyProviderSvc.h

  ATLAS Collaboration
  ***************************************************************************/
 
-// $Id: IProxyProviderSvc.h,v 1.1.1.1 2002-11-27 23:35:04 calaf Exp $
+// $Id: IProxyProviderSvc.h,v 1.2 2002-12-04 22:56:04 calaf Exp $
 
 #ifndef ATHENAKERNEL_IPROXYPROVIDERSVC_H
 # define ATHENAKERNEL_IPROXYPROVIDERSVC_H
 #include "GaudiKernel/StatusCode.h"
 //<<<<<< CLASS DECLARATIONS                                             >>>>>>
 class DataProxy;
-//FIXME can't forward-declare tdef// class TransientID;
-#include "AthenaKernel/TransientID.h"
-class IAddressRegistry; //this is StoreGateSvc
+class TransientID;
+class IOpaqueAddress;
+class IProxyRegistry; //this is the store
 
 class IProxyProviderSvc : virtual public IInterface {
 public:
-  ///add proxies to the store to modify
-  // SR: AddProxies is not necessary, because proxy are created on damand
-  // SR: We may however want an addAddress(IOpaqueAddress*) to allow
-  // SR: client's (converters) to addAddress. This is the equivalent of
-  // SR: converters doing storeGate->recordAddress() today.
+  ///add proxies to the store to modify. (FIXME may not be needed)
+  virtual StatusCode loadProxies(IProxyRegistry& storeToModify) const=0;
+  ///get the default proxy for a given TransientID.
+  /// Optionally add more proxies to the store to modify
+  virtual DataProxy* getProxy(const TransientID& id, 
+			      IProxyRegistry& storeToModify) const=0;
+  ///low-level accessor: get the IOA instead of the proxy. 
+  ///Does not modify any store
+  virtual IOpaqueAddress* getAddress(const TransientID& id) const=0; 
 
-  virtual StatusCode addProxies(IAddressRegistry& storeToModify) const=0;
-  ///get the default proxy. Optionally add proxies to the store to modify
-  virtual DataProxy* getProxy(TransientID& id, IAddressRegistry& storeToModify) const=0;
+  ///create a new Proxy and add it to the registry
+  virtual StatusCode addAddress(IProxyRegistry& storeToModify, 
+				IOpaqueAddress* pIOA) const=0;
+  ///create a new Proxy, overriding CLID and/or key
+  virtual StatusCode addAddress(IProxyRegistry& storeToModify,
+				IOpaqueAddress* pIOA, TransientID& id) const=0;
+
   static const InterfaceID& interfaceID();
+  virtual ~IProxyProviderSvc() {}
 };
 
 //<<<<<< INLINE MEMBER FUNCTIONS                                        >>>>>>
-inline const InterfaceID&
+inline
+const InterfaceID&
 IProxyProviderSvc::interfaceID() {
   static InterfaceID _ID("IProxyProviderSvc", 0 , 0);
   return _ID;

File AthenaKernel/IProxyRegistry.h

+/** a proxy registry
+ --------------------
+ @author Paolo Calafiura - ATLAS
+ ***************************************************************************/
+
+// $Id: IProxyRegistry.h,v 1.1 2002-12-04 22:56:04 calaf Exp $
+
+#ifndef ATHENAKERNEL_IPROXYREGISTRY_H
+# define ATHENAKERNEL_IPROXYREGISTRY_H
+
+//<<<<<< INCLUDES                                                       >>>>>>
+#include "GaudiKernel/StatusCode.h"
+
+//<<<<<< CLASS DECLARATIONS                                             >>>>>>
+class DataProxy;
+class TransientID;
+
+class IProxyRegistry {
+public:
+  /// add proxy to store. 
+  virtual StatusCode addProxy(DataProxy* proxy)=0;
+  /// get proxy with given id. Returns 0 to flag failure
+  virtual DataProxy* proxy(const TransientID& id) const=0;
+
+  virtual ~IProxyRegistry() {}
+};
+#endif // ATHENAKERNEL_IPROXYREGISTRY_H
+
+
+

File AthenaKernel/TransientID.h

-/***************************************************************************
- the transient (StoreGate) identifier of a dobj: the pair (CLID, key)
+/** the transient (StoreGate) identifier of a dobj: the pair (CLID, key)
  --------------------------------------------------
  ATLAS Collaboration
  ***************************************************************************/
 
-// $Id: TransientID.h,v 1.1.1.1 2002-11-27 23:35:04 calaf Exp $
+// $Id: TransientID.h,v 1.2 2002-12-04 22:56:04 calaf Exp $
 
 #ifndef ATHENAKERNEL_TRANSIENTID_H
 # define ATHENAKERNEL_TRANSIENTID_H
 
 //<<<<<< INCLUDES                                                       >>>>>>
+#include <functional>  /*unary_function*/
 #include <string>
-#include <utility> /*pair*/
 #include "GaudiKernel/ClassID.h"
-#include "GaudiKernel/IOpaqueAddress.h"
+
+//<<<<<< FORWARD DECLARATIONS                                           >>>>>>
+class IOpaqueAddress;
 
 //<<<<<< CLASS DECLARATIONS                                             >>>>>>
 
-typedef std::pair<CLID, std::string> TransientID; 
+struct TransientID {
+public:
+  typedef std::string key_type;
 
+  TransientID():
+    m_id(0), m_key(std::string()) {}
+  explicit TransientID(const TransientID& rhs) : 
+    m_id(rhs.m_id), m_key(rhs.m_key) {}
+
+  explicit TransientID(const IOpaqueAddress& IOA);
+
+  explicit TransientID(const CLID& id) : 
+    m_id(id), m_key(std::string()) {}
+  
+  TransientID(const CLID& id, const std::string& skey) : 
+    m_id(id), m_key(skey) {}
+  
+  ///access the transient CLID
+  const CLID& clID() const { return m_id; }
+  ///access the string-ified key
+  const key_type& key() const { return m_key; }
+  ///is the ID referring to the default object of given CLID?
+  bool isDefault() const {return m_key.empty();}
+
+private:
+  ///the transient CLID
+  CLID m_id;
+  ///the string-ified key
+  std::string m_key;
+};
+
+/** a STL predicate to compare TransientIDs to IOAs */
+class CompareTransientIDToIOA : public std::unary_function<IOpaqueAddress*, bool> {
+public:
+  CompareTransientIDToIOA(const TransientID& id): m_id(id) {}
+  bool operator()(const IOpaqueAddress* pIOA);    
+private:
+  TransientID m_id;
+};
+
+//<<<<<< PUBLIC FUNCTION DEFINITIONS                                    >>>>>>
 inline
-bool operator ==(const TransientID& id, const IOpaqueAddress& IOA) {
-  return (id.first == IOA.clID() && id.second == IOA.par()[0]);
+bool operator ==(const TransientID& lhs, const TransientID& rhs) {
+  return ((rhs.clID() == lhs.clID()) && (rhs.key() == lhs.key()));
 }
-inline
-bool operator ==(const IOpaqueAddress& IOA, const TransientID& id) {
-  return (id.first == IOA.clID() && id.second == IOA.par()[0]);
-}
-
 #endif // ATHENAKERNEL_TRANSIENTID_H
+2002-12-04  Paolo Calafiura  <pcalafiura@lbl.gov>
+
+        * struct TransientID: now a full fledged struct with structors,
+	accessors and a unit test
+	* AthenaKernel/IProxyProviderSvc.h: basically rewritten from scratch
+	* AthenaKernel/IProxyRegistry.h: replaces IAddressRegistry (a misnomer)
+	* AthenaKernel/IAddressProvider.h: renamed method, use TransientID struct
+	* AthenaKernel/IAlgContextSvc: added explicit virtual destructor
+	* AthenaKernel/IAtRndmGenSvc: added explicit virtual destructor,
+	use new InterfaceID constructor as elsewhere
+	* cmt/requirements: added TransientID_test
+	*tag AthenaKernel-00-00-01

File cmt/requirements

 use AtlasPolicy AtlasPolicy-* 
 use GaudiInterface GaudiInterface-01-* External
 library AthenaKernel *.cxx
+
+apply_pattern installed_library
+
+application TransientID_test -group=test -check ../test/TransientID_test.cxx
+
+

File src/TransientID.cxx

+/** the transient SG identifier
+  * ---------------------------------------------------------------------
+  * @author Paolo Calafiura <pcalafiura@lbl.gov> - ATLAS Collaboration
+  */
+
+// $Id: TransientID.cxx,v 1.1 2002-12-04 22:56:07 calaf Exp $
+
+//<<<<<< INCLUDES                                                       >>>>>>
+#include "AthenaKernel/TransientID.h"
+#include "GaudiKernel/IOpaqueAddress.h"
+
+TransientID::TransientID(const IOpaqueAddress& IOA) :
+  m_id(IOA.clID()), m_key(*(IOA.par())) {}
+
+
+bool 
+CompareTransientIDToIOA::operator()(const IOpaqueAddress* pIOA) {
+  return (m_id.clID() == pIOA->clID()) && ( m_id.key() == *(pIOA->par()) );
+}

File test/TransientID_test.cxx

+/***************************************************************************
+ unit test for the TransientID class
+ -----------------------------------------
+ ATLAS Collaboration
+ ***************************************************************************/
+
+// $Id: TransientID_test.cxx,v 1.1 2002-12-04 22:56:08 calaf Exp $
+
+//<<<<<< INCLUDES                                                       >>>>>>
+
+#include <cassert>
+#include <algorithm>
+#include <iostream>
+#include <list>
+
+#include "AthenaKernel/TransientID.h"
+
+#include "GaudiKernel/IOpaqueAddress.h"
+#include "GaudiKernel/GenericAddress.h"
+
+using namespace std;
+
+int main() {
+  cout << "*** TransientID_test BEGINS ***" <<endl;
+  TransientID id(CLID(1234), "aKey");
+  assert( id.key() == "aKey" );
+  assert( id.clID() == 1234 );
+
+  TransientID copy(id);
+  assert( id == copy );
+
+  TransientID ioaID(GenericAddress(98,id.clID(),id.key()));
+  assert( ioaID.key() == "aKey" );
+  assert( ioaID.clID() == 1234 );
+  assert( id == ioaID );
+
+  TransientID def(CLID(4321));
+  assert( def.isDefault() );
+
+  list<IOpaqueAddress*> idList;
+  idList.push_back(new GenericAddress(98,id.clID(),id.key()));
+  idList.push_back(new GenericAddress(98,123,"bla"));
+  idList.push_back(new GenericAddress(98,3,"bli"));
+  CompareTransientIDToIOA c2IOA(id);
+  assert(idList.end() != std::find_if(idList.begin(), idList.end(), c2IOA));
+  CompareTransientIDToIOA rc2IOA(TransientID(3, "bli"));
+  assert(idList.end() != std::find_if(idList.begin(), idList.end(), rc2IOA));
+  CompareTransientIDToIOA failc2IOA(TransientID(3456, "bla"));
+  assert(idList.end() == std::find_if(idList.begin(), idList.end(), failc2IOA));
+  cout << "*** TransientID_test OK ***" <<endl;
+
+  return 0;
+}
+