|
A TfStacked is used where a class needs to keep a stack of the objects currently in existence. More...
#include <stacked.h>
Public Types | |
typedef Holder | Storage |
typedef Storage::Stack | Stack |
Public Member Functions | |
TfStacked () | |
Pushes this stacked object onto the stack. | |
~TfStacked () | |
Pops this stacked object from the stack. | |
Static Public Member Functions | |
static Derived const * | GetStackTop () |
Returns the top of the stack. | |
static Derived const * | GetStackPrevious () |
Returns the element under the top of the stack. | |
static Stack const & | GetStack () |
Returns a const reference to the entire stack. | |
static bool | IsStackTop (Derived const *p) |
Returns true if p is the top of the stack. | |
Friends | |
class | TfStackedAccess |
A TfStacked is used where a class needs to keep a stack of the objects currently in existence.
This class follows the CRTP and is a base class that is parameterized on its derived classes.
TfStacked is thread-safe by default and each thread will get its own stack. This behavior may be disabled by passing false for the PerThread template parameter.
Derived classes must instantiate the stack themselves by putting
TF_INSTANTIATE_STACKED(YourStackedClass)
in a single .cpp file.
Note that Stacked objects that differ only by PerThread will not share stacks.
|
inline |
|
inline |
|
inlinestatic |
|
inlinestatic |
Returns the element under the top of the stack.
If the stack contains only one element, or is empty, returns 0. Derived classes can befriend TfStackedAccess and hide (override) _InitializeStack() to pre-populate the stack if desired. This way, a stack can be made never to be empty.
|
inlinestatic |
Returns the top of the stack.
If the stack is empty, returns 0. Derived classes can befriend TfStackedAccess and hide (override) _InitializeStack() to pre-populate the stack if desired. This way, a stack can be made never to be empty.
|
inlinestatic |
|
friend |