Skip to content
Snippets Groups Projects
Commit 1abdd22e authored by Marco Clemencic's avatar Marco Clemencic
Browse files

Merge branch 'dev/DataObjID' into 'master'

update DataObjID

fixed typo in DataObjIDProperty, updated release notes, added DataHandle placeholder prototype class

* DataObjID: various classes used for DataObject and DataHandle identification
  * DataObjID: holds a unique key for an object in the store, with an internal
              representation as a hash for fast lookup.
              syntax is either Gaudi EDS path style "/path/to/object", or ATLAS
              style with (ClassID,"key") or ("ClassName","key")
              Collections of DataObjIDs are unordered_set<DataObjID,DataObjID_Hasher>
              typedef to DataObjIDColl
  * DataObjIDProperty: jobOpt Property handler for DataObjID and DataObjIDColl
  * DataHandle: prototype placeholder for DataHande class

See merge request !41
parents e3e20a4c f4340277
Branches
Tags
No related merge requests found
#ifndef GAUDIKERNEL_DATAHANDLE
#define GAUDIKERNEL_DATAHANDLE 1
#include "GaudiKernel/Parsers.h"
#include "GaudiKernel/Property.h"
#include "GaudiKernel/PropertyMgr.h"
#include "GaudiKernel/ToStream.h"
#include "GaudiKernel/DataObjID.h"
#include <sstream>
class IDataHandleHolder;
namespace Gaudi {
class DataHandle {
public:
enum Mode {
Reader = 1<<2,
Writer = 1<<4,
Updater = Reader | Writer
};
DataHandle() : m_key("NONE"), m_owner(0), m_mode(Reader) {};
DataHandle(const DataObjID& k, Mode a=Reader,
IDataHandleHolder* owner=0):
m_key(k), m_owner(owner), m_mode(a){};
virtual ~DataHandle(){}
virtual void setOwner(IDataHandleHolder* o) { m_owner = o; }
virtual IDataHandleHolder* owner() const { return m_owner; }
virtual Mode mode() const { return m_mode; }
virtual void setKey(const DataObjID& key) { m_key = key; }
virtual void updateKey(const std::string& key) { m_key.updateKey(key); }
virtual const std::string& objKey() const { return m_key.key(); }
virtual const DataObjID& fullKey() const { return m_key; }
virtual void reset(bool) {};
virtual StatusCode commit() { return StatusCode::SUCCESS; }
virtual const std::string pythonRepr() const {
std::ostringstream ost;
ost << "DataHandle(\"" << fullKey() << "|"
<< std::to_string(mode()) << "\")";
return ost.str();
}
protected:
virtual void setMode(const Mode& mode) { m_mode = mode; }
DataObjID m_key;
IDataHandleHolder* m_owner;
private:
Mode m_mode;
};
}
namespace Gaudi {
namespace Parsers {
GAUDI_API
StatusCode parse(DataHandle&, const std::string&);
} //> ns Parsers
namespace Utils {
GAUDI_API
std::ostream&
toStream(const DataHandle& v, std::ostream& o);
} //> ns Utils
} //> ns Gaudi
class GAUDI_API DataHandleProperty : public Property {
public:
/// Constructor with parameters:
DataHandleProperty( const std::string& name, Gaudi::DataHandle& ref );
/// Assignment operator:
DataHandleProperty& operator=( const Gaudi::DataHandle& value );
/// Destructor:
virtual ~DataHandleProperty();
virtual DataHandleProperty* clone() const;
virtual bool load( Property& destination ) const;
virtual bool assign( const Property& source );
virtual std::string toString() const;
virtual void toStream(std::ostream& out) const;
virtual StatusCode fromString(const std::string& s);
const Gaudi::DataHandle& value() const;
bool setValue( const Gaudi::DataHandle& value );
private:
/** Pointer to the real property. Reference would be better,
* but Reflex does not support references yet
*/
Gaudi::DataHandle* m_pValue;
};
inline
DataHandleProperty&
DataHandleProperty::operator=( const Gaudi::DataHandle& value )
{
setValue( value );
return *this;
}
inline
DataHandleProperty*
DataHandleProperty::clone() const
{
return new DataHandleProperty( *this );
}
inline
bool
DataHandleProperty::load( Property& destination ) const
{
return destination.assign( *this );
}
inline
bool
DataHandleProperty::assign( const Property& source )
{
return fromString( source.toString() ).isSuccess();
}
inline
const Gaudi::DataHandle&
DataHandleProperty::value() const
{
useReadHandler();
return *m_pValue;
}
template<>
class SimplePropertyRef< Gaudi::DataHandle > : public DataHandleProperty {
public:
SimplePropertyRef(const std::string& name, Gaudi::DataHandle& value) :
::DataHandleProperty(name, value)
{}
/// virtual Destructor
virtual ~SimplePropertyRef() {}
};
#endif
...@@ -2,6 +2,17 @@ ...@@ -2,6 +2,17 @@
Package manager : Marco Clemencic Package manager : Marco Clemencic
Commit Id: $Format:%H$ Commit Id: $Format:%H$
! 2015-10-06 - Charles Leggett
- DataObjID: various classes used for DataObject and DataHandle identification
o DataObjID: holds a unique key for an object in the store, with an internal
representation as a hash for fast lookup.
syntax is either Gaudi EDS path style "/path/to/object", or ATLAS
style with (ClassID,"key") or ("ClassName","key")
Collections of DataObjIDs are unordered_set<DataObjID,DataObjID_Hasher>
typedef to DataObjIDColl
o DataObjIDProperty: jobOpt Property handler for DataObjID and DataObjIDColl
o DataHandle: prototype placeholder for DataHande class
! 2015-09-09 - Gerhard Raven & Benedikt Hegner ! 2015-09-09 - Gerhard Raven & Benedikt Hegner
- C++11 modernization changes, eg. - C++11 modernization changes, eg.
o replace boost::lexical_cast with std::to_string, std::stod, std::stoi o replace boost::lexical_cast with std::to_string, std::stod, std::stoi
......
#include "GaudiKernel/DataHandle.h"
#include <sstream>
#include <map>
#include <boost/tokenizer.hpp>
#include <boost/algorithm/string.hpp>
using namespace Gaudi;
namespace Gaudi {
namespace Parsers {
StatusCode
parse(DataHandle& v, const std::string& s)
{
// Just a placeholder: currently the properties only contain
// the key
std::string k(s);
boost::erase_all(k,"'");
v.updateKey( k );
return StatusCode::SUCCESS;
}
} //> ns Parsers
namespace Utils {
std::ostream&
toStream(const DataHandle& v, std::ostream& o)
{
o << "'" << v.objKey() << "'";
return o;
}
} //> ns Utils
} //> ns Gaudi
DataHandleProperty::DataHandleProperty( const std::string& name,
DataHandle& ref )
: Property( name, typeid( DataHandle ) ),
m_pValue( &ref )
{}
DataHandleProperty::~DataHandleProperty()
{}
StatusCode
DataHandleProperty::fromString(const std::string& s)
{
if (!Gaudi::Parsers::parse(*m_pValue, s).isSuccess()) {
return StatusCode::FAILURE;
}
return useUpdateHandler()
? StatusCode::SUCCESS
: StatusCode::FAILURE;
}
bool
DataHandleProperty::setValue( const DataHandle& value )
{
m_pValue->operator=(value);
return useUpdateHandler();
}
std::string
DataHandleProperty::toString( ) const
{
useReadHandler();
std::ostringstream o;
Gaudi::Utils::toStream(*m_pValue, o);
return o.str();
}
void
DataHandleProperty::toStream(std::ostream& out) const
{
useReadHandler();
out << this->toString();
}
...@@ -155,8 +155,8 @@ namespace Gaudi { ...@@ -155,8 +155,8 @@ namespace Gaudi {
toStream(const DataObjIDColl& v, std::ostream& o) { toStream(const DataObjIDColl& v, std::ostream& o) {
o << "["; o << "[";
for (auto &i : v) { for (auto &i : v) {
// o << "(" << i.clid() << ",'" << i.key() << "'),"; toStream(i,o);
o << toStream(i,o) << ","; o << ",";
} }
o << "]"; o << "]";
return o; return o;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment