Loading [MathJax]/extensions/tex2jax.js
 |
ATLAS Offline Software
|
Go to the documentation of this file.
25 #include "GaudiKernel/MsgStream.h"
30 #include "GaudiKernel/ThreadLocalContext.h"
37 #include <boost/core/demangle.hpp>
47 template <
class T>
void*
ptr(T*
p) {
return static_cast<void*
>(
p); }
94 virtual const std::type_info&
tinfo()
const override {
return typeid(void); }
99 virtual void lock()
override { }
118 m_storeWasSet(false),
120 m_key (m_ownedKey.
get())
138 const std::string&
sgkey,
140 const std::string& storename,
141 const EventContext* ctx) :
146 m_storeWasSet(false),
148 m_key (m_ownedKey.
get())
167 const EventContext* ctx)
172 m_storeWasSet(false),
175 if (
key.storeHandle().get() ==
nullptr) {
177 key.storeHandle().name());
182 key.storeHandle().name());
200 m_storeWasSet (true),
204 m_store ? m_store->
name() :
"")),
205 m_key (m_ownedKey.
get())
219 m_store(rhs.m_store),
220 m_storeWasSet(rhs.m_storeWasSet)
245 m_store(rhs.m_store),
246 m_storeWasSet(rhs.m_storeWasSet),
247 m_ownedKey (std::move (rhs.m_ownedKey)),
251 m_ownedKey->setOwningHandle (
this);
257 rhs.m_proxy->unbindHandle (&rhs);
258 rhs.m_proxy->bindHandle(
this);
260 m_proxy = rhs.m_proxy;
305 m_ownedKey = std::move (rhs.m_ownedKey);
307 m_ownedKey->setOwningHandle (
this);
312 m_store = rhs.m_store;
313 m_storeWasSet = rhs.m_storeWasSet;
320 rhs.m_proxy->unbindHandle (&rhs);
321 rhs.m_proxy->bindHandle (
this);
323 m_proxy = rhs.m_proxy;
464 return StatusCode::SUCCESS;
476 return StatusCode::FAILURE;
479 return StatusCode::SUCCESS;
518 else if (!
proxy->isValid()) {
527 dbg::print(
stderr,
"::VHB:: setState() on {} ==> m_store points not to an SGImplSvc but to a {}\n",
dbg::ptr(
this), boost::core::demangle(
typeid(*m_store).name()));
540 return StatusCode::SUCCESS;
562 return StatusCode::SUCCESS;
616 return StatusCode::SUCCESS;
618 return StatusCode::FAILURE;
672 return StatusCode::FAILURE;
682 return StatusCode::SUCCESS;
695 return StatusCode::FAILURE;
732 if (this->
name().empty()) {
733 REPORT_ERROR (StatusCode::FAILURE) <<
"Attempt to record an object with a null key";
734 return StatusCode::FAILURE;
738 unsigned int initRefCount = sptr->refCount();
742 REPORT_ERROR (StatusCode::FAILURE) <<
"recordObject failed";
744 return StatusCode::FAILURE;
750 if (new_proxy && initRefCount == sptr->refCount() && new_proxy->
isValid()) {
756 <<
"Found an existing const object from recordOrRetrieve.";
757 return StatusCode::FAILURE;
764 m_ptr=(
void*)dataPtr;
766 return StatusCode::SUCCESS;
789 std::unique_ptr<DataObject> dobj,
795 if (this->
name().empty()) {
796 REPORT_ERROR (StatusCode::FAILURE) <<
"Attempt to record an object with a null key";
807 unsigned int initRefCount = sptr->refCount();
809 store->recordObject (sptr, this->
name(), allowMods, returnExisting);
811 REPORT_ERROR (StatusCode::FAILURE) <<
"recordObject failed";
815 if (new_proxy && initRefCount == sptr->refCount() && new_proxy->
isValid()) {
833 dbg::print(
stderr,
"::VHB::typeless_dataPointer_impl({}, ptr={}, proxy={}, key={}, store={})\n",
dbg::ptr(
this),
dbg::ptr(this->
m_ptr),
dbg::proxy(this->
m_proxy), this->
key(),
dbg::store(this->
m_store));
845 <<
"could not get proxy for key " <<
key();
888 <<
"get_impl called for a non-read handle.";
892 if (this->
key().empty()) {
895 <<
"Cannot initialize a Read/Write/Update handle with a null key.";
912 <<
"Cannot find proxy for "
913 << this->
clid() <<
"/" << this->
key();
933 const std::string& newKey)
936 REPORT_ERROR (StatusCode::FAILURE) <<
"symlink: Handle not valid.";
937 return StatusCode::FAILURE;
943 return StatusCode::FAILURE;
944 return StatusCode::SUCCESS;
1032 proxy->bindHandle (
this);
1056 <<
"/" << (
proxy != 0
1058 : std::string(
"<N/A>"))
1059 <<
"] is in an invalid state";
1064 DataObject* dobj =
proxy->accessData();
1069 <<
"this proxy " << MSG::hex <<
proxy
1070 << MSG::dec <<
" has a NULL data object ptr";
1088 ptr =
static_cast<void*
>(dbb->
object());
1092 <<
"Request for an invalid object; requested CLID = "
1094 <<
", proxy primary ID is " <<
proxy->clID();
1118 return proxy->isValid();
1136 out <<
"VarHandleBase @" << &o
1137 <<
" store=" <<o.
store()
1138 <<
", clid=" <<o.
clid()
1139 <<
", key=" <<o.
key()
1140 <<
"----------- ptr@" << o.
m_ptr
1143 out <<
", DataObject@" << o.
m_proxy->object();
1151 bool operator==(
const VarHandleBase&
l,
const VarHandleBase&
r)
1153 return (
l.clid() ==
r.clid() &&
1154 l.mode() ==
r.mode() &&
1155 l.name() ==
r.name() &&
1156 l.store() ==
r.store());
1163 bool operator!=(
const VarHandleBase&
l,
const VarHandleBase&
r)
Base class for VarHandle classes.
bool operator!=(const VarHandleBase &l, const VarHandleBase &r)
Inequality comparison.
Interface for registering a transient object in t2p map.
VarHandleBase(CLID clid, Gaudi::DataHandle::Mode mode)
Constructor with default key.
#define REPORT_ERROR(SC)
Report an error.
virtual SG::DataProxy * proxy(const CLID &id, const std::string &key) const =0
Get proxy with given id and key.
bool isConst() const
Check if it is a const object.
IProxyDict * storeFromHandle(const EventContext *ctx) const
Return the store instance to use.
std::unique_ptr< VarHandleKey > m_ownedKey
An owned VarHandleKey.
singleton-like access to IMessageSvc via open function and helper
virtual void finalReset() override final
Reset this handle at the end of processing.
void * typeless_dataPointer(bool quiet=defaultQuiet)
Retrieve an object from StoreGate.
virtual const std::type_info & tinfo() const override
Return the type_info for the stored object.
A non-templated base class for DataBucket, allows to access the transient object address as a void*.
convert to and from a SG storable
const ServiceHandle< IProxyDict > & storeHandle() const
Return handle to the referenced store.
const std::string & name() const
Return the StoreGate ID for the referenced object.
StatusCode assign(const std::string &sgkey)
Update the underlying key from a string.
StatusCode setState()
Retrieve and cache all information managed by a handle.
Base class for VarHandle types.
virtual void * object()=0
CLID clid() const
Return the class ID for the referenced object.
void * typeless_dataPointer_impl(bool quiet)
Retrieve an object from StoreGate.
bool hasExtendedEventContext(const EventContext &ctx)
Test whether a context object has an extended context installed.
bool operator==(const VarHandleBase &l, const VarHandleBase &r)
Equality comparison.
VarHandleBase & operator=(const VarHandleBase &rhs)
Assignment operator.
virtual void * cast(CLID, SG::IRegisterTransient *, bool) override
Return the contents of the DataBucket, converted to type given by clid.
bool isValid() const
called by destructor
std::string context_name(const INamedInterface *context)
Return the context name from a context (this) pointer.
bool isValid(const T &p)
Av: we implement here an ATLAS-sepcific convention: all particles which are 99xxxxx are fine.
const std::string & key() const
Return the StoreGate ID for the referenced object.
T * cast(SG::IRegisterTransient *irt=0, bool isConst=true)
Return the contents of the DataBucket, converted to type T.
StatusCode setConst()
Set the 'const' bit for the bound proxy in the store.
void unbindHandle(IResetable *ir)
SymlinkDataObject(CLID clid, void *obj)
const ExtendedEventContext & getExtendedEventContext(const EventContext &ctx)
Retrieve an extended context from a context object.
virtual SG::DataProxy * proxy_exact(SG::sgkey_t sgkey) const =0
Get proxy given a hashed key+clid.
a resetable object (e.g. a SG DataHandle)
virtual const CLID & clID() const override
virtual StatusCode setProxyDict(IProxyDict *store)
Explicitly set the event store.
virtual void lock() override
If the held object derives from ILockable, call lock() on it.
void resetProxy()
Clear the m_proxy field and release the old proxy.
Exceptions that can be thrown from StoreGate.
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.
virtual StatusCode assign(const std::string &sgkey)
Change the key of the object to which we're referring.
::StatusCode StatusCode
StatusCode definition for legacy code.
const VarHandleKey * m_key
The associated key object.
std::string store() const
Return the name of the store holding the object we are proxying.
virtual void * cast(const std::type_info &, SG::IRegisterTransient *, bool) override
Return the contents of the DataBucket, converted to type given by std::type_info.
bool isEventStore() const
Does this key reference the primary event store?
The Athena Transient Store API.
#define CHECK(...)
Evaluate an expression and check for errors.
SG::DataProxy * m_proxy
Proxy holding the object to which we are bound.
Exception — Tried to retrieve non-const pointer to const object.
uint32_t CLID
The Class ID type.
bool isInitialized() const
Has a proxy been retrieved from SG?
virtual unsigned long release() override final
release reference to object
std::string dump() const
dump objects in store.
Gaudi::DataHandle::Mode mode() const
Return the mode (read/write/update) for this handle.
Helpers for checking error return status codes and reporting errors.
virtual void * object() override
bool isPresent_impl(const std::string &key) const
Is the referenced object present in SG?
virtual void reset(bool hard) override
Reset this handle.
void * typeless_dataPointer_fromProxy(SG::DataProxy *proxy, bool quiet) const
Retrieve a pointer from a proxy.
CLID clid() const
Return the class ID for the referenced object.
virtual const std::string & key() const override final
Return the StoreGate ID for the referenced object.
A property holding a SG store/key/clid from which a VarHandle is made.
virtual ~VarHandleBase() override
Destructor.
#define REPORT_MESSAGE(LVL)
Report a message.
void throwExcNonConstHandleKey(CLID clid, const std::string &sgkey, const std::string &storename)
Throw a SG::ExcNonConstHandleKey exception.
const ServiceHandle< IProxyDict > & storeHandle() const
Return handle to the referenced store.
bool setStoreFromHandle(const EventContext *ctx)
Initialize the store pointer from the store handle.
T * Storable_cast(DataObject *pDObj, bool quiet=true, IRegisterTransient *irt=0, bool isConst=true)
Exception — Tried to create a handle from an uninitialized key.
void * typeless_ptr(bool quiet=defaultQuiet)
Retrieve an object from StoreGate as non-const pointer.
void setConst()
Mark this object as const.
SG::sgkey_t hashedKey() const
Return the hashed StoreGate key.
StatusCode initialize(bool used=true)
Verify that the handle has been configured properly.
Exception — Error initializing VarHandle from VarHandleKey.
SG::VarHandleKey & vhKey()
Return a non-const reference to the HandleKey.
bool m_storeWasSet
True if the store was set explicitly via setProxyDict.
void * m_ptr
The object to which we are bound.
virtual SG::DataProxy * recordObject(SG::DataObjectSharedPtr< DataObject > obj, const std::string &key, bool allowMods, bool returnExisting)=0
Record an object in the store.
bool isPresent() const
Is the referenced object present in SG?
bool isResetOnly() const
Check reset only:
void print(std::FILE *stream, std::format_string< Args... > fmt, Args &&... args)
bool isConst() const
True if this handle has a proxy, and the proxy is const.
Smart pointer to manage DataObject reference counts.
const void * put_impl(const EventContext *ctx, std::unique_ptr< DataObject > dobj, const void *dataPtr, bool allowMods, bool returnExisting, IProxyDict *&store) const
Helper to record an object in the event store.
IProxyDict * m_store
Pointer to the store that owns the object.
virtual void relinquish() override
Give up ownership of the DataBucket contents.
virtual bool isSet() const override final
Has a proxy been retrieved from SG?
StatusCode record_impl(std::unique_ptr< DataObject > dobj, void *dataPtr, bool allowMods, bool returnExisting)
Helper to record an object in the event store.
virtual IProxyDict * hiveProxyDict() override
Return the current event-slot-specific store.
std::ostream & operator<<(std::ostream &os, const ArenaAllocatorBase::Stats::Stat &stat)
Format a statistic structure.
StatusCode symLink_impl(CLID newClid, const std::string &newKey)
Make a symlink or alias to the object currently referenced by this handle.
const void * get_impl(const EventContext *ctx, bool quiet=defaultQuiet) const
void setProxy(SG::DataProxy *proxy)
Set a new proxy.