LSST Applications g00d0e8bbd7+edbf708997,g03191d30f7+9ce8016dbd,g1955dfad08+0bd186d245,g199a45376c+5137f08352,g1fd858c14a+a888a50aa2,g262e1987ae+45f9aba685,g29ae962dfc+1c7d47a24f,g2cef7863aa+73c82f25e4,g35bb328faa+edbf708997,g3fd5ace14f+eed17d2c67,g47891489e3+6dc8069a4c,g53246c7159+edbf708997,g64539dfbff+c4107e45b5,g67b6fd64d1+6dc8069a4c,g74acd417e5+f452e9c21a,g786e29fd12+af89c03590,g7ae74a0b1c+a25e60b391,g7aefaa3e3d+2025e9ce17,g7cc15d900a+2d158402f9,g87389fa792+a4172ec7da,g89139ef638+6dc8069a4c,g8d4809ba88+c4107e45b5,g8d7436a09f+e96c132b44,g8ea07a8fe4+db21c37724,g98df359435+aae6d409c1,ga2180abaac+edbf708997,gac66b60396+966efe6077,gb632fb1845+88945a90f8,gbaa8f7a6c5+38b34f4976,gbf99507273+edbf708997,gca7fc764a6+6dc8069a4c,gd7ef33dd92+6dc8069a4c,gda68eeecaf+7d1e613a8d,gdab6d2f7ff+f452e9c21a,gdbb4c4dda9+c4107e45b5,ge410e46f29+6dc8069a4c,ge41e95a9f2+c4107e45b5,geaed405ab2+e194be0d2b,w.2025.47
LSST Data Management Base Package
Loading...
Searching...
No Matches
lsst::afw::fits::HduMoveGuard Class Reference

RAII scoped guard for moving the HDU in a Fits object. More...

#include <fits.h>

Public Member Functions

 HduMoveGuard ()=delete
 
 HduMoveGuard (HduMoveGuard const &)=delete
 
 HduMoveGuard (HduMoveGuard &&)=delete
 
HduMoveGuardoperator= (HduMoveGuard const &)=delete
 
HduMoveGuardoperator= (HduMoveGuard &&)=delete
 
 HduMoveGuard (Fits &fits, int hdu, bool relative=false)
 Create a guard object and set the HDU of the given Fits object at the same time.
 
 ~HduMoveGuard ()
 
void disable ()
 Disable the guard, leaving the HDU at its current state at destruction.
 

Detailed Description

RAII scoped guard for moving the HDU in a Fits object.

This class attempts to ensure that the HDU state of a Fits object is restored when the guard class goes out of scope, even in the presence of exceptions. (In practice, resetting the HDU can only fail if the Fits object has become sufficiently corrupted that it's no longer usable at all).

Definition at line 706 of file fits.h.

Constructor & Destructor Documentation

◆ HduMoveGuard() [1/4]

lsst::afw::fits::HduMoveGuard::HduMoveGuard ( )
delete

◆ HduMoveGuard() [2/4]

lsst::afw::fits::HduMoveGuard::HduMoveGuard ( HduMoveGuard const & )
delete

◆ HduMoveGuard() [3/4]

lsst::afw::fits::HduMoveGuard::HduMoveGuard ( HduMoveGuard && )
delete

◆ HduMoveGuard() [4/4]

lsst::afw::fits::HduMoveGuard::HduMoveGuard ( Fits & fits,
int hdu,
bool relative = false )

Create a guard object and set the HDU of the given Fits object at the same time.

Parameters
[in,out]fitsFITS file pointer to manipulate.
[in]hduHDU index moved to within the lifetime of the guard object (0 is primary).
[in]relativeIf True, interpret hdu as relative to the current HDU rather than an absolute index.

Definition at line 1876 of file fits.cc.

1876 :
1877 _fits(fits),
1878 _oldHdu(_fits.getHdu()),
1879 _enabled(true)
1880{
1881 _fits.setHdu(hdu, relative);
1882}

◆ ~HduMoveGuard()

lsst::afw::fits::HduMoveGuard::~HduMoveGuard ( )

Definition at line 1884 of file fits.cc.

1884 {
1885 if (!_enabled) {
1886 return;
1887 }
1888 int status = 0;
1889 std::swap(status, _fits.status); // unset error indicator, but remember the old status
1890 try {
1891 _fits.setHdu(_oldHdu);
1892 } catch (...) {
1893 LOGL_WARN(
1894 "afw.fits",
1895 makeErrorMessage(_fits.fptr, _fits.status, "Failed to move back to HDU %d").c_str(),
1896 _oldHdu
1897 );
1898 }
1899 std::swap(status, _fits.status); // reset the old status
1900}
#define LOGL_WARN(logger, message...)
Log a warn-level message using a varargs/printf style interface.
Definition Log.h:547
T c_str(T... args)
std::string makeErrorMessage(std::string const &fileName="", int status=0, std::string const &msg="")
Return an error message reflecting FITS I/O errors.
Definition fits.cc:396
T swap(T... args)

Member Function Documentation

◆ disable()

void lsst::afw::fits::HduMoveGuard::disable ( )
inline

Disable the guard, leaving the HDU at its current state at destruction.

Definition at line 733 of file fits.h.

733{ _enabled = false; }

◆ operator=() [1/2]

HduMoveGuard & lsst::afw::fits::HduMoveGuard::operator= ( HduMoveGuard && )
delete

◆ operator=() [2/2]

HduMoveGuard & lsst::afw::fits::HduMoveGuard::operator= ( HduMoveGuard const & )
delete

The documentation for this class was generated from the following files: