Stack::WithClone::FIFO< T > Class Template Reference

#include <FIFO.hpp>

List of all members.


Detailed Description

template<typename T>
class Stack::WithClone::FIFO< T >

Provides FIFO like stack functionalities for any object It is recommended to push "new" created object.

The stack takes care of deleting the pushed pointer when destructed or reallocated (size zeros and grow again) If you plan to use copy constructor or operator =, the objects must provide a "clone" method.

            Stack::WithClone::FIFO<MyClass> stack;
            // Push some data onto this stack
            stack.Push(new MyClass(...));
            stack.Push(new MyDerivedClass(...));
            // Pop them
            MyClass * t = stack.Pop();
            // Don't delete the popped pointer
            MyClass * t2 = stack.Pop();
            // t3 will be NULL, but t and t2 still points to valid memory
            MyClass * t3 = stack.Pop(); 
            // This will invalidate t and t2 ( because stack.size is zero )
            stack.Push(new MyChildClass(3));
            t2->SomeMethod(); //<== This will crash the program as t2 is now deleted
            
            // This will use virtual MyClass::clone method
            Stack::WithClone::FIFO<MyClass> stack2 = stack; 
            // On leaving scope, the array will be destructed, so will MyChildClass instance.


Public Member Functions

 FIFO (const FIFO &other)
 Copy constructor.
 FIFO ()
 Default Constructor.
bool Forget (T *avoidDeleting=NULL)
 Tell the stack it is no more required to delete the given pop'd pointer.
size_t getSize () const
 Access size member.
const FIFOoperator= (const FIFO< T > &fifo)
 Classic copy operator.
T * Pop ()
 Pop an element from the list.
void Push (T *ref)
 Push an element to the list.
void Reset ()
 Reset the FIFO.
 ~FIFO ()
 Destructor.


Constructor & Destructor Documentation

template<typename T>
Stack::WithClone::FIFO< T >::FIFO (  )  [inline]

Default Constructor.

template<typename T>
Stack::WithClone::FIFO< T >::FIFO ( const FIFO< T > &  other  )  [inline]

Copy constructor.

template<typename T>
Stack::WithClone::FIFO< T >::~FIFO (  )  [inline]

Destructor.


Member Function Documentation

template<typename T>
bool Stack::WithClone::FIFO< T >::Forget ( T *  avoidDeleting = NULL  )  [inline]

Tell the stack it is no more required to delete the given pop'd pointer.

Returns:
true if the pointer has been pop'd (hence will not be deleted)

false if the pointer hasn't been pop'd yet, or not found

template<typename T>
size_t Stack::WithClone::FIFO< T >::getSize (  )  const [inline]

Access size member.

template<typename T>
const FIFO& Stack::WithClone::FIFO< T >::operator= ( const FIFO< T > &  fifo  )  [inline]

Classic copy operator.

template<typename T>
T* Stack::WithClone::FIFO< T >::Pop (  )  [inline]

Pop an element from the list.

template<typename T>
void Stack::WithClone::FIFO< T >::Push ( T *  ref  )  [inline]

Push an element to the list.

template<typename T>
void Stack::WithClone::FIFO< T >::Reset (  )  [inline]

Reset the FIFO.


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

(C) An X-Ryl669 project 2007

This document describes Unlimited Zooming Interface source code. UZI stands for Unlimited Zooming Interface, and source code license is