HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
TfStacked< Derived, PerThread, Holder > Class Template Reference

#include <stacked.h>

Public Types

typedef Holder Storage
 
typedef Storage::Stack Stack
 

Public Member Functions

 TfStacked ()
 Pushes this stacked object onto the stack. More...
 
 ~TfStacked ()
 Pops this stacked object from the stack. More...
 

Static Public Member Functions

static Derived const * GetStackTop ()
 
static Derived const * GetStackPrevious ()
 
static Stack const & GetStack ()
 Returns a const reference to the entire stack. More...
 
static bool IsStackTop (Derived const *p)
 Returns true if p is the top of the stack. More...
 

Friends

class TfStackedAccess
 

Detailed Description

template<class Derived, bool PerThread = true, class Holder = Tf_StackedStorage<Derived, PerThread>>
class TfStacked< Derived, PerThread, Holder >

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.

Definition at line 137 of file stacked.h.

Member Typedef Documentation

template<class Derived , bool PerThread = true, class Holder = Tf_StackedStorage<Derived, PerThread>>
typedef Storage::Stack TfStacked< Derived, PerThread, Holder >::Stack

Definition at line 143 of file stacked.h.

template<class Derived , bool PerThread = true, class Holder = Tf_StackedStorage<Derived, PerThread>>
typedef Holder TfStacked< Derived, PerThread, Holder >::Storage

Definition at line 142 of file stacked.h.

Constructor & Destructor Documentation

template<class Derived , bool PerThread = true, class Holder = Tf_StackedStorage<Derived, PerThread>>
TfStacked< Derived, PerThread, Holder >::TfStacked ( )
inline

Pushes this stacked object onto the stack.

Definition at line 146 of file stacked.h.

template<class Derived , bool PerThread = true, class Holder = Tf_StackedStorage<Derived, PerThread>>
TfStacked< Derived, PerThread, Holder >::~TfStacked ( )
inline

Pops this stacked object from the stack.

Definition at line 151 of file stacked.h.

Member Function Documentation

template<class Derived , bool PerThread = true, class Holder = Tf_StackedStorage<Derived, PerThread>>
static Stack const& TfStacked< Derived, PerThread, Holder >::GetStack ( )
inlinestatic

Returns a const reference to the entire stack.

Definition at line 176 of file stacked.h.

template<class Derived , bool PerThread = true, class Holder = Tf_StackedStorage<Derived, PerThread>>
static Derived const* TfStacked< Derived, PerThread, Holder >::GetStackPrevious ( )
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.

Definition at line 169 of file stacked.h.

template<class Derived , bool PerThread = true, class Holder = Tf_StackedStorage<Derived, PerThread>>
static Derived const* TfStacked< Derived, PerThread, Holder >::GetStackTop ( )
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.

Definition at line 159 of file stacked.h.

template<class Derived , bool PerThread = true, class Holder = Tf_StackedStorage<Derived, PerThread>>
static bool TfStacked< Derived, PerThread, Holder >::IsStackTop ( Derived const *  p)
inlinestatic

Returns true if p is the top of the stack.

Definition at line 181 of file stacked.h.

Friends And Related Function Documentation

template<class Derived , bool PerThread = true, class Holder = Tf_StackedStorage<Derived, PerThread>>
friend class TfStackedAccess
friend

Definition at line 186 of file stacked.h.


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