SLBM: slbm::CrustalProfileStore Class Reference

SLBM 3.0 Regional Seismic Travel Time

- Main Page
- Namespaces
- Classes
- Files

- Class List
- Class Hierarchy
- Class Members

Public Member Functions | Private Attributes | List of all members
slbm::CrustalProfileStore Class Reference

CrustalProfileStore supports pool allocation for CrustalProfile objects. More...

`#include <CrustalProfileStore.h>`

## Public Member Functions
| CrustalProfileStore (Grid &grid, const int &maxSize)
| Constructor. More...
| ~CrustalProfileStore ()
| Destructor. More...
void | clear ()
CrustalProfile * | getCrustalProfile (const int &phase, const double &lat, const double &lon, const double &depth)
int | getNCrustalProfiles ()
size_t | memSize ()

## Private Attributes
Grid & | grid
int | maxSize
map< string, CrustalProfile * > | profiles
list< string > | priority
list< CrustalProfile * > | pool
string | locString

## Detailed Description

CrustalProfileStore supports pool allocation for CrustalProfile objects. Grid owns two CrustalProfileStore objects, one for seismic sources and a separate one for seismic receivers. When a GreatCircle object is created, it needs two CrustalProfile objects, one for the source and one for the receiver. It requests these CrustalProfile objects from the Grid object and Grid requests them from the two CrustalProfileStore objects. A Grid object requests a CrustalProfile object from a CrustalProfileStore by calling CrustalProfileStore::getCrustalProfile(phase, lat, lon, depth). When it receives such a request CrustalProfileStore searches its internal containers to see if it already has a CrustalProfile object for that phase/location. If it does, it returns a handle to the existing CrustalProfile object and promotes the priority of that CrustalProfile object to the highest level. If it does not already have a CrustalProfile object for the specified phase/location, it pops a reference to a previously used CrustalProfile object that it keeps in a pool of previously instantiated but currently unused objects and resets the data in the CrustalProfile object for the new phase/location. If the pool is empty, it constructs a new CrustalProfile object. It then pushes the Crustal Profile object onto the head of the priority list. If the priority list reaches its maximum size, then CrustalProfileStore pops the CrustalProfile object with the lowest priority off the back of the priority list and returns it to the pool of unused CrustalProfile objects.

There is an important assumption being made here and that is that when CrustalProfileStore::getCrustalProfile(phase, lat, lon, depth) is called, there are no valid references to any CrustalProfile objects out in the application. This is necessary so that CrustalProfileStore can reset the information contained in CrustalProfile that it pops off the pool of unused objects. As currently implemented this condition is satisfied in SLBM. CrustalProfile objects are owned only by GreatCircle objects. SlbmInterface objects maintain a reference to a single GreatCircle object at a time. When an application requests a new GreatCircle object, SlbmInterface deletes the current GreatCircle object (if it currently has one) and then instantiates a new GreatCircle object. Since only one GreatCircle exists at a time, there can be no valid references to any CrustalProfile at the time that CrustalProfileStore::getCrustalProfile(phase, lat, lon, depth) is called.

## Constructor & Destructor Documentation

slbm::CrustalProfileStore::CrustalProfileStore | ( | Grid & | grid,
|  | const int & | maxSize
| ) |  |

slbm::CrustalProfileStore::~CrustalProfileStore | ( |  | ) |

## Member Function Documentation

void slbm::CrustalProfileStore::clear | ( |  | ) |

CrustalProfile* slbm::CrustalProfileStore::getCrustalProfile | ( | const int & | phase,
|  | const double & | lat,
|  | const double & | lon,
|  | const double & | depth
| ) |  |

int slbm::CrustalProfileStore::getNCrustalProfiles | ( |  | ) |
| inline

size_t slbm::CrustalProfileStore::memSize | ( |  | ) |
| inline

## Member Data Documentation

Grid& slbm::CrustalProfileStore::grid
| private

string slbm::CrustalProfileStore::locString
| private

int slbm::CrustalProfileStore::maxSize
| private

list<CrustalProfile*> slbm::CrustalProfileStore::pool
| private

list<string> slbm::CrustalProfileStore::priority
| private

map<string, CrustalProfile*> slbm::CrustalProfileStore::profiles
| private

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

- /nfs/tonto2/devlpool/sballar/RSTT/SLBM_Root.3.0.5/install/SLBM_Root.3.0.5.Linux/SLBM/include/CrustalProfileStore.h