GammaLib  2.0.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GResponseVectorCache Class Reference

Response vector cache class. More...

#include <GResponseVectorCache.hpp>

Inheritance diagram for GResponseVectorCache:
GBase

Public Member Functions

 GResponseVectorCache (void)
 Void constructor. More...
 
 GResponseVectorCache (const GResponseVectorCache &cache)
 Copy constructor. More...
 
virtual ~GResponseVectorCache (void)
 Destructor. More...
 
GResponseVectorCacheoperator= (const GResponseVectorCache &cache)
 Assignment operator. More...
 
void clear (void)
 Clear response vector cache. More...
 
GResponseVectorCacheclone (void) const
 Clone response cache. More...
 
std::string classname (void) const
 Return class name. More...
 
bool is_empty (void) const
 Checks whether the cache is empty. More...
 
int size (void) const
 Returns size of vector chache. More...
 
void set (const std::string &cache_id, const GVector &vector)
 Set cache value. More...
 
void remove (const std::string &cache_id)
 Remove cache. More...
 
bool contains (const std::string &cache_id, GVector *irfs=NULL) const
 Check if cache contains a value for specific parameters. More...
 
std::string print (const GChatter &chatter=NORMAL) const
 Print response cache. More...
 
- Public Member Functions inherited from GBase
virtual ~GBase (void)
 Destructor. More...
 

Protected Member Functions

void init_members (void)
 Initialise class members. More...
 
void copy_members (const GResponseVectorCache &cache)
 Copy class members. More...
 
void free_members (void)
 Delete class members. More...
 
int find_cache (const std::string &cache_id) const
 Find cache. More...
 

Protected Attributes

std::vector< std::string > m_cache_ids
 
std::vector< int > m_cache_entries
 
std::vector< double * > m_cache_values
 
std::vector< int * > m_cache_indices
 

Detailed Description

Response vector cache class.

The class implements a vector cache for the Instrument Response Function values so that the values do not need to be recomputed each time but can be fetched from the cache.

Definition at line 52 of file GResponseVectorCache.hpp.

Constructor & Destructor Documentation

GResponseVectorCache::GResponseVectorCache ( void  )

Void constructor.

Definition at line 54 of file GResponseVectorCache.cpp.

References init_members().

Referenced by clone().

GResponseVectorCache::GResponseVectorCache ( const GResponseVectorCache cache)

Copy constructor.

Parameters
[in]cacheResponse vector cache.

Definition at line 69 of file GResponseVectorCache.cpp.

References copy_members(), and init_members().

GResponseVectorCache::~GResponseVectorCache ( void  )
virtual

Destructor.

Definition at line 85 of file GResponseVectorCache.cpp.

References free_members().

Member Function Documentation

std::string GResponseVectorCache::classname ( void  ) const
inlinevirtual

Return class name.

Returns
String containing the class name ("GResponseVectorCache").

Implements GBase.

Definition at line 97 of file GResponseVectorCache.hpp.

void GResponseVectorCache::clear ( void  )
virtual

Clear response vector cache.

Implements GBase.

Definition at line 137 of file GResponseVectorCache.cpp.

References free_members(), and init_members().

Referenced by GResponse::init_members().

GResponseVectorCache * GResponseVectorCache::clone ( void  ) const
virtual

Clone response cache.

Returns
Pointer to deep copy of response cache.

Implements GBase.

Definition at line 155 of file GResponseVectorCache.cpp.

References GResponseVectorCache().

bool GResponseVectorCache::contains ( const std::string &  cache_id,
GVector vector = NULL 
) const

Check if cache contains a value for specific parameters.

Parameters
[in]cache_idCache identifier.
[in,out]vectorPointer to cached vector (only if found).
Returns
True if cached value was found, otherwise false.

Check if the cache contains a value for a given name, reconstructed energy ereco, and true energy etrue.

If the value pointer argument is not NULL, the method will return the cached value through this argument in case that the value exists.

Definition at line 295 of file GResponseVectorCache.cpp.

References find_cache(), m_cache_entries, m_cache_indices, m_cache_values, and GVector::size().

Referenced by GResponse::irf_spatial().

