Anonymous avatar Anonymous committed e130faf Merge

sync w/ atlasoff

Comments (0)

Files changed (9)

 932a9f1cd993de4981fa2bfb3f69ec730595b5d1 SGTools-00-16-14
 ecc1616d02661a0210af273871d5925ae85f569c SGTools-00-16-15
 45180f697cad74bab4481be390a8bce782cf45ff SGTools-00-16-16
+e9eb0c1bdb8ad6bb1e41564fa38f6653b9789407 SGTools-00-16-17
+041094ccfef9b93caa211a5b6b122bb4562d61e3 SGTools-00-17-00
+528b885e71e84df62e90d4bbbbc5906984cde4c2 SGTools-00-17-01
+e8df26de171bf83e4346f60a235b2f23013ae23e SGTools-00-17-02
+3233fca840fbaf854e1c34863b61d6031558712a SGTools-00-17-03
+5d2dd1f9574f94a491d4cbe9f624df4a9322279a SGTools-00-17-04
+5c8431a1cea6c1cde1d9515305984991e77e659e SGTools-00-17-05
+2012-03-30  Sebastien Binet  <binet@cern.ch>
+
+	* tagging  SGTools-00-17-05
+	* adding vec of vec of short, ushort, ulong and ulonglong
+	* M SGTools/StlVectorClids.h
+
+2012-03-26  Sebastien Binet  <binet@cern.ch>
+
+	* tagging  SGTools-00-17-04
+	* add clid for map of str to str
+	* add clid for vec of vec of vec of {int,float}
+	* M SGTools/StlVectorClids.h
+	* M SGTools/StlMapClids.h
+
+2012-03-13  Sebastien Binet  <binet@voatlas51.cern.ch>
+
+	* tagging  SGTools-00-17-03
+	* add a default ctor for SGFolderItem so a vector of those can be resized(0)
+	* M SGTools/SGFolderItem.h
+
+	2012-03-05  Paolo Calafiura  <calaf@localhost6.localdomain6>
+
+	* Tagging  SGTools-00-17-02.
+	* src/DataProxy.cxx (DataProxy::requestRelease): further protect
+	VERBOSE message (#82923)
+
+2012-02-06  scott snyder  <snyder@bnl.gov>
+
+	* Tagging  SGTools-00-17-01.
+	* src/DataStore.cxx (proxy): Change logic for default key
+	retrieval: If there are multiple matching proxies, but only one is
+	of the exact type requested, then that one wins.  This means that
+	making a symlink from another type won't spoil an existing
+	default key retrieval.
+
+2011-11-28  Sebastien Binet  <sebastien.binet@cern.ch>
+
+	* tagging SGTools-00-17-00
+	* split-up DataHandle into DataHandle and DataHandleBase (reduce
+	  template bloat)
+	* add clid for vector of bools
+	* A SGTools/DataHandleBase.h
+	* A src/DataHandleBase.cxx
+	* M SGTools/StlVectorClids.h
+	* M src/DataProxy.cxx
+
 2011-09-23  scott snyder  <snyder@bnl.gov>
 
 	* Tagging  SGTools-00-16-17.

SGTools/DataHandleBase.h

+///////////////////////// -*- C++ -*- /////////////////////////////
+// DataHandleBase.h 
+// Header file for class DataHandleBase
+// Author: S.Binet<binet@cern.ch>
+/////////////////////////////////////////////////////////////////// 
+#ifndef SGTOOLS_DATAHANDLEBASE_H
+#define SGTOOLS_DATAHANDLEBASE_H 1
+
+// STL includes
+#include <string>
+
+// fwk includes
+#include "AthenaKernel/IProxyDict.h"
+#include "AthenaKernel/IResetable.h"
+
+// SGTools includes
+#include "SGTools/DataProxy.h"
+#include "SGTools/ProxyMap.h"
+
+// Forward declaration
+
+
+/**
+ * @class DataHandleBase 
+ * @brief an iterator over instances of a given type in an @c IProxyDict (such
+ * as StoreGateSvc). It d-casts and caches locally the pointed-at object, to 
+ * speed-up subsequent accesses.
+ * It can be reset by the store for asynchronous updates (IOVSvc)
+ */
+class DataHandleBase : public IResetable
+{ 
+
+  /////////////////////////////////////////////////////////////////// 
+  // Public typedefs: 
+  /////////////////////////////////////////////////////////////////// 
+public: 
+  typedef std::string ID_type;
+
+  /////////////////////////////////////////////////////////////////// 
+  // Public methods: 
+  /////////////////////////////////////////////////////////////////// 
+public: 
+
+  /// Default constructor: 
+  DataHandleBase();
+
+  /// Copy constructor: 
+  DataHandleBase( const DataHandleBase& rhs );
+
+  /// Assignment operator: 
+  DataHandleBase& operator=( const DataHandleBase& rhs ); 
+
+  /// Constructor with parameters: 
+
+  DataHandleBase(SG::DataProxy* proxy); ///< 
+  DataHandleBase(const SG::ConstProxyIterator& itr1,
+                 const SG::ConstProxyIterator& itr2);
+
+  /// Destructor: 
+  virtual ~DataHandleBase(); 
+
+  /////////////////////////////////////////////////////////////////// 
+  // Const methods: 
+  ///////////////////////////////////////////////////////////////////
+
+  /// \name validity checks
+  //@{
+  bool isConst() const;
+  bool isInitialized() const;    ///<weaker test but it does not touch the disk!
+  bool isSet() const { return isInitialized(); }
+  //@}
+
+  /// Get the key string with which the current object was stored.
+  const std::string& key() const;
+
+  StatusCode setState(SG::DataProxy* proxy) const;
+  StatusCode setState(IProxyDict* store, const ID_type& name) const;
+
+  // Note: itr1 may be modified!
+  StatusCode setState(SG::ConstProxyIterator& itr1,
+                      const SG::ConstProxyIterator& itr2) const;
+
+  /// the CLID of the object we are bound to
+  virtual CLID clid() const =0;
+
+  ///get the data object key (ID)
+  ID_type ID() const { return isInitialized() ? m_proxy->name() : "NONE"; }
+
+  /////////////////////////////////////////////////////////////////// 
+  // Non-const methods: 
+  /////////////////////////////////////////////////////////////////// 
+
+  StatusCode setState(SG::DataProxy* proxy);
+  StatusCode setState(IProxyDict* store, const ID_type& name);
+
+  /////////////////////////////////////////////////////////////////// 
+  // Protected data: 
+  /////////////////////////////////////////////////////////////////// 
+protected: 
+
+  /// iterator pointing at the beginning of the range of proxies
+  mutable SG::ConstProxyIterator m_itr;
+
+  /// iterator pointing at the end of the range of proxies
+  mutable SG::ConstProxyIterator m_itrEnd;
+
+  /// the proxy holding the object we are bound to
+  mutable SG::DataProxy* m_proxy;
+
+  /// use the proxy-iterator or just the proxy ?
+  mutable bool m_useItr;
+
+}; 
+
+/////////////////////////////////////////////////////////////////// 
+// Inline methods: 
+/////////////////////////////////////////////////////////////////// 
+//std::ostream& operator<<( std::ostream& out, const DataHandleBase& o );
+
+
+
+#endif //> !SGTOOLS_DATAHANDLEBASE_H

SGTools/SGFolderItem.h

    **/
   class FolderItem {
   public:
-    FolderItem(CLID id, const std::string& key) : m_id(id), m_key(key) {}
+    FolderItem(CLID id=CLID_NULL, const std::string& key="") : m_id(id), m_key(key) {}
     CLID id() const { return m_id; }
     const std::string& key() const { return m_key; }
     bool operator < (const FolderItem& rhs) const {

SGTools/StlMapClids.h

 CLASS_DEF2( std::map<std::string,unsigned int> , 113556225 , 1 )
 CLASS_DEF2( std::map<std::string,float> ,        193758082 , 1 )
 CLASS_DEF2( std::map<std::string,double> ,       252602412 , 1 )
+CLASS_DEF2( std::map<std::string,std::string> , 143489258 , 1 )
 
 CLASS_DEF2( std::map<std::string,std::vector<int> > ,          181049313 , 1 )
 CLASS_DEF2( std::map<std::string,std::vector<unsigned int> > , 199376827 , 1 )

SGTools/StlVectorClids.h

 // SGTools includes
 #include "SGTools/CLASS_DEF.h"
 
+CLASS_DEF( std::vector<bool> ,            45822813 , 1 )
 CLASS_DEF( std::vector<short> ,           35706084 , 1 )
-CLASS_DEF( std::vector<unsigned short> , 238793770 , 1 )
 CLASS_DEF( std::vector<int> ,             22592129 , 1 )
-CLASS_DEF( std::vector<unsigned int> ,   177480351 , 1 )
 CLASS_DEF( std::vector<float> ,          202242136 , 1 )
 CLASS_DEF( std::vector<double> ,         219400222 , 1 )
 CLASS_DEF( std::vector<std::string> ,     25884436 , 1 )
 
-CLASS_DEF( std::vector<std::vector<int> > ,           23262399 , 1 )
-CLASS_DEF( std::vector<std::vector<unsigned int> > , 213985193 , 1 )
+CLASS_DEF( std::vector<unsigned short> , 238793770 , 1 )
+CLASS_DEF( std::vector<unsigned int> ,   177480351 , 1 )
+CLASS_DEF( std::vector<unsigned long> ,      18868981 , 1 )
+CLASS_DEF( std::vector<unsigned long long> , 35119468 , 1 )
+
+CLASS_DEF( std::vector<std::vector<short> > ,              24204906 , 1 )
+CLASS_DEF( std::vector<std::vector<int> > ,                23262399 , 1 )
+CLASS_DEF( std::vector<std::vector<unsigned short> > ,    247252788 , 1 )
+CLASS_DEF( std::vector<std::vector<unsigned int> > ,      213985193 , 1 )
+CLASS_DEF( std::vector<std::vector<unsigned long> > ,     205717523 , 1 )
+CLASS_DEF( std::vector<std::vector<unsigned long long> > , 76977490 , 1 )
 CLASS_DEF( std::vector<std::vector<float> > ,        258753314 , 1 )
 CLASS_DEF( std::vector<std::vector<double> > ,       154043868 , 1 )
 CLASS_DEF( std::vector<std::vector<std::string> > ,  101141770 , 1 )
 
+CLASS_DEF( std::vector<std::vector<std::vector<int> > > ,   85220325 , 1 )
+CLASS_DEF( std::vector<std::vector<std::vector<float> > > , 82469196 , 1 )
+
 #endif // !SGTOOLS_STLVECTORCLIDS_H

src/DataHandleBase.cxx

+///////////////////////// -*- C++ -*- /////////////////////////////
+// DataHandleBase.cxx 
+// Implementation file for class DataHandleBase
+// Author: S.Binet<binet@cern.ch>
+/////////////////////////////////////////////////////////////////// 
+
+// SGTools includes
+#include "SGTools/DataHandleBase.h"
+
+// STL includes
+
+
+
+/////////////////////////////////////////////////////////////////// 
+// Public methods: 
+/////////////////////////////////////////////////////////////////// 
+
+// Constructors
+////////////////
+
+/// Default constructor: 
+DataHandleBase::DataHandleBase() :
+  IResetable(),
+  m_itr(), 
+  m_itrEnd(), 
+  m_proxy(0),
+  //m_ptr(0),
+  m_useItr(false)
+{}
+
+/// Copy constructor: 
+DataHandleBase::DataHandleBase( const DataHandleBase& rhs ) :
+  IResetable(),
+  m_itr(rhs.m_itr), 
+  m_itrEnd(rhs.m_itrEnd),
+  m_proxy(rhs.m_proxy), 
+  //m_ptr(rhs.m_ptr),
+  m_useItr(rhs.m_useItr)
+{
+  if (m_proxy) {
+    m_proxy->addRef();
+  }
+}
+
+
+/// Assignment operator: 
+DataHandleBase& 
+DataHandleBase::operator=( const DataHandleBase& rhs )
+{
+  if (m_proxy) {
+    m_proxy->release();
+  }
+
+  m_itr =    rhs.m_itr;
+  m_itrEnd = rhs.m_itrEnd;
+  m_useItr = rhs.m_useItr;
+  m_proxy =  rhs.m_proxy;
+  //m_ptr =    rhs.m_ptr;
+  if (m_proxy) {
+    m_proxy->addRef();
+  }
+
+  return *this;
+}
+
+/// Constructor with parameters: 
+DataHandleBase::DataHandleBase(SG::DataProxy* proxy) :
+  IResetable(),
+  m_itr(), 
+  m_itrEnd(), 
+  m_proxy(proxy), 
+  //m_ptr(0),
+  m_useItr(false)
+{
+  if (m_proxy) {
+    m_proxy->addRef();
+  }
+}
+
+DataHandleBase::DataHandleBase(const SG::ConstProxyIterator& itr,
+                               const SG::ConstProxyIterator& itrEnd) :
+  IResetable(),
+  m_itr(itr), 
+  m_itrEnd(itrEnd),
+  m_proxy(0), 
+  //m_ptr(0),
+  m_useItr(true)
+{
+  if (m_itr != m_itrEnd) {
+    m_proxy = m_itr->second;
+  }
+
+  if (m_proxy) {
+    m_proxy->addRef();
+  }
+}
+
+
+/// Destructor: 
+DataHandleBase::~DataHandleBase()
+{
+  if (m_proxy != 0) {
+    m_proxy->unbindHandle(this);
+    m_proxy->release();
+  }
+}
+
+// Destructor
+///////////////
+
+/////////////////////////////////////////////////////////////////// 
+// Const methods: 
+///////////////////////////////////////////////////////////////////
+
+StatusCode 
+DataHandleBase::setState(SG::ConstProxyIterator &itr, 
+                         const SG::ConstProxyIterator &itrEnd) const 
+{
+  if (m_proxy) m_proxy->release();
+
+  m_itr = itr;
+  m_itrEnd = itrEnd;
+  m_useItr = true;
+
+  // ouch! FIXME ?
+  // we could have a void* m_ptr data member and have a
+  // typeless_dataPointer method using the typeless machinery of
+  // DataProxy+DataBucketBase...
+  const_cast<DataHandleBase*>(this)->reset();
+
+  // scan from itr to itrEnd and set m_itr to the first valid iterator:
+
+  for (; itr != itrEnd; itr++) {
+    if (itr->second->isValid()) {
+      m_itr = itr;
+      m_proxy = m_itr->second;
+      if (m_proxy) m_proxy->addRef();
+      return StatusCode::SUCCESS;
+    }
+  }
+
+  m_itr = itrEnd;
+  m_proxy = 0;
+  
+  return StatusCode::FAILURE; 
+}
+
+StatusCode 
+DataHandleBase::setState(SG::DataProxy* proxy) const
+{
+  if (0 == proxy || !proxy->isValid()) {
+    return StatusCode::FAILURE;
+  }
+
+  if (m_proxy != proxy) {
+    if (m_proxy) m_proxy->release();
+    m_proxy = proxy;
+    m_proxy->addRef();
+  }
+
+  m_useItr = false;
+  const_cast<DataHandleBase*>(this)->reset();
+
+  return StatusCode::SUCCESS;
+}
+
+StatusCode 
+DataHandleBase::setState(IProxyDict* store, const ID_type& key) const 
+{
+  if (0 == store) {
+    return StatusCode::FAILURE;
+  }
+  CLID cid = this->clid();
+  SG::DataProxy* proxy = store->proxy(cid, key);
+  return this->setState(proxy);
+}
+
+const std::string& 
+DataHandleBase::key() const
+{
+  if (m_itr == m_itrEnd) {
+    return m_proxy->name();
+  } else {
+    return m_itr->first;
+  }
+}
+
+bool 
+DataHandleBase::isConst() const
+{
+  return 0 != m_proxy 
+    ? m_proxy->isConst() 
+    : false;
+}
+
+
+// A weaker test that
+// *does not* retrieve the GaudiObject to check validity if not already done
+bool 
+DataHandleBase::isInitialized() const
+{
+  return (0 != m_proxy);
+}
+
+/////////////////////////////////////////////////////////////////// 
+// Non-const methods: 
+/////////////////////////////////////////////////////////////////// 
+
+StatusCode 
+DataHandleBase::setState(SG::DataProxy* proxy)
+{
+  if (0 == proxy || !proxy->isValid() || proxy->isConst()) {
+    return StatusCode::FAILURE;
+  }
+
+  if (m_proxy != proxy) {
+    if (m_proxy) m_proxy->release();
+    m_proxy = proxy;
+    m_proxy->addRef();
+  }
+
+  m_useItr = false;
+  this->reset();
+  return StatusCode::SUCCESS;
+}
+
+StatusCode 
+DataHandleBase::setState(IProxyDict* store, const ID_type& key)
+{
+  if (0 == store) {
+    return StatusCode::FAILURE;
+  }
+  CLID cid = this->clid();
+  SG::DataProxy* proxy = store->proxy(cid, key);
+  return this->setState(proxy);
+}
+
+/////////////////////////////////////////////////////////////////// 
+// Protected methods: 
+/////////////////////////////////////////////////////////////////// 
+
+

src/DataProxy.cxx

   bool canRelease = !isResetOnly() || force;
 #ifndef NDEBUG
   MsgStream gLog(m_ims, "DataProxy");
-  gLog << MSG::VERBOSE << "requestRelease(): "
-       << (canRelease ? " release " : " reset")
-       <<" object " 
-       << name() << " CLID " << clID() << " address " << MSG::hex
-       << object() << MSG::dec << endreq;
+  if (gLog.level() <= MSG::VERBOSE) {
+    gLog << MSG::VERBOSE << "requestRelease(): "
+	 << (canRelease ? " release " : " reset")
+	 <<" object " 
+	 << name() << " CLID " << clID() << " address " << MSG::hex
+	 << object() << MSG::dec << endreq;
+  }
 #endif
   if (canRelease)  release();
     else             reset();
 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
 bool DataProxy::isValidAddress() const
 {
-  return m_tAddress->isValid();
+  return (0 != m_tAddress && m_tAddress->isValid());
 }
 
 bool DataProxy::isValidObject() const

src/DataStore.cxx

     ConstProxyIterator p_iter = pmap.find(key);
     if (p_iter != pmap.end()) {
       p=p_iter->second;
-    } else if (key == SG::DEFAULTKEY && !pmap.empty() &&
-	       (int(pmap.size() - pmap.begin()->second->alias().size()) < 2)) {
-      // we did not find the object using key. Now check for default object.
-      // There can only be one, not counting its aliases.
-      // Notice: we test that there are less than two matches: symlinked objects
-      // may carry aliases from the concrete class. In that case pmap.size()
-      // may be equal to or even smaller than the number of aliases
-      if (doAudit()) m_pSGAudSvc->SGAudRETRIEVE(pmap.begin()->first);
-      p = pmap.begin()->second;
+    }
+    else if (key == SG::DEFAULTKEY && !pmap.empty()) {
+      // we did not find the object using key.
+      // Now check for default object.
+      // Simple case first --- single object.
+      if (pmap.size() == 1) {
+        if (doAudit()) m_pSGAudSvc->SGAudRETRIEVE(pmap.begin()->first);
+        p = pmap.begin()->second;
+      }
+      else {
+        // Otherwise, match only the exact type requested.
+        ConstProxyIterator p_match = pmap.end();
+        size_t nmatch = 0;
+        for (p_iter = pmap.begin(); p_iter != pmap.end(); ++p_iter) {
+          if (p_iter->second->transientAddress()->clID() == id) {
+            ++nmatch;
+            if (p_match == pmap.end()) p_match = p_iter;
+          }
+        }
+
+        // We must have matched only one object, not counting its aliases.
+        // Notice: we test that there are less than two matches: symlinked objects
+        // may carry aliases from the concrete class. In that case nmatch
+        // may be equal to or even smaller than the number of aliases
+        if (nmatch > 0 &&
+            (int(nmatch - p_match->second->alias().size()) < 2))
+        {
+          if (doAudit()) m_pSGAudSvc->SGAudRETRIEVE(pmap.begin()->first);
+          p = pmap.begin()->second;
+        }
+      }
     }
   }
   return p;
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.