Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

ACE_Singleton_Strategy Class Template Reference

Defines the interface for specifying a creation strategy for a <SVC_HANDLER> that always returns the same <SVC_HANDLER> (i.e., it's a Singleton). More...

#include <Strategies_T.h>

Inheritance diagram for ACE_Singleton_Strategy:

Inheritance graph
[legend]
Collaboration diagram for ACE_Singleton_Strategy:

Collaboration graph
[legend]
List of all members.

Public Types

typedef ACE_Creation_Strategy<
SVC_HANDLER > 
base_type

Public Methods

 ACE_Singleton_Strategy (SVC_HANDLER *=0, ACE_Thread_Manager *=0)
int open (SVC_HANDLER *, ACE_Thread_Manager *=0)
virtual ~ACE_Singleton_Strategy (void)
virtual int make_svc_handler (SVC_HANDLER *&)
 Create a Singleton SVC_HANDLER by always returning the same SVC_HANDLER. Returns -1 on failure, else 0. More...

void dump (void) const
 Dump the state of an object. More...


Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks. More...


Protected Attributes

SVC_HANDLER * svc_handler_
 Pointer to the Singleton svc_handler. More...

int delete_svc_handler_
 Keep track of whether we need to delete the <SVC_HANDLER>. More...


Detailed Description

template<class SVC_HANDLER>
class ACE_Singleton_Strategy< SVC_HANDLER >

Defines the interface for specifying a creation strategy for a <SVC_HANDLER> that always returns the same <SVC_HANDLER> (i.e., it's a Singleton).

Note that this class takes over the ownership of the SVC_HANDLER passed into it as a parameter and it becomes responsible for deleting this object.

Definition at line 138 of file Strategies_T.h.


Member Typedef Documentation

template<class SVC_HANDLER>
typedef ACE_Creation_Strategy<SVC_HANDLER> ACE_Singleton_Strategy::base_type
 

Definition at line 143 of file Strategies_T.h.


Constructor & Destructor Documentation

template<class SVC_HANDLER>
ASYS_INLINE ACE_Singleton_Strategy< SVC_HANDLER >::ACE_Singleton_Strategy SVC_HANDLER *    = 0,
ACE_Thread_Manager   = 0
 

Definition at line 25 of file Strategies_T.i.

References ACE_ERROR, ACE_LIB_TEXT, ACE_TRACE, LM_ERROR, and open.

00027   : svc_handler_ (0),
00028     delete_svc_handler_ (1)
00029 {
00030   ACE_TRACE ("ACE_Singleton_Strategy<SVC_HANDLER>::ACE_Singleton_Strategy");
00031   if (this->open (sh, tm) == -1)
00032     ACE_ERROR ((LM_ERROR,
00033                 ACE_LIB_TEXT ("%p\n"),
00034                 ACE_LIB_TEXT ("ACE_Singleton_Strategy")));
00035 }

template<class SVC_HANDLER>
ASYS_INLINE ACE_Singleton_Strategy< SVC_HANDLER >::~ACE_Singleton_Strategy void    [virtual]
 

Definition at line 38 of file Strategies_T.i.

References ACE_TRACE, delete_svc_handler_, and svc_handler_.

00039 {
00040   ACE_TRACE ("ACE_Singleton_Strategy<SVC_HANDLER>::~ACE_Singleton_Strategy");
00041   if (this->delete_svc_handler_ != 0)
00042     delete this->svc_handler_;
00043 }


Member Function Documentation

template<class SVC_HANDLER>
ACE_INLINE void ACE_Singleton_Strategy< SVC_HANDLER >::dump void    const
 

Dump the state of an object.

Reimplemented from ACE_Creation_Strategy.

Definition at line 1210 of file Strategies_T.cpp.

References ACE_TRACE.

01211 {
01212   ACE_TRACE ("ACE_Singleton_Strategy<SVC_HANDLER>::dump");
01213 }

template<class SVC_HANDLER>
ASYS_INLINE int ACE_Singleton_Strategy< SVC_HANDLER >::make_svc_handler SVC_HANDLER *&    [virtual]
 

Create a Singleton SVC_HANDLER by always returning the same SVC_HANDLER. Returns -1 on failure, else 0.

Reimplemented from ACE_Creation_Strategy.

Definition at line 49 of file Strategies_T.i.

References ACE_TRACE, and svc_handler_.

00050 {
00051   ACE_TRACE ("ACE_Singleton_Strategy<SVC_HANDLER>::make_svc_handler");
00052   sh = this->svc_handler_;
00053   return 0;
00054 }

template<class SVC_HANDLER>
int ACE_Singleton_Strategy< SVC_HANDLER >::open SVC_HANDLER *   ,
ACE_Thread_Manager   = 0
 

Definition at line 25 of file Strategies_T.cpp.

References ACE_NEW_RETURN, ACE_TRACE, delete_svc_handler_, and svc_handler_.

Referenced by ACE_Singleton_Strategy.

00027 {
00028   ACE_TRACE ("ACE_Singleton_Strategy<SVC_HANDLER>::open");
00029 
00030   if (this->delete_svc_handler_
00031       && this->svc_handler_ != 0)
00032     delete this->svc_handler_;
00033 
00034   // If <sh> is NULL then create a new <SVC_HANDLER>.
00035   if (sh == 0)
00036     {
00037       ACE_NEW_RETURN (this->svc_handler_,
00038                       SVC_HANDLER,
00039                       -1);
00040       this->delete_svc_handler_ = 1;
00041     }
00042   else
00043     {
00044       this->svc_handler_ = sh;
00045       this->delete_svc_handler_ = 0;
00046     }
00047 
00048   return 0;
00049 }


Member Data Documentation

template<class SVC_HANDLER>
ACE_Singleton_Strategy::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Reimplemented from ACE_Creation_Strategy.

Definition at line 161 of file Strategies_T.h.

template<class SVC_HANDLER>
int ACE_Singleton_Strategy::delete_svc_handler_ [protected]
 

Keep track of whether we need to delete the <SVC_HANDLER>.

Definition at line 168 of file Strategies_T.h.

Referenced by open, and ~ACE_Singleton_Strategy.

template<class SVC_HANDLER>
SVC_HANDLER* ACE_Singleton_Strategy::svc_handler_ [protected]
 

Pointer to the Singleton svc_handler.

Definition at line 165 of file Strategies_T.h.

Referenced by make_svc_handler, open, and ~ACE_Singleton_Strategy.


The documentation for this class was generated from the following files:
Generated on Mon Jun 16 12:56:14 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002