ACE_Malloc_LIFO_Iterator_T<, ACE_LOCK, ACE_CB > Class Template Reference

LIFO iterator for names stored in Malloc'd memory. More...

#include <Malloc_T.h>

Collaboration diagram for ACE_Malloc_LIFO_Iterator_T<, ACE_LOCK, ACE_CB >:

Collaboration graph
[legend]
List of all members.

Public Types

typedef ACE_TYPENAME ACE_CB::ACE_Name_Node NAME_NODE
typedef ACE_TYPENAME ACE_CB::ACE_Malloc_Header MALLOC_HEADER

Public Member Functions

 ACE_Malloc_LIFO_Iterator_T (ACE_Malloc_T< ACE_MEM_POOL_2, ACE_LOCK, ACE_CB > &malloc, const char *name=0)
 ~ACE_Malloc_LIFO_Iterator_T (void)
 Destructor.

int done (void) const
 Returns 1 when all items have been seen, else 0.

int next (void *&next_entry)
int next (void *&next_entry, const char *&name)
int advance (void)
void dump (void) const
 Dump the state of an object.


Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks.


Private Attributes

ACE_Malloc_T< ACE_MEM_POOL_2,
ACE_LOCK, ACE_CB > & 
malloc_
 Malloc we are iterating over.

NAME_NODEcurr_
 Keeps track of how far we've advanced...

ACE_Read_Guard< ACE_LOCK > guard_
 Lock Malloc for the lifetime of the iterator.

const char * name_
 Name that we are searching for.


Detailed Description

template<ACE_MEM_POOL_1, class ACE_LOCK, class ACE_CB>
class ACE_Malloc_LIFO_Iterator_T<, ACE_LOCK, ACE_CB >

LIFO iterator for names stored in Malloc'd memory.

This class can be configured flexibly with different types of ACE_LOCK strategies that support the ACE_Thread_Mutex and ACE_Process_Mutex constructor API.

Does not support deletions while iteration is occurring.

Definition at line 699 of file Malloc_T.h.


Member Typedef Documentation

template<ACE_MEM_POOL_1 , class ACE_LOCK, class ACE_CB>
typedef ACE_TYPENAME ACE_CB::ACE_Malloc_Header ACE_Malloc_LIFO_Iterator_T<, ACE_LOCK, ACE_CB >::MALLOC_HEADER
 

Definition at line 703 of file Malloc_T.h.

template<ACE_MEM_POOL_1 , class ACE_LOCK, class ACE_CB>
typedef ACE_TYPENAME ACE_CB::ACE_Name_Node ACE_Malloc_LIFO_Iterator_T<, ACE_LOCK, ACE_CB >::NAME_NODE
 

Definition at line 702 of file Malloc_T.h.


Constructor & Destructor Documentation

template<ACE_MEM_POOL_1 , class ACE_LOCK, class ACE_CB>
ACE_Malloc_LIFO_Iterator_T<, ACE_LOCK, ACE_CB >::ACE_Malloc_LIFO_Iterator_T ACE_Malloc_T< ACE_MEM_POOL_2, ACE_LOCK, ACE_CB > &  malloc,
const char *  name = 0
 

If name = 0 it will iterate through everything else only through those entries whose name match.

Definition at line 1065 of file Malloc_T.cpp.

References ACE_TRACE, ACE_Malloc_LIFO_Iterator_T<, ACE_LOCK, ACE_CB >::advance(), ACE_Malloc_T< ACE_MEM_POOL_2, ACE_LOCK, ACE_CB >::cb_ptr_, ACE_Malloc_LIFO_Iterator_T<, ACE_LOCK, ACE_CB >::curr_, and ACE_Malloc_LIFO_Iterator_T<, ACE_LOCK, ACE_CB >::malloc_.

