Public Types | Public Member Functions | Public Attributes | Private Attributes

ACE_Malloc_FIFO_Iterator_T< ACE_MEM_POOL_1, ACE_LOCK, ACE_CB > Class Template Reference

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

#include <Malloc_T.h>

Collaboration diagram for ACE_Malloc_FIFO_Iterator_T< ACE_MEM_POOL_1, ACE_LOCK, ACE_CB >:
Collaboration graph
[legend]

List of all members.

Public Types

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

Public Member Functions

 ACE_Malloc_FIFO_Iterator_T (ACE_Malloc_T< ACE_MEM_POOL_2, ACE_LOCK, ACE_CB > &malloc, const char *name=0)
 ~ACE_Malloc_FIFO_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)
int start (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_FIFO_Iterator_T< ACE_MEM_POOL_1, ACE_LOCK, ACE_CB >

FIFO 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 789 of file Malloc_T.h.


Member Typedef Documentation

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

Definition at line 793 of file Malloc_T.h.

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

Definition at line 792 of file Malloc_T.h.


Constructor & Destructor Documentation

template<ACE_MEM_POOL_1 , class ACE_LOCK, class ACE_CB>
ACE_Malloc_FIFO_Iterator_T< ACE_MEM_POOL_1, ACE_LOCK, ACE_CB >::ACE_Malloc_FIFO_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 1158 of file Malloc_T.cpp.

  : malloc_ (malloc),
    curr_ (0),
    guard_ (*malloc_.lock_),
    name_ (name != 0 ? ACE_OS::strdup (name) : 0)
{
  ACE_TRACE ("ACE_Malloc_FIFO_Iterator_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::ACE_Malloc_FIFO_Iterator");
  // Cheap trick to make code simple.
  // @@ Doug, this looks like trouble...
  NAME_NODE temp;
  this->curr_ = &temp;
  this->curr_->next_ = malloc_.cb_ptr_->name_head_;
  this->curr_->prev_ = 0;

  // Go to the first element that was inserted.
  this->start ();
}

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

Destructor.

Definition at line 1178 of file Malloc_T.cpp.

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


Member Function Documentation

template<ACE_MEM_POOL_1 , class ACE_LOCK , class ACE_CB >
int ACE_Malloc_FIFO_Iterator_T< ACE_MEM_POOL_1, 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 1222 of file Malloc_T.cpp.

{
  ACE_TRACE ("ACE_Malloc_FIFO_Iterator_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::advance");

  this->curr_ = this->curr_->prev_;

  if (this->name_ == 0)
    return this->curr_ != 0;

  while (this->curr_ != 0
         && ACE_OS::strcmp (this->name_,
                            this->curr_->name ()) != 0)
    this->curr_ = this->curr_->prev_;

  return this->curr_ != 0;
}

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

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

Definition at line 1214 of file Malloc_T.cpp.

{
  ACE_TRACE ("ACE_Malloc_FIFO_Iterator_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::done");

  return this->curr_ == 0;
}

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

Dump the state of an object.

Definition at line 1144 of file Malloc_T.cpp.

{
#if defined (ACE_HAS_DUMP)
  ACE_TRACE ("ACE_Malloc_FIFO_Iterator_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::dump");

  ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
  this->curr_->dump ();
  this->guard_.dump ();
  ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("name_ = %s\n"), this->name_));
  ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
#endif /* ACE_HAS_DUMP */
}

template<ACE_MEM_POOL_1 , class ACE_LOCK , class ACE_CB >
int ACE_Malloc_FIFO_Iterator_T< ACE_MEM_POOL_1, 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 1200 of file Malloc_T.cpp.

{
  ACE_TRACE ("ACE_Malloc_FIFO_Iterator_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::next");

  if (this->curr_ != 0)
    {
      next_entry = this->curr_->pointer_;
      return 1;
    }
  else
    return 0;
}

template<ACE_MEM_POOL_1 , class ACE_LOCK , class ACE_CB >
int ACE_Malloc_FIFO_Iterator_T< ACE_MEM_POOL_1, 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 1184 of file Malloc_T.cpp.

{
  ACE_TRACE ("ACE_Malloc_FIFO_Iterator_T<ACE_MEM_POOL_2, ACE_LOCK, ACE_CB>::next");

  if (this->curr_ != 0)
    {
      next_entry = (char *) this->curr_->pointer_;
      name = this->curr_->name ();
      return 1;
    }
  else
    return 0;
}

template<ACE_MEM_POOL_1 , class ACE_LOCK , class ACE_CB >
int ACE_Malloc_FIFO_Iterator_T< ACE_MEM_POOL_1, ACE_LOCK, ACE_CB >::start ( void   ) 

Go to the starting element that was inserted first. Returns 0 when there is no item in the set, else 1.

Definition at line 1240 of file Malloc_T.cpp.

{
  this->curr_ = this->curr_->next_;
  NAME_NODE *prev = 0;

  // Locate the element that was inserted first.
  // @@ We could optimize this by making the list a circular list or
  // storing an extra pointer.
  while (this->curr_ != 0)
    {
      prev = this->curr_;
      this->curr_ = this->curr_->next_;
    }

  this->curr_ = prev;
  return this->curr_ != 0;
}


Member Data Documentation

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

Declare the dynamic allocation hooks.

Definition at line 833 of file Malloc_T.h.

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

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

Definition at line 840 of file Malloc_T.h.

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

Lock Malloc for the lifetime of the iterator.

Definition at line 843 of file Malloc_T.h.

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

Malloc we are iterating over.

Definition at line 837 of file Malloc_T.h.

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

Name that we are searching for.

Definition at line 846 of file Malloc_T.h.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines