ACE_Singleton_Strategy< SVC_HANDLER > Class Template Reference

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

#include <Strategies_T.h>

Inheritance diagram for ACE_Singleton_Strategy< SVC_HANDLER >:

Inheritance graph
[legend]
Collaboration diagram for ACE_Singleton_Strategy< SVC_HANDLER >:

Collaboration graph
[legend]
List of all members.

Public Types

typedef ACE_Creation_Strategy<
SVC_HANDLER > 
base_type

Public Member Functions

 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 *&)
void dump (void) const
 Dump the state of an object.


Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks.


Protected Attributes

SVC_HANDLER * svc_handler_
 Pointer to the Singleton svc_handler.

int delete_svc_handler_
 Keep track of whether we need to delete the .


Detailed Description

template<class SVC_HANDLER>
class ACE_Singleton_Strategy< SVC_HANDLER >

Defines the interface for specifying a creation strategy for a that always returns the same (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 141 of file Strategies_T.h.


Member Typedef Documentation

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

Definition at line 146 of file Strategies_T.h.


Constructor & Destructor Documentation

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

Definition at line 8 of file Strategies_T.inl.

References ACE_ERROR, ACE_LIB_TEXT, ACE_TRACE, LM_ERROR, and ACE_Singleton_Strategy< SVC_HANDLER >::open().

00010   : svc_handler_ (0),
00011     delete_svc_handler_ (1)
00012 {
00013   ACE_TRACE ("ACE_Singleton_Strategy<SVC_HANDLER>::ACE_Singleton_Strategy");
00014   if (this->open (sh, tm) == -1)
00015     ACE_ERROR ((LM_ERROR,
00016                 ACE_LIB_TEXT ("%p\n"),
00017                 ACE_LIB_TEXT ("ACE_Singleton_Strategy")));
00018 }

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

Definition at line 51 of file Strategies_T.cpp.

References ACE_TRACE, and ACE_Singleton_Strategy< SVC_HANDLER >::delete_svc_handler_.

00052 {
00053   ACE_TRACE ("ACE_Singleton_Strategy<SVC_HANDLER>::~ACE_Singleton_Strategy");
00054   if (this->delete_svc_handler_ != 0)
00055     delete this->svc_handler_;
00056 }


Member Function Documentation

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

Dump the state of an object.

Reimplemented from ACE_Creation_Strategy< SVC_HANDLER >.

Definition at line 1436 of file Strategies_T.cpp.

References ACE_TRACE.

01437 {
01438 #if defined (ACE_HAS_DUMP)
01439   ACE_TRACE ("ACE_Singleton_Strategy<SVC_HANDLER>::dump");
01440 #endif /* ACE_HAS_DUMP */
01441 }

template<class SVC_HANDLER>
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< SVC_HANDLER >.

Definition at line 62 of file Strategies_T.cpp.

References ACE_TRACE.

00063 {
00064   ACE_TRACE ("ACE_Singleton_Strategy<SVC_HANDLER>::make_svc_handler");
00065   sh = this->svc_handler_;
00066   return 0;
00067 }

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

Definition at line 70 of file Strategies_T.cpp.

References ACE_NEW_RETURN, ACE_TRACE, and ACE_Singleton_Strategy< SVC_HANDLER >::delete_svc_handler_.

Referenced by ACE_Singleton_Strategy< SVC_HANDLER >::ACE_Singleton_Strategy().

00072 {
00073   ACE_TRACE ("ACE_Singleton_Strategy<SVC_HANDLER>::open");
00074 
00075   if (this->delete_svc_handler_
00076       && this->svc_handler_ != 0)
00077     delete this->svc_handler_;
00078 
00079   // If <sh> is NULL then create a new <SVC_HANDLER>.
00080   if (sh == 0)
00081     {
00082       ACE_NEW_RETURN (this->svc_handler_,
00083                       SVC_HANDLER,
00084                       -1);
00085       this->delete_svc_handler_ = 1;
00086     }
00087   else
00088     {
00089       this->svc_handler_ = sh;
00090       this->delete_svc_handler_ = 0;
00091     }
00092 
00093   return 0;
00094 }


Member Data Documentation

template<class SVC_HANDLER>
ACE_Singleton_Strategy< SVC_HANDLER >::ACE_ALLOC_HOOK_DECLARE
 

Declare the dynamic allocation hooks.

Reimplemented from ACE_Creation_Strategy< SVC_HANDLER >.

Definition at line 164 of file Strategies_T.h.

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

Keep track of whether we need to delete the .

Definition at line 171 of file Strategies_T.h.

Referenced by ACE_Singleton_Strategy< SVC_HANDLER >::open(), and ACE_Singleton_Strategy< SVC_HANDLER >::~ACE_Singleton_Strategy().

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

Pointer to the Singleton svc_handler.

Definition at line 168 of file Strategies_T.h.


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