01067   : malloc_ (malloc),
01068     curr_ (0),
01069     guard_ (*malloc_.lock_),
01070     name_ (name != 0 ? ACE_OS::strdup (name) : 0)
01071 {
01072   ACE_TRACE ("ACE_Malloc_LIFO_Iterator_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::ACE_Malloc_LIFO_Iterator_T");
01073   // Cheap trick to make code simple.
01074   // @@ Doug, this looks like trouble...
01075   NAME_NODE temp;
01076   this->curr_ = &temp;
01077   this->curr_->next_ = malloc_.cb_ptr_->name_head_;
01078 
01079   this->advance ();
01080 }

template<ACE_MEM_POOL_1 , class ACE_LOCK, class ACE_CB>
ACE_Malloc_LIFO_Iterator_T<, ACE_LOCK, ACE_CB >::~ACE_Malloc_LIFO_Iterator_T void   ) 
 

Destructor.

Definition at line 1083 of file Malloc_T.cpp.

References ACE_OS::free().

01084 {
01085   ACE_OS::free ((void *) this->name_);
01086 }


Member Function Documentation

template<ACE_MEM_POOL_1 , class ACE_LOCK, class ACE_CB>
int ACE_Malloc_LIFO_Iterator_T<, ACE_LOCK, ACE_CB >::advance void   ) 
 

Move forward by one element in the set. Returns 0 when all the items in the set have been seen, else 1.

Definition at line 1127 of file Malloc_T.cpp.

References ACE_TRACE, ACE_Malloc_LIFO_Iterator_T<, ACE_LOCK, ACE_CB >::curr_, and ACE_OS::strcmp().

Referenced by ACE_Malloc_LIFO_Iterator_T<, ACE_LOCK, ACE_CB >::ACE_Malloc_LIFO_Iterator_T().

01128 {
01129   ACE_TRACE ("ACE_Malloc_LIFO_Iterator_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::advance");
01130 
01131   this->curr_ = this->curr_->next_;
01132 
01133   if (this->name_ == 0)
01134     return this->curr_ != 0;
01135 
01136   while (this->curr_ != 0
01137          && ACE_OS::strcmp (this->name_,
01138                             this->curr_->name ()) != 0)
01139     this->curr_ = this->curr_->next_;
01140 
01141   return this->curr_ != 0;
01142 }

template<ACE_MEM_POOL_1 , class ACE_LOCK, class ACE_CB>
int ACE_Malloc_LIFO_Iterator_T<, ACE_LOCK, ACE_CB >::done void   )  const
 

Returns 1 when all items have been seen, else 0.

Definition at line 1119 of file Malloc_T.cpp.

References ACE_TRACE, and ACE_Malloc_LIFO_Iterator_T<, ACE_LOCK, ACE_CB >::curr_.

01120 {
01121   ACE_TRACE ("ACE_Malloc_LIFO_Iterator_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::done");
01122 
01123   return this->curr_ == 0;
01124 }

template<ACE_MEM_POOL_1 , class ACE_LOCK, class ACE_CB>
void ACE_Malloc_LIFO_Iterator_T<, ACE_LOCK, ACE_CB >::dump void   )  const
 

Dump the state of an object.

Definition at line 1050 of file Malloc_T.cpp.

References ACE_BEGIN_DUMP, ACE_DEBUG, ACE_END_DUMP, ACE_LIB_TEXT, ACE_TRACE, ACE_Malloc_LIFO_Iterator_T<, ACE_LOCK, ACE_CB >::curr_, ACE_Malloc_LIFO_Iterator_T<, ACE_LOCK, ACE_CB >::guard_, and LM_DEBUG.

01051 {
01052 #if defined (ACE_HAS_DUMP)
01053   ACE_TRACE ("ACE_Malloc_LIFO_Iterator_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::dump");
01054 
01055   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
01056   this->curr_->dump ();
01057   this->guard_.dump ();
01058   ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("name_ = %s"), this->name_));
01059   ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\n")));
01060   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
01061 #endif /* ACE_HAS_DUMP */
01062 }

template<ACE_MEM_POOL_1 , class ACE_LOCK, class ACE_CB>
int ACE_Malloc_LIFO_Iterator_T<, ACE_LOCK, ACE_CB >::next void *&  next_entry,
const char *&  name
 

