Laxkit  0.0.7.1
Public Member Functions
Laxkit::RefPtrStack< T > Class Template Reference

A RefPtrStack with refcounting elements. More...

Inheritance diagram for Laxkit::RefPtrStack< T >:
Inheritance graph
[legend]

List of all members.

Public Member Functions

 RefPtrStack (char nar=3)
virtual ~RefPtrStack ()
 RefPtrStack Destructor, empty.
virtual void flush ()
 Flush the stack. Makes e==NULL.
virtual int push (T *nd, char local=-1, int where=-1)
 Push a pointer onto the stack before index where. Transfers pointer, does not duplicate.
virtual int pushnodup (T *nd, char local=-1, int where=-1)
virtual int remove (int which=-1)
 Pop and delete (if islocal) the element at index which.
- Public Member Functions inherited from Laxkit::PtrStack< T >
 PtrStack (char nar=1)
virtual ~PtrStack ()
 PtrStack Destructor, just calls flush().
virtual T * operator[] (int i)
 Return pointer to element i, or NULL.
virtual int howmany ()
 Returns how many things are on the stack.
virtual void swap (int i1, int i2)
 Swap the elements with indices i1 and i2.
virtual int popp (T *topop, int *local=NULL)
 Pop the first item that points where topop points.
virtual int pop (T *&popped, int which=-1, int *local=NULL)
 Pop element with index which (defaults to top), and make popped point to it.
virtual T * pop (int which=-1, int *local=NULL)
 Pop element with index which, or the top if which not specified.
virtual int findindex (T *t)
 Find the index (in the range [0,n-1]) corresponding to the pointer t.
virtual void Delta (int ndelta)
 Set the delta.
virtual int Delta ()
 Get the delta.
virtual T ** extractArrays (char **local=NULL, int *nn=NULL)
 Return the e and islocal arrays, and internally set them to NULL, max=n=0.
virtual int insertArrays (T **a, char *nl, int nn)
 Flush, then use a as the new array.

Additional Inherited Members

- Public Attributes inherited from Laxkit::PtrStack< T >
charislocal
int n
 The number of elements on the stack.
T ** e
 The elements of the stack.
- Protected Attributes inherited from Laxkit::PtrStack< T >
int max
 The number of spaces allocated in the internal array.
int delta
 Size of chunks of memory to add or remove from internal array.
char arrays
 The default local value for elements of the stack.

Detailed Description

template<class T>
class Laxkit::RefPtrStack< T >

A RefPtrStack with refcounting elements.

In addition to 0 (no special delete behavior), 1 (delete), and 2 (delete[]), there is here also 3 for call dec_count() on the element if it can be cast to anObject. If not, delete is called on it.


Member Function Documentation

template<class T >
void Laxkit::RefPtrStack< T >::flush ( )
virtual

Flush the stack. Makes e==NULL.

If the element's local==2 then the elements are delete with delete[]. If the local==1 it is just deleted with delete. If the local==3, then if it can be cast to a anObject, then it's dec_count() is called. If it cannot be so cast, then it is simply deleted as if local==1. If the islocal flag for the element is !=1,2, or 3, then the element is not delete'd or decremented at all.

Reimplemented from Laxkit::PtrStack< T >.

References Laxkit::anObject::dec_count().

Referenced by Laxkit::FileDialog::getDirectory().

template<class T>
int Laxkit::RefPtrStack< T >::push ( T *  ne,
char  local = -1,
int  where = -1 
)
virtual

Push a pointer onto the stack before index where. Transfers pointer, does not duplicate.

If called without where, pointer is pushed onto the top (highest n) position.

If local==-1, then use arrays for local. If local==1, then when the stack flushes or the the element is removed, then it is delete'd. If local==2, then the element will be delete[]'d.

If local==3 then call dec_count() when the stack would otherwise delete it. That assumes the element can be cast to anObject. ne's count is incremented when pushed here.

If local is any other value, then delete is not called on the element.

If the item has 3 for its local and it can be cast to anObject, then inc_count() is called on it.

Returns the index of the new element on the stack, or -1 if the push failed.

Reimplemented from Laxkit::PtrStack< T >.

References Laxkit::anObject::inc_count(), and Laxkit::PtrStack< T >::push().

Referenced by Laxkit::ShortcutManager::AddArea(), LaxInterfaces::ViewportWithStack::DropObject(), Laxkit::ShortcutManager::dump_in_atts(), and LaxInterfaces::ViewportWithStack::NewData().

template<class T >
int Laxkit::RefPtrStack< T >::remove ( int  which = -1)
virtual

Pop and delete (if islocal) the element at index which.

This purges the element by popping and then (if islocal==1 or 2) deleting it, or dec_count() on it if islocal==3.

Default if no index is specified is to remove the top element (which==-1). If which==-2 then do nothing (see findindex()).

Return 1 if an item is removed, else 0.

Reimplemented from Laxkit::PtrStack< T >.

References Laxkit::anObject::dec_count(), and Laxkit::PtrStack< T >::pop().

Referenced by LaxInterfaces::ViewportWithStack::DeleteObject(), LaxInterfaces::ViewportWindow::Pop(), LaxInterfaces::ViewerWindow::RemoveTool(), and Laxkit::anXApp::reparent().


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

Mon Feb 17 2014 11:53:00, Laxkit