ACE_Singleton_Strategy< SVC_HANDLER > 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< 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.
bool delete_svc_handler_
 Keep track of whether we need to delete the SVC_HANDLER.

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 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_TEXT, ACE_TRACE, and LM_ERROR.

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_TEXT ("%p\n"),
00017                 ACE_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 >::svc_handler_.

00052 {
00053   ACE_TRACE ("ACE_Singleton_Strategy<SVC_HANDLER>::~ACE_Singleton_Strategy");
00054   if (this->delete_svc_handler_)
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 1435 of file Strategies_T.cpp.

References ACE_TRACE.

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

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, and ACE_Singleton_Strategy< SVC_HANDLER >::svc_handler_.

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, ACE_Singleton_Strategy< SVC_HANDLER >::delete_svc_handler_, and ACE_Singleton_Strategy< SVC_HANDLER >::svc_handler_.

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


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>
bool ACE_Singleton_Strategy< SVC_HANDLER >::delete_svc_handler_ [protected]

Keep track of whether we need to delete the SVC_HANDLER.

Definition at line 171 of file Strategies_T.h.

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

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.

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


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:35:37 2010 for ACE by  doxygen 1.4.7