Pass back the next entry (and the name associated with it) in the set that hasn't yet been visited. Returns 0 when all items have been seen, else 1.

Definition at line 1089 of file Malloc_T.cpp.

References ACE_TRACE, and ACE_Malloc_LIFO_Iterator_T<, ACE_LOCK, ACE_CB >::curr_.

01091 {
01092   ACE_TRACE ("ACE_Malloc_LIFO_Iterator_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::next");
01093 
01094   if (this->curr_ != 0)
01095     {
01096       next_entry = (char *) this->curr_->pointer_;
01097       name = this->curr_->name ();
01098       return 1;
01099     }
01100   else
01101     return 0;
01102 }

template<ACE_MEM_POOL_1 , class ACE_LOCK, class ACE_CB>
int ACE_Malloc_LIFO_Iterator_T<, ACE_LOCK, ACE_CB >::next void *&  next_entry  ) 
 

Pass back the next entry in the set that hasn't yet been visited. Returns 0 when all items have been seen, else 1.

Definition at line 1105 of file Malloc_T.cpp.

References ACE_TRACE, and ACE_Malloc_LIFO_Iterator_T<, ACE_LOCK, ACE_CB >::curr_.

01106 {
01107   ACE_TRACE ("ACE_Malloc_LIFO_Iterator_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::next");
01108 
01109   if (this->curr_ != 0)
01110     {
01111       next_entry = this->curr_->pointer_;
01112       return 1;
01113     }
01114   else
01115     return 0;
01116 }


Member Data Documentation

template<ACE_MEM_POOL_1 , class ACE_LOCK, class ACE_CB>
ACE_Malloc_LIFO_Iterator_T<, ACE_LOCK, ACE_CB >::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Definition at line 739 of file Malloc_T.h.

template<ACE_MEM_POOL_1 , class ACE_LOCK, class ACE_CB>
NAME_NODE* ACE_Malloc_LIFO_Iterator_T<, ACE_LOCK, ACE_CB >::curr_ [private]
 

Keeps track of how far we've advanced...

Definition at line 746 of file Malloc_T.h.

Referenced by ACE_Malloc_LIFO_Iterator_T<, ACE_LOCK, ACE_CB >::ACE_Malloc_LIFO_Iterator_T(), ACE_Malloc_LIFO_Iterator_T<, ACE_LOCK, ACE_CB >::advance(), ACE_Malloc_LIFO_Iterator_T<, ACE_LOCK, ACE_CB >::done(), ACE_Malloc_LIFO_Iterator_T<, ACE_LOCK, ACE_CB >::dump(), and ACE_Malloc_LIFO_Iterator_T<, ACE_LOCK, ACE_CB >::next().

template<ACE_MEM_POOL_1 , class ACE_LOCK, class ACE_CB>
ACE_Read_Guard<ACE_LOCK> ACE_Malloc_LIFO_Iterator_T<, ACE_LOCK, ACE_CB >::guard_ [private]
 

Lock Malloc for the lifetime of the iterator.

Definition at line 749 of file Malloc_T.h.

Referenced by ACE_Malloc_LIFO_Iterator_T<, ACE_LOCK, ACE_CB >::dump().

template<ACE_MEM_POOL_1 , class ACE_LOCK, class ACE_CB>
ACE_Malloc_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>& ACE_Malloc_LIFO_Iterator_T<, ACE_LOCK, ACE_CB >::malloc_ [private]
 

Malloc we are iterating over.

Definition at line 743 of file Malloc_T.h.

Referenced by ACE_Malloc_LIFO_Iterator_T<, ACE_LOCK, ACE_CB >::ACE_Malloc_LIFO_Iterator_T().

template<ACE_MEM_POOL_1 , class ACE_LOCK, class ACE_CB>
const char* ACE_Malloc_LIFO_Iterator_T<, ACE_LOCK, ACE_CB >::name_ [private]
 

Name that we are searching for.

Definition at line 752 of file Malloc_T.h.


The documentation for this class was generated from the following files:
Generated on Thu Nov 9 11:24:19 2006 for ACE by doxygen 1.3.6