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