Public Member Functions | Private Attributes

TAO_ESF_Copy_On_Read< PROXY, COLLECTION, ITERATOR, ACE_LOCK > Class Template Reference

Implement the Copy_On_Read protocol. More...

#include <ESF_Copy_On_Read.h>

Inheritance diagram for TAO_ESF_Copy_On_Read< PROXY, COLLECTION, ITERATOR, ACE_LOCK >:
Inheritance graph
[legend]
Collaboration diagram for TAO_ESF_Copy_On_Read< PROXY, COLLECTION, ITERATOR, ACE_LOCK >:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 TAO_ESF_Copy_On_Read (void)
 Constructors.
 TAO_ESF_Copy_On_Read (const COLLECTION &collection)
virtual void for_each (TAO_ESF_Worker< PROXY > *worker)
virtual void connected (PROXY *proxy)
virtual void reconnected (PROXY *proxy)
virtual void disconnected (PROXY *proxy)
 Remove an element from the collection.
virtual void shutdown (void)
 The EC is shutting down, must release all the elements.

Private Attributes

COLLECTION collection_
ACE_LOCK lock_

Detailed Description

template<class PROXY, class COLLECTION, class ITERATOR, class ACE_LOCK>
class TAO_ESF_Copy_On_Read< PROXY, COLLECTION, ITERATOR, ACE_LOCK >

Implement the Copy_On_Read protocol.

The class is parametric on the kind of collection and locking mechanism used.

Definition at line 38 of file ESF_Copy_On_Read.h.


Constructor & Destructor Documentation

template<class PROXY , class COLLECTION , class ITERATOR , class ACE_LOCK >
TAO_ESF_Copy_On_Read< PROXY, COLLECTION, ITERATOR, ACE_LOCK >::TAO_ESF_Copy_On_Read ( void   ) 

Constructors.

Definition at line 15 of file ESF_Copy_On_Read.cpp.

{
}

template<class PROXY , class COLLECTION , class ITERATOR , class ACE_LOCK >
TAO_ESF_Copy_On_Read< PROXY, COLLECTION, ITERATOR, ACE_LOCK >::TAO_ESF_Copy_On_Read ( const COLLECTION &  collection  ) 

Definition at line 21 of file ESF_Copy_On_Read.cpp.

      :  collection_ (collection)
{
}


Member Function Documentation

template<class PROXY , class COLLECTION , class ITERATOR , class ACE_LOCK >
void TAO_ESF_Copy_On_Read< PROXY, COLLECTION, ITERATOR, ACE_LOCK >::connected ( PROXY *  proxy  )  [virtual]

Insert a new element into the collection. The collection assumes ownership of the element.

Implements TAO_ESF_Proxy_Collection< PROXY >.

Definition at line 78 of file ESF_Copy_On_Read.cpp.

{
  ACE_GUARD (ACE_LOCK, ace_mon, this->lock_);

  proxy->_incr_refcnt ();
  this->collection_.connected (proxy);
}

template<class PROXY , class COLLECTION , class ITERATOR , class ACE_LOCK >
void TAO_ESF_Copy_On_Read< PROXY, COLLECTION, ITERATOR, ACE_LOCK >::disconnected ( PROXY *  proxy  )  [virtual]

Remove an element from the collection.

Implements TAO_ESF_Proxy_Collection< PROXY >.

Definition at line 98 of file ESF_Copy_On_Read.cpp.

{
  ACE_GUARD (ACE_LOCK, ace_mon, this->lock_);

  this->collection_.disconnected (proxy);
}

template<class PROXY , class COLLECTION , class ITERATOR , class ACE_LOCK >
void TAO_ESF_Copy_On_Read< PROXY, COLLECTION, ITERATOR, ACE_LOCK >::for_each ( TAO_ESF_Worker< PROXY > *  worker  )  [virtual]

Iterate over the collection and invoke worker->work() for each member of the collection. This encapsulates

Implements TAO_ESF_Proxy_Collection< PROXY >.

Definition at line 28 of file ESF_Copy_On_Read.cpp.

{
  // @@ Use an allocator for this memory...
  PROXY **proxies = 0;
  size_t size = 0;
  try
    {
      {
        ACE_GUARD (ACE_LOCK, ace_mon, this->lock_);

        size = this->collection_.size ();
        ACE_NEW (proxies, PROXY*[size]);
        PROXY **j = proxies;

        for (; j != proxies + size; ++j)
          *j = 0;

        j = proxies;

        ITERATOR end = this->collection_.end ();
        for (ITERATOR i = this->collection_.begin (); i != end; ++i)
          {
            *j = *i;
            (*j)->_incr_refcnt ();
            ++j;
          }
      }
      worker->set_size(size);
      for (PROXY **j = proxies; j != proxies + size; ++j)
        {
          worker->work (*j);
          (*j)->_decr_refcnt ();
        }
      delete[] proxies;
    }
  catch (const CORBA::Exception&)
    {
      for (PROXY **j = proxies; j != proxies + size; ++j)
        {
          if (*j != 0)
            (*j)->_decr_refcnt ();
        }
      delete[] proxies;

      throw;
    }
}

template<class PROXY , class COLLECTION , class ITERATOR , class ACE_LOCK >
void TAO_ESF_Copy_On_Read< PROXY, COLLECTION, ITERATOR, ACE_LOCK >::reconnected ( PROXY *  proxy  )  [virtual]

Insert an element into the collection. No errors can be raised if the element is already present. The collection assumes ownership, i.e. must invoke <proxy->_decr_refcnt()> if the element is already present in the collection.

Implements TAO_ESF_Proxy_Collection< PROXY >.

Definition at line 88 of file ESF_Copy_On_Read.cpp.

{
  ACE_GUARD (ACE_LOCK, ace_mon, this->lock_);

  proxy->_incr_refcnt ();
  this->collection_.reconnected (proxy);
}

template<class PROXY , class COLLECTION , class ITERATOR , class ACE_LOCK >
void TAO_ESF_Copy_On_Read< PROXY, COLLECTION, ITERATOR, ACE_LOCK >::shutdown ( void   )  [virtual]

The EC is shutting down, must release all the elements.

Implements TAO_ESF_Proxy_Collection< PROXY >.

Definition at line 106 of file ESF_Copy_On_Read.cpp.

{
  ACE_GUARD (ACE_LOCK, ace_mon, this->lock_);

  this->collection_.shutdown ();
}


Member Data Documentation

template<class PROXY , class COLLECTION , class ITERATOR , class ACE_LOCK >
COLLECTION TAO_ESF_Copy_On_Read< PROXY, COLLECTION, ITERATOR, ACE_LOCK >::collection_ [private]

Definition at line 53 of file ESF_Copy_On_Read.h.

template<class PROXY , class COLLECTION , class ITERATOR , class ACE_LOCK >
ACE_LOCK TAO_ESF_Copy_On_Read< PROXY, COLLECTION, ITERATOR, ACE_LOCK >::lock_ [private]

Definition at line 55 of file ESF_Copy_On_Read.h.


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