Go to the documentation of this file.00001
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
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 #include "ace/Log_Msg.h"
00016 #if defined (ACE_OPENVMS)
00017 # include "ace/Lib_Find.h"
00018 #endif
00019
00020 ACE_RCSID (ace,
00021 Service_Object,
00022 "$Id: Service_Object.cpp 90077 2010-05-05 16:19:16Z cbeaulac $")
00023
00024 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00025
00026 ACE_ALLOC_HOOK_DEFINE(ACE_Service_Object)
00027 ACE_ALLOC_HOOK_DEFINE(ACE_Service_Type)
00028
00029 void
00030 ACE_Service_Type::dump (void) const
00031 {
00032 #if defined (ACE_HAS_DUMP)
00033 ACE_TRACE ("ACE_Service_Type::dump");
00034 #endif
00035
00036
00037
00038
00039
00040
00041 ACE_OS::fprintf(stderr,
00042 "// [ST] dump, this=%p, name=%s, type=%p, so=%p, active=%d\n",
00043 this,
00044 this->name_,
00045 this->type_,
00046 (this->type_ != 0) ? this->type_->object () : 0,
00047 this->active_);
00048
00049 }
00050
00051 ACE_Service_Type::ACE_Service_Type (const ACE_TCHAR *n,
00052 ACE_Service_Type_Impl *t,
00053 const ACE_DLL &dll,
00054 bool active)
00055 : name_ (0),
00056 type_ (t),
00057 dll_ (dll),
00058 active_ (active),
00059 fini_already_called_ (false)
00060 {
00061 ACE_TRACE ("ACE_Service_Type::ACE_Service_Type");
00062 this->name (n);
00063 }
00064
00065 ACE_Service_Type::ACE_Service_Type (const ACE_TCHAR *n,
00066 ACE_Service_Type_Impl *t,
00067 ACE_SHLIB_HANDLE handle,
00068 bool active)
00069 : name_ (0),
00070 type_ (t),
00071 active_ (active),
00072 fini_already_called_ (false)
00073 {
00074 ACE_TRACE ("ACE_Service_Type::ACE_Service_Type");
00075 this->dll_.set_handle (handle);
00076 this->name (n);
00077 }
00078
00079 ACE_Service_Type::~ACE_Service_Type (void)
00080 {
00081 ACE_TRACE ("ACE_Service_Type::~ACE_Service_Type");
00082 this->fini ();
00083
00084 delete [] const_cast <ACE_TCHAR *> (this->name_);
00085 }
00086
00087 int
00088 ACE_Service_Type::fini (void)
00089 {
00090 if (ACE::debug ())
00091 ACE_DEBUG ((LM_DEBUG,
00092 ACE_TEXT ("ACE (%P|%t) ST::fini - destroying name=%s, dll=%s\n"),
00093 this->name_,
00094 this->dll_.dll_name_));
00095
00096 if (this->fini_already_called_)
00097 return 0;
00098
00099 this->fini_already_called_ = true;
00100
00101 if (this->type_ == 0)
00102 {
00103
00104
00105
00106
00107
00108
00109 return 1;
00110 }
00111
00112 int ret = this->type_->fini ();
00113
00114
00115 this->type_ = 0;
00116
00117
00118
00119
00120
00121 return (ret | this->dll_.close ());
00122 }
00123
00124 int
00125 ACE_Service_Type::suspend (void) const
00126 {
00127 ACE_TRACE ("ACE_Service_Type::suspend");
00128 (const_cast<ACE_Service_Type *> (this))->active_ = false;
00129 return this->type_->suspend ();
00130 }
00131
00132 int
00133 ACE_Service_Type::resume (void) const
00134 {
00135 ACE_TRACE ("ACE_Service_Type::resume");
00136 (const_cast<ACE_Service_Type *> (this))->active_ = true;
00137 return this->type_->resume ();
00138 }
00139
00140 ACE_Service_Object::ACE_Service_Object (ACE_Reactor *r)
00141 : ACE_Event_Handler (r)
00142 {
00143 ACE_TRACE ("ACE_Service_Object::ACE_Service_Object");
00144 }
00145
00146 ACE_Service_Object::~ACE_Service_Object (void)
00147 {
00148 ACE_TRACE ("ACE_Service_Object::~ACE_Service_Object");
00149 }
00150
00151 int
00152 ACE_Service_Object::suspend (void)
00153 {
00154 ACE_TRACE ("ACE_Service_Object::suspend");
00155 return 0;
00156 }
00157
00158 int
00159 ACE_Service_Object::resume (void)
00160 {
00161 ACE_TRACE ("ACE_Service_Object::resume");
00162 return 0;
00163 }
00164
00165 void
00166 ACE_Service_Type::name (const ACE_TCHAR *n)
00167 {
00168 ACE_TRACE ("ACE_Service_Type::name");
00169
00170 delete [] const_cast <ACE_TCHAR *> (this->name_);
00171 this->name_ = ACE::strnew (n);
00172 }
00173
00174 #if defined (ACE_OPENVMS)
00175 ACE_Dynamic_Svc_Registrar::ACE_Dynamic_Svc_Registrar (const ACE_TCHAR* alloc_name,
00176 void* svc_allocator)
00177 {
00178
00179 ACE::ldregister (alloc_name, svc_allocator);
00180 }
00181 #endif
00182
00183 ACE_END_VERSIONED_NAMESPACE_DECL