Loading...
Searching...
No Matches
casacore::ObjectStack< T > Class Template Reference
casa package (libcasa_casa) » Containers_module

More...

`#include <ObjectStack.h>`

## Public Member Functions

| ~ObjectStack ()
| Destructor.
T * | get ()
| Get a pointer to an object in the stack.
void | put (T *obj)
| Return an object to the stack for re-use.
void | clear ()
| Decimate the stack by getting rid of all unused elements in it.
Bool | empty ()
| Test if stack empty.
uInt | nelements () const
| return the stack extend (for debugging use and checking mainly)

## Static Public Member Functions

static ObjectStack< T > & | stack ()
| Create a singleton stack.

## Private Member Functions

| ObjectStack ()
| All ctor and assignment constructors and assignment (not implemented).
| ObjectStack (const ObjectStack< T > &other)
ObjectStack< T > & | operator= (const ObjectStack< T > &other)

## Private Attributes

std::vector< T * > | stack_p
| The Stack.
std::mutex | mutex_p

## Detailed Description

template<class T>
class casacore::ObjectStack< T >

A stack of re-usable objects

### Intended use:

Public interface

### Review Status

Reviewed By:
  Ger van Diepen
Date Reviewed:
  2001/07/03
Test programs:
  tObjectStack

### Prerequisite

### Synopsis

An ObjectStack contains a set of pre-allocated Objects of the type T. The stack is a very simple stack, without the linking/unlinking of a normal Stack implementation. This lightweight implementation was especially designed for use with the AutoDiff classes, but can be used independently. The stack works best with small object sizes, or letter/envelope classes.

The class is fully thread-safe, thus the same object can be used safely in multiple threads.

### Example

{
// Get an element (and create stack!)
SparseDiff<Double> elem;
// Use it
elem.value() = 27;
// Release it (automatic by dtor on elem)
}
casacore::SparseDiff
Definition SparseDiff.h:276
casacore::SparseDiff::value
T & value()
Returns the value of the function.
Definition SparseDiff.h:349

### Motivation

To improve the speed for the auto differentiating classes.

### Template Type Argument Requirements (T)

- the class T must have a constructor(T::FULLREFRESH) for creating new entries and destructor; and must possess a clear() method to enable element re-use.

Definition at line 92 of file ObjectStack.h.

## Constructor & Destructor Documentation

## ~ObjectStack()

template<class T>

casacore::ObjectStack< T >::~ObjectStack | ( |  | ) |

Destructor.

## ObjectStack() [1/2]

template<class T>

casacore::ObjectStack< T >::ObjectStack | ( |  | ) |

inline private

All ctor and assignment constructors and assignment (not implemented).

Definition at line 127 of file ObjectStack.h.

References stack_p.

Referenced by ObjectStack(), operator=(), and stack().

## ObjectStack() [2/2]

template<class T>

casacore::ObjectStack< T >::ObjectStack | ( | const ObjectStack< T > & | other | ) |

private

References ObjectStack().

## Member Function Documentation

## clear()

template<class T>

void casacore::ObjectStack< T >::clear | ( |  | ) |

Decimate the stack by getting rid of all unused elements in it.

## empty()

template<class T>

Bool casacore::ObjectStack< T >::empty | ( |  | ) |

inline

Test if stack empty.

Definition at line 113 of file ObjectStack.h.

References stack_p.

## get()

template<class T>

T * casacore::ObjectStack< T >::get | ( |  | ) |

Get a pointer to an object in the stack.

The stack will be extended if no objects left.

## nelements()

template<class T>

uInt casacore::ObjectStack< T >::nelements | ( |  | ) | const

inline

return the stack extend (for debugging use and checking mainly)

Definition at line 116 of file ObjectStack.h.

References stack_p.

## operator=()

template<class T>

ObjectStack< T > & casacore::ObjectStack< T >::operator= | ( | const ObjectStack< T > & | other | ) |

private

References ObjectStack().

## put()

template<class T>

void casacore::ObjectStack< T >::put | ( | T * | obj | ) |

inline

Return an object to the stack for re-use.

Definition at line 107 of file ObjectStack.h.

References stack_p.

## stack()

template<class T>

ObjectStack< T > & casacore::ObjectStack< T >::stack | ( |  | ) |

static

Create a singleton stack.

References ObjectStack().

## Member Data Documentation

## mutex_p

template<class T>

std::mutex casacore::ObjectStack< T >::mutex_p

private

Definition at line 122 of file ObjectStack.h.

## stack_p

template<class T>

std::vector<T*> casacore::ObjectStack< T >::stack_p

private

The Stack.

Definition at line 121 of file ObjectStack.h.

Referenced by empty(), nelements(), ObjectStack(), and put().

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

- casa/Containers/ObjectStack.h