|
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())
137 const std::string&
sgkey,
139 const std::string& storename) :
144 m_storeWasSet(false),
146 m_key (m_ownedKey.
get())
161 const EventContext* ctx)
166 m_storeWasSet(false),
169 if (
key.storeHandle().get() ==
nullptr) {
171 key.storeHandle().name());
176 key.storeHandle().name());
194 m_storeWasSet (true),
198 m_store ? m_store->
name() :
"")),
199 m_key (m_ownedKey.
get())
213 m_store(rhs.m_store),
214 m_storeWasSet(rhs.m_storeWasSet)
239 m_store(rhs.m_store),
240 m_storeWasSet(rhs.m_storeWasSet),
241 m_ownedKey (std::move (rhs.m_ownedKey)),
245 m_ownedKey->setOwningHandle (
this);
251 rhs.m_proxy->unbindHandle (&rhs);
252 rhs.m_proxy->bindHandle(
this);
254 m_proxy = rhs.m_proxy;
299 m_ownedKey = std::move (rhs.m_ownedKey);
301 m_ownedKey->setOwningHandle (
this);
306 m_store = rhs.m_store;
307 m_storeWasSet = rhs.m_storeWasSet;
314 rhs.m_proxy->unbindHandle (&rhs);
315 rhs.m_proxy->bindHandle (
this);
317 m_proxy = rhs.m_proxy;
458 return StatusCode::SUCCESS;
470 return StatusCode::FAILURE;
473 return StatusCode::SUCCESS;
512 else if (!
proxy->isValid()) {
521 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()));
534 return StatusCode::SUCCESS;
556 return StatusCode::SUCCESS;
610 return StatusCode::SUCCESS;
612 return StatusCode::FAILURE;
666 return StatusCode::FAILURE;
676 return StatusCode::SUCCESS;
689 return StatusCode::FAILURE;
726 if (this->
name().empty()) {
727 REPORT_ERROR (StatusCode::FAILURE) <<
"Attempt to record an object with a null key";
728 return StatusCode::FAILURE;
732 unsigned int initRefCount = sptr->refCount();
736 REPORT_ERROR (StatusCode::FAILURE) <<
"recordObject failed";
738 return StatusCode::FAILURE;
744 if (new_proxy && initRefCount == sptr->refCount() && new_proxy->
isValid()) {
750 <<
"Found an existing const object from recordOrRetrieve.";
751 return StatusCode::FAILURE;
758 m_ptr=(
void*)dataPtr;
760 return StatusCode::SUCCESS;
783 std::unique_ptr<DataObject> dobj,
790 REPORT_ERROR (StatusCode::FAILURE) <<
"Attempt to record an object with a null key";
801 unsigned int initRefCount = sptr->refCount();
803 store->recordObject (sptr, this->
name(), allowMods, returnExisting);
805 REPORT_ERROR (StatusCode::FAILURE) <<
"recordObject failed";
809 if (new_proxy && initRefCount == sptr->refCount() && new_proxy->
isValid()) {
827 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));
839 <<
"could not get proxy for key " <<
key();
882 <<
"get_impl called for a non-read handle.";
889 <<
"Cannot initialize a Read/Write/Update handle with a null key.";
906 <<
"Cannot find proxy for "
907 << this->
clid() <<
"/" << this->
key();
927 const std::string& newKey)
930 REPORT_ERROR (StatusCode::FAILURE) <<
"symlink: Handle not valid.";
931 return StatusCode::FAILURE;
937 return StatusCode::FAILURE;
938 return StatusCode::SUCCESS;
1026 proxy->bindHandle (
this);
1050 <<
"/" << (
proxy != 0
1052 : std::string(
"<N/A>"))
1053 <<
"] is in an invalid state";
1058 DataObject* dobj =
proxy->accessData();
1063 <<
"this proxy " << MSG::hex <<
proxy
1064 << MSG::dec <<
" has a NULL data object ptr";
1082 ptr =
static_cast<void*
>(dbb->
object());
1086 <<
"Request for an invalid object; requested CLID = "
1088 <<
", proxy primary ID is " <<
proxy->clID();
1112 return proxy->isValid();
1130 out <<
"VarHandleBase @" << &o
1131 <<
" store=" <<o.
store()
1132 <<
", clid=" <<o.
clid()
1133 <<
", key=" <<o.
key()
1134 <<
"----------- ptr@" << o.
m_ptr
1137 out <<
", DataObject@" << o.
m_proxy->object();
1145 bool operator==(
const VarHandleBase&
l,
const VarHandleBase&
r)
1147 return (
l.clid() ==
r.clid() &&
1148 l.mode() ==
r.mode() &&
1149 l.name() ==
r.name() &&
1150 l.store() ==
r.store());
1157 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
CLID clid(const TKEY &key) const
Retrieve the main CLID of the object recorded in StoreGate with the given "key" WARNING: slow!
std::string context_name(const INamedInterface *context)
Return the context name from a context (this) pointer.
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.
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.
const T * get(const ReadHandleKey< T > &key)
Convenience function to retrieve an object given a ReadHandleKey.
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.