#include <itkObjectStore.h>
Inheritance diagram for itk::ObjectStore:
Public Types | |
typedef ObjectStore | Self |
typedef Object | Superclass |
typedef SmartPointer< Self > | Pointer |
typedef SmartPointer< const Self > | ConstPointer |
typedef TObjectType | ObjectType |
typedef std::vector< ObjectType * > | FreeListType |
enum | GrowthStrategyType { LINEAR_GROWTH = 0, EXPONENTIAL_GROWTH = 1 } |
Public Methods | |
virtual const char * | GetClassName () const |
ObjectType * | Borrow () |
void | Return (ObjectType *p) |
virtual::vcl_size_t | GetSize () |
void | Reserve (::vcl_size_t n) |
void | Squeeze () |
void | Clear () |
void | SetGrowthStrategyToExponential () |
void | SetGrowthStrategyToLinear () |
virtual void | SetLinearGrowthSize (::vcl_size_t _arg) |
virtual::vcl_size_t | GetLinearGrowthSize () |
virtual void | SetGrowthStrategy (GrowthStrategyType _arg) |
virtual GrowthStrategyType | GetGrowthStrategy () |
Static Public Methods | |
Pointer | New () |
Protected Methods | |
ObjectStore () | |
~ObjectStore () | |
virtual void | PrintSelf (std::ostream &os, Indent indent) const |
::vcl_size_t | GetGrowthSize () |
ObjectStore implements a dynamically sizeable free memory store, from which instantiated objects can be borrowed and returned without always invoking calls to new/delete. This type of memory management is useful in situations where calls to new/delete may be expensive, such as a multithreaded environment to avoid the heap contention problem.
ObjectStore is designed to grow dynamically. Shrinking is a more difficult problem and is only done if it will not invalidate any pointers that have been "lent" to a calling application.
This implementation uses a very simple, list-based scheme to manage pointers that have been borrowed and returned. Memory overhead incurred is one pointer per object allocated. Because of this overhead, ObjectStore is not efficient for use with small objects such as native types.
Warnings: For efficiency reasons, the ObjectStore cannot guard against the same pointer being Returned() more than once. Doing this could result in serious problems.
Definition at line 50 of file itkObjectStore.h.
|
Reimplemented from itk::Object. Definition at line 57 of file itkObjectStore.h. |
|
Type of list for storing pointers to free memory. Definition at line 69 of file itkObjectStore.h. |
|
Type of the objects in storage. Definition at line 66 of file itkObjectStore.h. |
|
Reimplemented from itk::Object. Definition at line 56 of file itkObjectStore.h. |
|
Standard typedefs. Reimplemented from itk::Object. Definition at line 54 of file itkObjectStore.h. |
|
Reimplemented from itk::Object. Definition at line 55 of file itkObjectStore.h. |
|
Type of memory allocation strategy Definition at line 72 of file itkObjectStore.h. |
|
|
|
|
|
Borrow a pointer to an object from the memory store. |
|
Frees all memory in the container |
|
Run-time type information (and related methods). Reimplemented from itk::Object. |
|
Returns a new size to grow. |
|
Set/Get the growth strategy. |
|
Set/Get the linear growth size |
|
Returns the size of the container. This is not the number of objects available, but the total number of objects allocated. |
|
Method for creation through the object factory. Reimplemented from itk::Object. |
|
Methods invoked by Print() to print information about the object including superclasses. Typically not called by the user (use Print() instead) but used in the hierarchical print process to combine the output of several classes. Reimplemented from itk::Object. |
|
Ensures that there are at least n elements allocated in the storage container. Will not shrink the container, but may enlarge the container. |
|
Return a pointer to the memory store for reuse. WARNING: The ObjectStore assumes a pointer is returned exactly once after each time it has been borrowed. |
|
Set/Get the growth strategy. |
|
Set growth strategy to exponential Definition at line 109 of file itkObjectStore.h. |
|
Set growth strategy to linear Definition at line 113 of file itkObjectStore.h. References HardConnectedComponentImageFilter::PrintSelf(). |
|
Set/Get the linear growth size |
|
Attempts to free memory that is not in use and shrink the size of the container. Not guaranteed to do anything. |