Variant of util::ArtHandleTrackerManager
in local scope.
More...
#include <ArtHandleTrackerManager.h>
Public Types | |
using | Event_t = typename ArtHandleTrackerManager< Event >::Event_t |
Type of the art event. More... | |
Public Member Functions | |
LocalArtHandleTrackerManager (Event const &event, bool removeCache=true) | |
Constructor: operates on the specified event . More... | |
~LocalArtHandleTrackerManager () | |
Destructor; will implement the RAII pattern (i.e. call doneWithEvent() ). More... | |
template<typename Handle > | |
auto | registerHandle (Handle &&handle) -> decltype(auto) |
Queries | |
unsigned int | nTrackedHandles () const |
Returns the number of handles currently tracked. More... | |
bool | willRemoveCachedProducts () const |
Registration of data products | |
template<typename T , typename... Args> | |
art::Handle< T > | getHandle (Args &&...args) |
Retrieves an handle from the event, and registers it. More... | |
template<typename T , typename... Args> | |
art::ValidHandle< T > | getValidHandle (Args &&...args) |
Retrieves a valid handle from the event, and registers it. More... | |
template<typename Handle > | |
decltype(auto) | registerHandle (Handle &&handle) |
Registers an existing handle. More... | |
Operations | |
void | setRemoveCachedProducts (bool removeCache) |
Sets whether to remove tracked data caches on destruction or not. More... | |
unsigned int | removeCachedProducts () |
Clears the cached data products for all tracked handles. More... | |
void | forgetAllHandles () |
Stops tracking any handle, without removing their cache first. More... | |
unsigned int | doneWithEvent (bool removeCache) |
Completes the work on the associated event . More... | |
unsigned int | doneWithEvent () |
Completes the work on the associated event . More... | |
Private Attributes | |
ArtHandleTrackerManager< Event > | fManager |
The actual manager doing the work. More... | |
bool | fRemoveCache |
Whether to remove cache on destructor. More... | |
Variant of util::ArtHandleTrackerManager
in local scope.
Event | the type of data product source (the "principal") to serve |
This class allows the removal of data products cached in an event. The general functionality is described in util::ArtHandleTrackerManager
.
This class in particular offers a tuned interface for the case where the object is local (which is convenient for multithreading and if all the reading and usage happens in the same scope):
Whether the object will actually remove the caches can be decided on construction (by default it does), and then changed with setRemoveCachedProducts()
. The removal can also be anticipated by explicitly calling doneWithEvent()
(no event
parameter is supported), after which the destruction will not do anything.
Example:
Definition at line 33 of file ArtHandleTrackerManager.h.
using util::LocalArtHandleTrackerManager< Event >::Event_t = typename ArtHandleTrackerManager<Event>::Event_t |
Type of the art event.
Definition at line 429 of file ArtHandleTrackerManager.h.
util::LocalArtHandleTrackerManager< Event >::LocalArtHandleTrackerManager | ( | Event const & | event, |
bool | removeCache = true |
||
) |
Constructor: operates on the specified event
.
event | the event this object will operate on |
removeCache | (default: true ) remove tracked data caches when done |
The parameter removeCache
controls whether the data caches are removed on destruction. It may be changed along the way with setRemoveCachedProducts()
.
Definition at line 997 of file ArtHandleTrackerManager.h.
util::LocalArtHandleTrackerManager< Event >::~LocalArtHandleTrackerManager | ( | ) |
Destructor; will implement the RAII pattern (i.e. call doneWithEvent()
).
Definition at line 1004 of file ArtHandleTrackerManager.h.
unsigned int util::LocalArtHandleTrackerManager< Event >::doneWithEvent | ( | bool | removeCache | ) |
Completes the work on the associated event
.
removeCache | (default: true ) removes tracked data product caches |
doneWithEvent()
This is a shortcut for having optional release of cache in a single call, depending on the value of removeCache
:
true
, removeCachedProducts()
is called and its count is returned;false
, forgetAllHandles()
is called and 0
is returned.Differently from util::ArtHandleTrackerManager
, the object is not disassociated from the event: new handles can be registered and the clearing settings are preserved as they are. To be really done with the event, setRemoveCachedProducts()
needs to be set to false
, and users should refrain from calling `removeCachedProducts().
This method ignores and overrides the value set by setRemoveCachedProducts()
and the one at construction.
Definition at line 1068 of file ArtHandleTrackerManager.h.
unsigned int util::LocalArtHandleTrackerManager< Event >::doneWithEvent | ( | ) |
Completes the work on the associated event
.
This is a shortcut for having optional release of cache in a single call, depending on the value of willRemoveCachedProducts()
:
true
, removeCachedProducts()
is called and its count is returned;false
, forgetAllHandles()
is called and 0
is returned.In addition, the object is disassociated from the event, and the object will not be available for use any more.
Definition at line 1081 of file ArtHandleTrackerManager.h.
void util::LocalArtHandleTrackerManager< Event >::forgetAllHandles | ( | ) |
Stops tracking any handle, without removing their cache first.
Definition at line 1061 of file ArtHandleTrackerManager.h.
art::Handle< T > util::LocalArtHandleTrackerManager< Event >::getHandle | ( | Args &&... | args | ) |
Retrieves an handle from the event, and registers it.
T | type of data product to retrieve |
Args | types of the arguments needed by art::getHandle() |
args | all the arguments that art::getHandle() requires |
getValidHandle()
, registerHandle()
This function wraps art::Event::getHandle()
, calling it to obtain the handle and then registering it (like with registerHandle()
).
Definition at line 1024 of file ArtHandleTrackerManager.h.
art::ValidHandle< T > util::LocalArtHandleTrackerManager< Event >::getValidHandle | ( | Args &&... | args | ) |
Retrieves a valid handle from the event, and registers it.
T | type of data product to retrieve |
Args | types of the arguments needed by art::getValidHandle() |
args | all the arguments that art::getValidHandle() requires |
getHandle()
, registerHandle()
This is the art::ValidHandle
sibling of getHandle()
. See that one for details.
Definition at line 1032 of file ArtHandleTrackerManager.h.
unsigned int util::LocalArtHandleTrackerManager< Event >::nTrackedHandles | ( | ) | const |
Returns the number of handles currently tracked.
Definition at line 1010 of file ArtHandleTrackerManager.h.
decltype(auto) util::LocalArtHandleTrackerManager< Event >::registerHandle | ( | Handle && | handle | ) |
Registers an existing handle.
Handle | the type of handle to register |
handle | the handle to be registered |
handle
is passed throughThis method registers a copy of handle
into the manager.
auto util::LocalArtHandleTrackerManager< Event >::registerHandle | ( | Handle && | handle | ) | -> decltype(auto) |
Definition at line 1040 of file ArtHandleTrackerManager.h.
unsigned int util::LocalArtHandleTrackerManager< Event >::removeCachedProducts | ( | ) |
Clears the cached data products for all tracked handles.
This method calls Event_t::removeCachedProduct()
for all tracked handles. This is the core functionality of the manager, which removes the cache of all tracked handles.
The art framework always makes the handles used to remove the cache invalid (Handle::clear()
). After the removal, the object stops tracking the handles (like with a call to forgetAllHandles()
).
Calling this method when there are no handles registered has no effect.
Definition at line 1055 of file ArtHandleTrackerManager.h.
void util::LocalArtHandleTrackerManager< Event >::setRemoveCachedProducts | ( | bool | removeCache | ) |
Sets whether to remove tracked data caches on destruction or not.
removeCache | if true , data caches will be removed on destruction |
Definition at line 1049 of file ArtHandleTrackerManager.h.
bool util::LocalArtHandleTrackerManager< Event >::willRemoveCachedProducts | ( | ) | const |
Returns whether caches will be removed on destruction.
setRemoveCachedProducts()
Definition at line 1016 of file ArtHandleTrackerManager.h.
|
private |
The actual manager doing the work.
Definition at line 422 of file ArtHandleTrackerManager.h.
|
private |
Whether to remove cache on destructor.
Definition at line 424 of file ArtHandleTrackerManager.h.