LSSTApplications  10.0+286,10.0+36,10.0+46,10.0-2-g4f67435,10.1+152,10.1+37,11.0,11.0+1,11.0-1-g47edd16,11.0-1-g60db491,11.0-1-g7418c06,11.0-2-g04d2804,11.0-2-g68503cd,11.0-2-g818369d,11.0-2-gb8b8ce7
LSSTDataManagementBasePackage
Public Member Functions | Private Attributes | Friends | List of all members
lsst::afw::fits::MemFileManager Class Reference

Lifetime-management for memory that goes into FITS memory files. More...

#include <fits.h>

Inheritance diagram for lsst::afw::fits::MemFileManager:

Public Member Functions

 MemFileManager ()
 Construct a MemFileManager with no initial memory buffer. More...
 
 MemFileManager (std::size_t len)
 Construct a MemFileManager with (len) bytes of initial memory. More...
 
 MemFileManager (void *ptr, std::size_t len)
 Construct a MemFileManager that references and does not manage external memory. More...
 
void reset ()
 Return the manager to the same state it would be if default-constructed. More...
 
void reset (std::size_t len)
 Set the size of the internal memory buffer, freeing the current buffer if necessary. More...
 
void reset (void *ptr, std::size_t len)
 Set the internal memory buffer to an manually-managed external block. More...
 
 ~MemFileManager ()
 
void * getData () const
 Return the buffer. More...
 
std::size_t getLength () const
 Return the buffer length. More...
 

Private Attributes

void * _ptr
 
std::size_t _len
 
bool _managed
 

Friends

class Fits
 

Detailed Description

Lifetime-management for memory that goes into FITS memory files.

Definition at line 106 of file fits.h.

Constructor & Destructor Documentation

lsst::afw::fits::MemFileManager::MemFileManager ( )
inline

Construct a MemFileManager with no initial memory buffer.

The manager will still free the memory when it goes out of scope, but all allocation and reallocation will be performed by cfitsio as needed.

Definition at line 115 of file fits.h.

lsst::afw::fits::MemFileManager::MemFileManager ( std::size_t  len)
inlineexplicit

Construct a MemFileManager with (len) bytes of initial memory.

The manager will free the memory when it goes out of scope, and cfitsio will be allowed to reallocate the internal memory as needed.

Definition at line 123 of file fits.h.

123 : _ptr(0), _len(0), _managed(true) { reset(len); }
void reset()
Return the manager to the same state it would be if default-constructed.
lsst::afw::fits::MemFileManager::MemFileManager ( void *  ptr,
std::size_t  len 
)
inline

Construct a MemFileManager that references and does not manage external memory.

The manager will not manage the given pointer, and it will not allow cfitsio to do so either. The user must provide enough initial memory and is responsible for freeing it manually after the FITS file has been closed.

Definition at line 132 of file fits.h.

132 : _ptr(ptr), _len(len), _managed(false) {}
lsst::afw::fits::MemFileManager::~MemFileManager ( )
inline

Definition at line 161 of file fits.h.

161 { reset(); }
void reset()
Return the manager to the same state it would be if default-constructed.

Member Function Documentation

void* lsst::afw::fits::MemFileManager::getData ( ) const
inline

Return the buffer.

Definition at line 164 of file fits.h.

164 { return _ptr; }
std::size_t lsst::afw::fits::MemFileManager::getLength ( ) const
inline

Return the buffer length.

Definition at line 167 of file fits.h.

167 { return _len; }
void lsst::afw::fits::MemFileManager::reset ( )

Return the manager to the same state it would be if default-constructed.

This must not be called while a FITS file that uses this memory is open.

void lsst::afw::fits::MemFileManager::reset ( std::size_t  len)

Set the size of the internal memory buffer, freeing the current buffer if necessary.

This must not be called while a FITS file that uses this memory is open.

Memory allocated with this overload of reset can be reallocated by cfitsio and will be freed when the manager goes out of scope or is reset.

void lsst::afw::fits::MemFileManager::reset ( void *  ptr,
std::size_t  len 
)
inline

Set the internal memory buffer to an manually-managed external block.

This must not be called while a FITS file that uses this memory is open.

Memory passed to this overload of reset cannot be reallocated by cfitsio and will not be freed when the manager goes out of scope or is reset.

Definition at line 159 of file fits.h.

159 { reset(); _ptr = ptr; _len = len; _managed = false; }
void reset()
Return the manager to the same state it would be if default-constructed.

Friends And Related Function Documentation

friend class Fits
friend

Definition at line 171 of file fits.h.

Member Data Documentation

std::size_t lsst::afw::fits::MemFileManager::_len
private

Definition at line 174 of file fits.h.

bool lsst::afw::fits::MemFileManager::_managed
private

Definition at line 175 of file fits.h.

void* lsst::afw::fits::MemFileManager::_ptr
private

Definition at line 173 of file fits.h.


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