Service_Object.cpp

Go to the documentation of this file.
00001 // Service_Object.cpp,v 4.35 2006/06/06 21:55:38 shuston Exp
00002 
00003 #include "ace/config-all.h"
00004 
00005 #include "ace/Service_Object.h"
00006 
00007 #if !defined (__ACE_INLINE__)
00008 #include "ace/Service_Object.inl"
00009 #endif /* __ACE_INLINE__ */
00010 
00011 #include "ace/OS_NS_stdio.h"
00012 #include "ace/Service_Types.h"
00013 #include "ace/DLL.h"
00014 #include "ace/ACE.h"
00015 
00016 ACE_RCSID (ace,
00017            Service_Object,
00018            "Service_Object.cpp,v 4.35 2006/06/06 21:55:38 shuston Exp")
00019 
00020   ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00021 
00022 ACE_ALLOC_HOOK_DEFINE(ACE_Service_Object)
00023   ACE_ALLOC_HOOK_DEFINE(ACE_Service_Type)
00024 
00025   void
00026 ACE_Service_Type::dump (void) const
00027 {
00028 #if defined (ACE_HAS_DUMP)
00029   ACE_TRACE ("ACE_Service_Type::dump");
00030 #endif /* ACE_HAS_DUMP */
00031 
00032 
00033   // Using printf, since the log facility may not have
00034   // been initialized yet
00035   ACE_OS::fprintf(stderr,
00036                   "// [ST] dump, this=%p, name=%s, type=%p, so=%p, active=%d\n",
00037                   this,
00038                   this->name_,
00039                   this->type_,
00040                   (this->type_ != 0) ? this->type_->object () : 0,
00041                   this->active_);
00042 
00043 }
00044 
00045 ACE_Service_Type::ACE_Service_Type (const ACE_TCHAR *n,
00046                                     ACE_Service_Type_Impl *t,
00047                                     const ACE_DLL &dll,
00048                                     int active)
00049   : name_ (0),
00050     type_ (t),
00051     dll_ (dll),
00052     active_ (active),
00053     fini_already_called_ (0)
00054 {
00055   ACE_TRACE ("ACE_Service_Type::ACE_Service_Type");
00056   this->name (n);
00057 }
00058 
00059 ACE_Service_Type::ACE_Service_Type (const ACE_TCHAR *n,
00060                                     ACE_Service_Type_Impl *t,
00061                                     ACE_SHLIB_HANDLE handle,
00062                                     int active)
00063   : name_ (0),
00064     type_ (t),
00065     active_ (active),
00066     fini_already_called_ (0)
00067 {
00068   ACE_TRACE ("ACE_Service_Type::ACE_Service_Type");
00069   ACE_DLL &dll = const_cast<ACE_DLL &> (this->dll_);
00070   dll.set_handle (handle);
00071   this->name (n);
00072 }
00073 
00074 ACE_Service_Type::~ACE_Service_Type (void)
00075 {
00076   ACE_TRACE ("ACE_Service_Type::~ACE_Service_Type");
00077   this->fini ();
00078 
00079   delete [] const_cast <ACE_TCHAR *> (this->name_);
00080 }
00081 
00082 int
00083 ACE_Service_Type::fini (void)
00084 {
00085   if (!this->fini_already_called_)
00086     {
00087       this->fini_already_called_ = 1;
00088       if (this->type_ != 0)
00089   return this->type_->fini ();
00090       else
00091         return 1; // No implementation was found.
00092                   // Currently only makes sense for dummy ST, used to "reserve"
00093                   // a spot (kind of like forward-declarations) for a dynamic
00094                   // service. This is necessary to help enforce the correct
00095                   // finalization order, when such service also has any
00096                   // (dependent) static services
00097     }
00098   return 0;
00099 }
00100 
00101 int
00102 ACE_Service_Type::suspend (void) const
00103 {
00104   ACE_TRACE ("ACE_Service_Type::suspend");
00105   (const_cast<ACE_Service_Type *> (this))->active_ = 0;
00106   return this->type_->suspend ();
00107 }
00108 
00109 int
00110 ACE_Service_Type::resume (void) const
00111 {
00112   ACE_TRACE ("ACE_Service_Type::resume");
00113   (const_cast<ACE_Service_Type *> (this))->active_ = 1;
00114   return this->type_->resume ();
00115 }
00116 
00117 ACE_Service_Object::ACE_Service_Object (ACE_Reactor *r)
00118   : ACE_Event_Handler (r)
00119 {
00120   ACE_TRACE ("ACE_Service_Object::ACE_Service_Object");
00121 }
00122 
00123 ACE_Service_Object::~ACE_Service_Object (void)
00124 {
00125   ACE_TRACE ("ACE_Service_Object::~ACE_Service_Object");
00126 }
00127 
00128 int
00129 ACE_Service_Object::suspend (void)
00130 {
00131   ACE_TRACE ("ACE_Service_Object::suspend");
00132   return 0;
00133 }
00134 
00135 int
00136 ACE_Service_Object::resume (void)
00137 {
00138   ACE_TRACE ("ACE_Service_Object::resume");
00139   return 0;
00140 }
00141 
00142 void
00143 ACE_Service_Type::name (const ACE_TCHAR *n)
00144 {
00145   ACE_TRACE ("ACE_Service_Type::name");
00146 
00147   delete [] const_cast <ACE_TCHAR *> (this->name_);
00148   this->name_ = ACE::strnew (n);
00149 }
00150 
00151 ACE_END_VERSIONED_NAMESPACE_DECL

Generated on Thu Nov 9 09:42:03 2006 for ACE by doxygen 1.3.6