![]() |
ATLAS Offline Software
|
RAII guard that guarantees a matching end-incident for every begin-incident. More...
#include <InputFileIncidentGuard.h>
Public Member Functions | |
| ~InputFileIncidentGuard () | |
| Destructor: fires the end incident unless the guard has been moved from (disarmed). | |
| InputFileIncidentGuard (InputFileIncidentGuard &&other) noexcept | |
| Move constructor: takes ownership; the source is disarmed. | |
| InputFileIncidentGuard & | operator= (InputFileIncidentGuard &&other) noexcept |
Move assignment: fires the end incident for the file being replaced (if any), then takes ownership of other. | |
| InputFileIncidentGuard (const InputFileIncidentGuard &)=delete | |
| Copy is not allowed. | |
| InputFileIncidentGuard & | operator= (const InputFileIncidentGuard &)=delete |
| Copy assignment is not allowed. | |
Static Public Member Functions | |
| static InputFileIncidentGuard | begin (IIncidentSvc &incSvc, std::string_view source, std::string_view beginFileName, std::string_view guid, std::string_view endFileName={}, std::string_view beginType=IncidentType::BeginInputFile, std::string_view endType=IncidentType::EndInputFile) |
| Factory: fire the begin incident and return a guard whose destructor fires the matching end incident. | |
| static void | transition (std::optional< InputFileIncidentGuard > &guard, IIncidentSvc &incSvc, std::string_view source, std::string_view beginFileName, std::string_view guid, std::string_view endFileName={}, std::string_view beginType=IncidentType::BeginInputFile, std::string_view endType=IncidentType::EndInputFile) |
| Replace the guard in an optional, with strict End-before-Begin ordering. | |
Private Member Functions | |
| InputFileIncidentGuard (IIncidentSvc &incSvc, std::string_view source, std::string_view beginFileName, std::string_view guid, std::string endFileName, std::string_view beginType, std::string_view endType) | |
Private constructor used by begin(). | |
Private Attributes | |
| IIncidentSvc * | m_incSvc |
| Incident service pointer; nullptr if disarmed (moved-from). | |
| std::string | m_source |
| Source name for both begin and end incidents. | |
| std::string | m_guid |
| File GUID passed to the FileIncident. | |
| std::string | m_endFileName |
| fileName used for the end incident. | |
| std::string | m_endType |
| Incident type string for the end incident (e.g. "EndInputFile"). | |
RAII guard that guarantees a matching end-incident for every begin-incident.
Event selectors fire BeginInputFile / EndInputFile incidents to notify listeners (e.g. MetaDataSvc) of input file transitions. These incidents must always be paired: every Begin must have a matching End. When the firing points are scattered across multiple methods, manual pairing is error-prone – early returns, exceptions, or forgotten calls can leave incidents unmatched.
This guard uses RAII to enforce pairing: the constructor fires the begin incident, and the destructor fires the matching end incident. Instances can only be created through the static begin() factory, which is marked [[nodiscard]] so the compiler warns if the guard is discarded.
transition() instead of direct assignment to guarantee End(old) fires before Begin(new).Typical usage as an std::optional member of an event selector:
Definition at line 75 of file InputFileIncidentGuard.h.
|
inline |
Destructor: fires the end incident unless the guard has been moved from (disarmed).
Definition at line 132 of file InputFileIncidentGuard.h.
|
inlinenoexcept |
Move constructor: takes ownership; the source is disarmed.
Definition at line 141 of file InputFileIncidentGuard.h.
|
delete |
Copy is not allowed.
|
inlineprivate |
Private constructor used by begin().
Definition at line 174 of file InputFileIncidentGuard.h.
|
inlinestaticnodiscard |
Factory: fire the begin incident and return a guard whose destructor fires the matching end incident.
| incSvc | The incident service used to fire incidents. |
| source | Source name passed to the FileIncident (typically the selector's name()). |
| beginFileName | fileName for the begin incident. |
| guid | File GUID passed to the FileIncident. |
| endFileName | fileName for the end incident. Defaults to "FID:" + guid; pass explicitly for eventless files. |
| beginType | Incident type string for the begin incident. |
| endType | Incident type string for the end incident. |
This is the only way to create an instance.
Definition at line 93 of file InputFileIncidentGuard.h.
|
delete |
Copy assignment is not allowed.
|
inlinenoexcept |
Move assignment: fires the end incident for the file being replaced (if any), then takes ownership of other.
Definition at line 151 of file InputFileIncidentGuard.h.
|
inlinestatic |
Replace the guard in an optional, with strict End-before-Begin ordering.
| guard | The optional holding the current guard. It is reset first (firing the end incident for the old file, if any), then a new guard is emplaced (firing the begin incident for the new file). |
The remaining parameters are forwarded to begin(). Use this for file transitions instead of direct assignment.
Definition at line 117 of file InputFileIncidentGuard.h.
|
private |
fileName used for the end incident.
Definition at line 199 of file InputFileIncidentGuard.h.
|
private |
Incident type string for the end incident (e.g. "EndInputFile").
Definition at line 201 of file InputFileIncidentGuard.h.
|
private |
File GUID passed to the FileIncident.
Definition at line 197 of file InputFileIncidentGuard.h.
|
private |
Incident service pointer; nullptr if disarmed (moved-from).
Definition at line 193 of file InputFileIncidentGuard.h.
|
private |
Source name for both begin and end incidents.
Definition at line 195 of file InputFileIncidentGuard.h.