void GResponseVectorCache::copy_members ( const GResponseVectorCache cache)
protected

Copy class members.

Parameters
[in]cacheResponse cache.

Definition at line 409 of file GResponseVectorCache.cpp.

References m_cache_entries, m_cache_ids, m_cache_indices, m_cache_values, and size().

Referenced by GResponseVectorCache(), and operator=().

int GResponseVectorCache::find_cache ( const std::string &  cache_id) const
protected

Find cache.

Parameters
[in]cache_idCache identifier.
Returns
Cache index (-1 if no cache was found)

Find cache for a given cache_id. If no cache was found the method returns -1.

Definition at line 463 of file GResponseVectorCache.cpp.

References m_cache_ids.

Referenced by contains(), remove(), and set().

void GResponseVectorCache::free_members ( void  )
protected

Delete class members.

Definition at line 439 of file GResponseVectorCache.cpp.

References m_cache_indices, m_cache_values, and size().

Referenced by clear(), operator=(), and ~GResponseVectorCache().

void GResponseVectorCache::init_members ( void  )
protected

Initialise class members.

Definition at line 391 of file GResponseVectorCache.cpp.

References m_cache_entries, m_cache_ids, m_cache_indices, and m_cache_values.

Referenced by clear(), GResponseVectorCache(), and operator=().

bool GResponseVectorCache::is_empty ( void  ) const
inline

Checks whether the cache is empty.

Returns
True if cache is empty, false otherwise.

Checks whether the response cache is empty.

Definition at line 111 of file GResponseVectorCache.hpp.

References m_cache_ids.

GResponseVectorCache & GResponseVectorCache::operator= ( const GResponseVectorCache cache)

Assignment operator.

Parameters
[in]cacheResponse vector cache.
Returns
Response vector cache.

Definition at line 107 of file GResponseVectorCache.cpp.

References copy_members(), free_members(), and init_members().

std::string GResponseVectorCache::print ( const GChatter chatter = NORMAL) const
virtual

Print response cache.

Parameters
[in]chatterChattiness.
Returns
String containing response cache information.

Implements GBase.

Definition at line 353 of file GResponseVectorCache.cpp.

References m_cache_entries, m_cache_ids, gammalib::parformat(), SILENT, size(), and gammalib::str().

void GResponseVectorCache::remove ( const std::string &  cache_id)

Remove cache.

Parameters
[in]cache_idCache identifier.

Remove cache for a given cache_id.

Definition at line 257 of file GResponseVectorCache.cpp.

References find_cache(), m_cache_entries, m_cache_ids, m_cache_indices, and m_cache_values.

Referenced by GResponse::remove_response_cache().

void GResponseVectorCache::set ( const std::string &  cache_id,
const GVector vector 
)

Set cache value.

Parameters
[in]cache_idCache identifier.
[in]vectorCache vector.

Set cache vector for a given cache_id.

Definition at line 169 of file GResponseVectorCache.cpp.

References find_cache(), m_cache_entries, m_cache_ids, m_cache_indices, m_cache_values, GVector::non_zeros(), and GVector::size().

Referenced by GResponse::irf_spatial().

int GResponseVectorCache::size ( void  ) const
inline

Returns size of vector chache.

Returns
Size of vector cache.

Returns the number of vectors that are stored in the vector cache.

Definition at line 125 of file GResponseVectorCache.hpp.

References m_cache_ids.

Referenced by copy_members(), free_members(), and print().

Member Data Documentation

std::vector<int> GResponseVectorCache::m_cache_entries
protected

Definition at line 85 of file GResponseVectorCache.hpp.

Referenced by contains(), copy_members(), init_members(), print(), remove(), and set().

std::vector<std::string> GResponseVectorCache::m_cache_ids
protected
std::vector<int*> GResponseVectorCache::m_cache_indices
protected

Definition at line 87 of file GResponseVectorCache.hpp.

Referenced by contains(), copy_members(), free_members(), init_members(), remove(), and set().

std::vector<double*> GResponseVectorCache::m_cache_values
protected

Definition at line 86 of file GResponseVectorCache.hpp.

Referenced by contains(), copy_members(), free_members(), init_members(), remove(), and set().


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