|
ATLAS Offline Software
|
Go to the documentation of this file.
24 #include "GaudiKernel/MsgStream.h"
29 #include "GaudiKernel/ThreadLocalContext.h"
46 std::ostringstream
ss;
49 <<
"[" << context->
clid() <<
"]"
74 virtual const std::type_info&
tinfo()
const override {
return typeid(void); }
79 virtual void lock()
override { }
100 m_key (m_ownedKey.
get())
104 std::cerr <<
"VarHandleBase() " <<
this << std::endl;
117 const std::string&
sgkey,
119 const std::string& storename) :
124 m_storeWasSet(false),
126 m_key (m_ownedKey.
get())
141 const EventContext* ctx)
146 m_storeWasSet(false),
149 if (
key.storeHandle().get() ==
nullptr) {
151 key.storeHandle().name());
156 key.storeHandle().name());
174 m_storeWasSet (true),
178 m_store ? m_store->
name() :
"")),
179 m_key (m_ownedKey.
get())
193 m_store(rhs.m_store),
194 m_storeWasSet(rhs.m_storeWasSet)
205 std::cerr <<
"::VHB::copy constr from " << &rhs
206 <<
" to " <<
this <<
", "
207 <<
"proxy=" << this->
m_proxy <<
", "
208 <<
"key=" <<this->
key()
223 m_store(rhs.m_store),
224 m_storeWasSet(rhs.m_storeWasSet),
225 m_ownedKey (std::move (rhs.m_ownedKey)),
229 m_ownedKey->setOwningHandle (
this);
235 rhs.m_proxy->unbindHandle (&rhs);
236 rhs.m_proxy->bindHandle(
this);
238 m_proxy = rhs.m_proxy;
242 std::cerr <<
"::VHB:: move constr from " << &rhs
243 <<
"to " <<
this <<
", "
244 <<
"proxy=" << this->m_proxy <<
", "
245 <<
"key=" <<this->
key()
274 std::cerr <<
"::VHB::assignment from " << &rhs
275 <<
" to " <<
this <<
", "
276 <<
"proxy=" << this->
m_proxy <<
", "
277 <<
"key=" <<this->
key()
291 m_ownedKey = std::move (rhs.m_ownedKey);
293 m_ownedKey->setOwningHandle (
this);
298 m_store = rhs.m_store;
299 m_storeWasSet = rhs.m_storeWasSet;
306 rhs.m_proxy->unbindHandle (&rhs);
307 rhs.m_proxy->bindHandle (
this);
309 m_proxy = rhs.m_proxy;
314 std::cerr <<
"::VHB:: move assign from " << &rhs
315 <<
" to " <<
this <<
", "
316 <<
"proxy=" << this->m_proxy <<
", "
317 <<
"key=" <<this->
key()
330 std::cerr <<
"~VarHandleBase(" <<
this
331 <<
",ptr=" << this->
m_ptr
332 <<
",proxy=" << this->
m_proxy <<
", ";
337 std::cerr <<
", key=" <<this->
key() <<
")...\n";
412 std::cerr <<
"::VHB::isInitialized("
414 <<
", proxy" <<
m_proxy <<
") const\n";
440 std::cerr <<
"::VHB::isConst("
448 std::cerr <<
") const\n";
471 return StatusCode::SUCCESS;
483 return StatusCode::FAILURE;
486 return StatusCode::SUCCESS;
516 if (
sc.isFailure() &&
mode() == Gaudi::DataHandle::Writer &&
m_ptr ==
nullptr)
517 return StatusCode::SUCCESS;
539 return StatusCode::SUCCESS;
555 std::cerr <<
"::VHB::reset("
556 <<
"ptr=" << this->
m_ptr <<
", "
557 <<
"proxy=" << this->
m_proxy <<
", "
558 <<
"key=" <<this->
key()
585 std::cerr <<
"::VHB::finalReset("
586 <<
"ptr=" << this->
m_ptr <<
", "
587 <<
"proxy=" << this->
m_proxy <<
", "
588 <<
"key=" <<this->
key()
603 return StatusCode::SUCCESS;
605 return StatusCode::FAILURE;
656 std::cerr <<
"::VHB::setState("
659 std::cerr <<
" -- isValid: " <<
proxy->isValid()
660 <<
" -- isConst: " <<
proxy->isConst();
662 std::cerr <<
") const\n";
665 return StatusCode::FAILURE;
675 return StatusCode::SUCCESS;
688 return StatusCode::FAILURE;
691 std::cerr <<
"::VHB::setState("
692 <<
store->name() <<
", "
728 if (this->
name().empty()) {
729 REPORT_ERROR (StatusCode::FAILURE) <<
"Attempt to record an object with a null key";
730 return StatusCode::FAILURE;
734 unsigned int initRefCount = sptr->refCount();
738 REPORT_ERROR (StatusCode::FAILURE) <<
"recordObject failed";
740 return StatusCode::FAILURE;
746 if (new_proxy && initRefCount == sptr->refCount() && new_proxy->
isValid()) {
752 <<
"Found an existing const object from recordOrRetrieve.";
753 return StatusCode::FAILURE;
760 m_ptr=(
void*)dataPtr;
762 return StatusCode::SUCCESS;
785 std::unique_ptr<DataObject> dobj,
792 REPORT_ERROR (StatusCode::FAILURE) <<
"Attempt to record an object with a null key";
803 unsigned int initRefCount = sptr->refCount();
805 store->recordObject (sptr, this->
name(), allowMods, returnExisting);
807 REPORT_ERROR (StatusCode::FAILURE) <<
"recordObject failed";
811 if (new_proxy && initRefCount == sptr->refCount() && new_proxy->
isValid()) {
829 std::cerr <<
"::VHB::typeless_dataPointer_impl("
831 <<
",ptr=" << this->
m_ptr
832 <<
",proxy=" << this->
m_proxy <<
", ";
837 std::cerr <<
", key=" <<this->
key() <<
")...\n";
849 <<
"could not get proxy for key " <<
key();
850 if (this->
mode() != Gaudi::DataHandle::Reader) {
889 if (this->
mode() != Gaudi::DataHandle::Reader) {
892 <<
"get_impl called for a non-read handle.";
899 <<
"Cannot initialize a Read/Write/Update handle with a null key.";
914 <<
"Cannot find proxy for "
915 << this->
clid() <<
"/" << this->
key();
934 const std::string& newKey)
937 REPORT_ERROR (StatusCode::FAILURE) <<
"symlink: Handle not valid.";
938 return StatusCode::FAILURE;
944 return StatusCode::FAILURE;
945 return StatusCode::SUCCESS;
1033 proxy->bindHandle (
this);
1057 <<
"/" << (
proxy != 0
1059 : std::string(
"<N/A>"))
1060 <<
"] is in an invalid state";
1065 DataObject* dobj =
proxy->accessData();
1070 <<
"this proxy " << MSG::hex <<
proxy
1071 << MSG::dec <<
" has a NULL data object ptr";
1089 ptr =
static_cast<void*
>(dbb->
object());
1093 <<
"Request for an invalid object; requested CLID = "
1095 <<
", proxy primary ID is " <<
proxy->clID();
1119 return proxy->isValid();
1137 out <<
"VarHandleBase @" << &o
1138 <<
" store=" <<o.
store()
1139 <<
", clid=" <<o.
clid()
1140 <<
", key=" <<o.
key()
1141 <<
"----------- ptr@" << o.
m_ptr
1144 out <<
", DataObject@" << o.
m_proxy->object();
1152 bool operator==(
const VarHandleBase&
l,
const VarHandleBase&
r)
1154 return (
l.clid() ==
r.clid() &&
1155 l.mode() ==
r.mode() &&
1156 l.name() ==
r.name() &&
1157 l.store() ==
r.store());
1164 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.
virtual 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.
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?
#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
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:
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.