Register actions to be performed automatically according to some criteria.
Often, when reading or writing MEF files, the same actions have to be performed for all or some of the HDUs. For example, each time an HDU is accessed for the first time, the checksums can be validated. And before closing the file, the checksums of the edited HDUs can be updated if present.
Instead of doing so manually, e.g.:
... Action
s can be registered in the MefFile
and performed automatically:
This removes boilerplate and noise in the code, and guarantees nothing is forgotten. Moreover, HDUs are guaranteed to be visited only once whatever the action count.
Acions are classes which inherit Action
and override at least one of its methods, like accessed()
or closing()
. Each time an action-related event occurs (an HDU is accessed for the first time or the file is being closed), all of the registered actions which override the corresponding method are executed.
The list of actions registered in the MefFile
constitutes the so-called strategy.
A specific part of the strategy relates to internal compression: it is possible to specify which compression algorithm to use when creating a new image HDU according to predefined criteria. For more details, refer to Image compression.
Actions (or complete strategies) can be registered at construction, like in the introductory example, or using MefFile::strategy()
methods and/or its Strategy
instance.
Predefined actions, provided with the library, are listed below.
Enumerations | |
enum class | UpdateChecksums { None , Outdated , EditedHdu , AnyHdu } |
Checksum update policy of VerifyChecksums . More... | |
Classes | |
class | Action |
Base class for strategy actions. More... | |
class | CiteEleFits |
An action which cites EleFits in the Primary header as a HISTORY record. More... | |
class | Strategy |
MEF file strategy. More... | |
class | VerifyChecksums |
An action which verifies and possibly updates existing checksums. More... | |