ACE_Service_Repository Class Reference

Contains all the services offered by a Service Configurator-based application. More...

#include <Service_Repository.h>

Collaboration diagram for ACE_Service_Repository:

Collaboration graph
[legend]
List of all members.

Public Types

 DEFAULT_SIZE = ACE_DEFAULT_SERVICE_REPOSITORY_SIZE
enum  { DEFAULT_SIZE = ACE_DEFAULT_SERVICE_REPOSITORY_SIZE }

Public Member Functions

 ACE_Service_Repository (void)
 Initialize the repository.
 ACE_Service_Repository (size_t size)
 Initialize the repository.
int open (size_t size=DEFAULT_SIZE)
 Initialize the repository.
 ~ACE_Service_Repository (void)
int close (void)
int fini (void)
int insert (const ACE_Service_Type *)
int find (const ACE_TCHAR name[], const ACE_Service_Type **srp=0, bool ignore_suspended=true) const
int remove (const ACE_TCHAR[], ACE_Service_Type **sr=0)
 Completely remove a <name> entry from the Repository and dynamically unlink it if it was originally dynamically linked.
int resume (const ACE_TCHAR[], const ACE_Service_Type **=0)
 Resume a service record.
int suspend (const ACE_TCHAR[], const ACE_Service_Type **=0)
 Suspend a service record.
size_t current_size (void) const
 Return the current size of the repository.
size_t total_size (void) const
 Return the total size of the repository.
void dump (void) const
 Dump the state of an object.

Static Public Member Functions

static ACE_Service_Repositoryinstance (size_t size=ACE_Service_Repository::DEFAULT_SIZE)
 Get pointer to a process-wide ACE_Service_Repository.
static ACE_Service_Repositoryinstance (ACE_Service_Repository *)
static void close_singleton (void)
 Delete the dynamically allocated Singleton.

Public Attributes

 ACE_ALLOC_HOOK_DECLARE
 Declare the dynamic allocation hooks.

Private Member Functions

int remove_i (const ACE_TCHAR[], ACE_Service_Type **sr)
int find_i (const ACE_TCHAR service_name[], size_t &slot, const ACE_Service_Type **srp=0, bool ignore_suspended=true) const
int relocate_i (size_t begin, size_t end, const ACE_DLL &adll)
 Relocate (static) services to another DLL.

Private Attributes

const ACE_Service_Type ** service_vector_
 Contains all the configured services.
size_t current_size_
 Current number of services.
size_t total_size_
 Maximum number of services.

Static Private Attributes

static ACE_Service_Repositorysvc_rep_ = 0
 Pointer to a process-wide ACE_Service_Repository.
static bool delete_svc_rep_ = false
 Must delete the <svc_rep_> if true.

Friends

class ACE_Service_Repository_Iterator
class ACE_Service_Type_Dynamic_Guard

Detailed Description

Contains all the services offered by a Service Configurator-based application.

This class contains a vector of <ACE_Service_Types> *'s and allows an administrative entity to centrally manage and control the behavior of application services. Note that if services are removed from the middle of the repository the order won't necessarily be maintained since the <remove> method performs compaction. However, the common case is not to remove services, so typically they are deleted in the reverse order that they were added originally.

Definition at line 48 of file Service_Repository.h.


Member Enumeration Documentation

anonymous enum

Enumerator:
DEFAULT_SIZE 

Definition at line 53 of file Service_Repository.h.


Constructor & Destructor Documentation

ACE_Service_Repository::ACE_Service_Repository ( void   ) 

Initialize the repository.

Definition at line 40 of file Service_Repository.cpp.

References ACE_TRACE.

00041   : service_vector_ (0),
00042     current_size_ (0),
00043     total_size_ (0)
00044 {
00045   ACE_TRACE ("ACE_Service_Repository::ACE_Service_Repository");
00046 }

ACE_Service_Repository::ACE_Service_Repository ( size_t  size  ) 

Initialize the repository.

Definition at line 123 of file Service_Repository.cpp.

References ACE_ERROR, ACE_TEXT, ACE_TRACE, and LM_ERROR.

00124   : current_size_ (0)
00125 {
00126   ACE_TRACE ("ACE_Service_Repository::ACE_Service_Repository");
00127 
00128   if (this->open (size) == -1)
00129     ACE_ERROR ((LM_ERROR,
00130                 ACE_TEXT ("%p\n"),
00131                 ACE_TEXT ("ACE_Service_Repository")));
00132 }

ACE_Service_Repository::~ACE_Service_Repository ( void   ) 

Close down the repository and free up dynamically allocated resources.

Definition at line 242 of file Service_Repository.cpp.

References ACE_DEBUG, ACE_TRACE, close(), ACE::debug(), and LM_DEBUG.

00243 {
00244   ACE_TRACE ("ACE_Service_Repository::~ACE_Service_Repository");
00245 #ifndef ACE_NLOGGING
00246   if(ACE::debug ())
00247     ACE_DEBUG ((LM_DEBUG, "(%P|%t) SR::<dtor>, this=%@\n", this));
00248 #endif
00249   this->close ();
00250 }


Member Function Documentation

int ACE_Service_Repository::close ( void   ) 

Close down the repository and free up dynamically allocated resources.

Definition at line 190 of file Service_Repository.cpp.

References ACE_DEBUG, ACE_GUARD_RETURN, ACE_TEXT, ACE_TRACE, current_size_, ACE::debug(), LM_DEBUG, ACE_Service_Type::name(), and service_vector_.

Referenced by ~ACE_Service_Repository().

00191 {
00192   ACE_TRACE ("ACE_Service_Repository::close");
00193   ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->lock_, -1));
00194 
00195   if (this->service_vector_ == 0)
00196     return 0;
00197 
00198 #ifndef ACE_NLOGGING
00199   if(ACE::debug ())
00200     ACE_DEBUG ((LM_DEBUG,
00201                 ACE_TEXT ("(%P|%t) SR::close - repo=%@, size=%d\n"),
00202                 this,
00203                 this->current_size_));
00204 #endif
00205 
00206   // Do not use the prefix decrement operator since the index is
00207   // unsigned and may wrap around the 0.
00208   for (size_t i = this->current_size_; i-- != 0; )
00209     {
00210       // Delete services in reverse order.
00211       ACE_Service_Type *s =
00212         const_cast<ACE_Service_Type *> (this->service_vector_[i]);
00213 
00214 #ifndef ACE_NLOGGING
00215       if(ACE::debug ())
00216         {
00217           if (s == 0)
00218             ACE_DEBUG ((LM_DEBUG,
00219                         ACE_TEXT ("(%P|%t) SR::close - repo=%@ [%d] -> 0\n"),
00220                         this,
00221                         i));
00222           else
00223             ACE_DEBUG ((LM_DEBUG,
00224                         ACE_TEXT ("(%P|%t) SR::close - repo=%@ [%d], name=%s, object=%@\n"),
00225                         this,
00226                         i,
00227                         s->name (),
00228                         s));
00229         }
00230 #endif
00231       --this->current_size_;
00232       delete s;
00233     }
00234 
00235   delete [] this->service_vector_;
00236   this->service_vector_ = 0;
00237   this->current_size_ = 0;
00238 
00239   return 0;
00240 }

void ACE_Service_Repository::close_singleton ( void   )  [static]

Delete the dynamically allocated Singleton.

Definition at line 90 of file Service_Repository.cpp.

References ACE_GUARD, ACE_TRACE, delete_svc_rep_, and svc_rep_.

Referenced by ACE_Service_Config::close().

00091 {
00092   ACE_TRACE ("ACE_Service_Repository::close_singleton");
00093 
00094   ACE_MT (ACE_GUARD (ACE_Recursive_Thread_Mutex, ace_mon,
00095                      *ACE_Static_Object_Lock::instance ()));
00096 
00097   if (ACE_Service_Repository::delete_svc_rep_)
00098     {
00099       delete ACE_Service_Repository::svc_rep_;
00100       ACE_Service_Repository::svc_rep_ = 0;
00101       ACE_Service_Repository::delete_svc_rep_ = false;
00102     }
00103 }

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_INLINE size_t ACE_Service_Repository::current_size ( void   )  const

Return the current size of the repository.

Definition at line 16 of file Service_Repository.inl.

References ACE_GUARD_RETURN, ACE_TRACE, and current_size_.

00017 {
00018   ACE_TRACE ("ACE_Service_Repository::current_size");
00019   ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex,
00020                             ace_mon,
00021                             (ACE_Recursive_Thread_Mutex &) this->lock_, 0));
00022   return this->current_size_;
00023 }

void ACE_Service_Repository::dump ( void   )  const

Dump the state of an object.

Definition at line 33 of file Service_Repository.cpp.

References ACE_TRACE.

00034 {
00035 #if defined (ACE_HAS_DUMP)
00036   ACE_TRACE ("ACE_Service_Repository::dump");
00037 #endif /* ACE_HAS_DUMP */
00038 }

int ACE_Service_Repository::find ( const ACE_TCHAR  name[],
const ACE_Service_Type **  srp = 0,
bool  ignore_suspended = true 
) const

Locate a named entry in the service table, optionally ignoring suspended entries.

Parameters:
service_name The name of the service to search for.
srp Optional; if not 0, it is a pointer to a location to receive the ACE_Service_Type pointer for the located service. Meaningless if this method returns -1.
ignore_suspended If true, the search ignores suspended services.
Return values:
0 Named service was located.
-1 Named service was not found.
-2 Named service was found, but is suspended and ignore_suspended is true.

Definition at line 369 of file Service_Repository.cpp.

References ACE_GUARD_RETURN, ACE_TRACE, and find_i().

Referenced by ACE_Service_Gestalt::find(), and ACE_Service_Gestalt::initialize().

00372 {
00373   ACE_TRACE ("ACE_Service_Repository::find");
00374   ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->lock_, -1));
00375   size_t ignore_location = 0;
00376   return this->find_i (name, ignore_location, srp, ignore_suspended);
00377 }

int ACE_Service_Repository::find_i ( const ACE_TCHAR  service_name[],
size_t &  slot,
const ACE_Service_Type **  srp = 0,
bool  ignore_suspended = true 
) const [private]

Locate a named entry in the service table, optionally ignoring suspended entries.

Parameters:
service_name The name of the service to search for.
slot Receives the position index of the service if it is found. Contents are meaningless if this method returns -1.
srp Optional; if not 0, it is a pointer to a location to receive the ACE_Service_Type pointer for the located service. Meaningless if this method returns -1.
ignore_suspended If true, the search ignores suspended services.
Return values:
0 Named service was located; index in the table is set in slot.
-1 Named service was not found.
-2 Named service was found, but is suspended and ignore_suspended is true.

Definition at line 260 of file Service_Repository.cpp.

References ACE_TRACE, current_size_, service_vector_, and ACE_OS::strcmp().

Referenced by find(), insert(), and ACE_Service_Type_Dynamic_Guard::~ACE_Service_Type_Dynamic_Guard().

00264 {
00265   ACE_TRACE ("ACE_Service_Repository::find_i");
00266   size_t i;
00267 
00268   for (i = 0; i < this->current_size_; i++)
00269     {
00270       if (this->service_vector_[i] != 0 // skip any empty slots
00271           && ACE_OS::strcmp (name,
00272                              this->service_vector_[i]->name ()) == 0)
00273         break;
00274     }
00275 
00276   if (i < this->current_size_)
00277     {
00278       slot = i;
00279       if (this->service_vector_[i]->fini_called ())
00280         {
00281           if (srp != 0)
00282             *srp = 0;
00283           return -1;
00284         }
00285 
00286       if (srp != 0)
00287         *srp = this->service_vector_[i];
00288 
00289       if (ignore_suspended
00290           && this->service_vector_[i]->active () == 0)
00291         return -2;
00292 
00293       return 0;
00294     }
00295 
00296   return -1;
00297 }

int ACE_Service_Repository::fini ( void   ) 

Finalize all the services by calling <fini> and deleting dynamically allocated services.

Definition at line 137 of file Service_Repository.cpp.

References ACE_DEBUG, ACE_GUARD_RETURN, ACE_TEXT, ACE_TRACE, ACE_Service_Type::active(), ACE::debug(), ACE_Service_Type::fini(), LM_DEBUG, ACE_Service_Type::name(), ACE_Service_Type_Impl::object(), service_vector_, and ACE_Service_Type::type().

Referenced by ACE_Service_Config::fini_svcs().

00138 {
00139   ACE_TRACE ("ACE_Service_Repository::fini");
00140   ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->lock_, -1));
00141 
00142   if (this->service_vector_ == 0)
00143     return 0;
00144 
00145   int retval = 0;
00146 
00147   // Do not be tempted to use the prefix decrement operator.  Use
00148   // postfix decrement operator since the index is unsigned and may
00149   // wrap around the 0
00150   for (size_t i = this->current_size_; i-- != 0; )
00151     {
00152       // <fini> the services in reverse order.
00153       ACE_Service_Type *s =
00154         const_cast<ACE_Service_Type *> (this->service_vector_[i]);
00155 
00156 #ifndef ACE_NLOGGING
00157       if (ACE::debug ())
00158         {
00159           if (s != 0)
00160             ACE_DEBUG ((LM_DEBUG,
00161                         ACE_TEXT ("ACE (%P|%t) SR::fini, repo=%@ [%d] (%d), ")
00162                         ACE_TEXT ("name=%s, type=%@, object=%@, active=%d\n"),
00163                         this,
00164                         i,
00165                         this->total_size_,
00166                         s->name(),
00167                         s->type (),
00168                         (s->type () != 0) ? s->type ()->object () : 0,
00169                         s->active ()));
00170           else
00171             ACE_DEBUG ((LM_DEBUG,
00172                         ACE_TEXT ("ACE (%P|%t) SR::fini, repo=%@ [%d] (%d) -> 0\n"),
00173                         this,
00174                         i,
00175                         this->total_size_));
00176         }
00177 #endif
00178 
00179       // Collect any errors.
00180       if (s != 0)
00181         retval += s->fini ();
00182     }
00183 
00184   return (retval == 0) ? 0 : -1;
00185 }

int ACE_Service_Repository::insert ( const ACE_Service_Type  ) 

Insert a new service record. Returns -1 when the service repository is full and 0 on success.

Definition at line 385 of file Service_Repository.cpp.

References ACE_DEBUG, ACE_GUARD_RETURN, ACE_TEXT, ACE_TRACE, ACE_Service_Type::active(), current_size_, ACE::debug(), find_i(), ACE_OS::last_error(), LM_DEBUG, ACE_Service_Type::name(), ACE_Service_Type_Impl::object(), service_vector_, total_size_, and ACE_Service_Type::type().

Referenced by ACE_Service_Gestalt::process_directive_i().

00386 {
00387   ACE_TRACE ("ACE_Service_Repository::insert");
00388 
00389   size_t i = 0;
00390   int return_value = -1;
00391   ACE_Service_Type const *s = 0;
00392 
00393   // Establish scope for locking while manipulating the service
00394   // storage
00395   {
00396     // @TODO: Do we need a recursive mutex here?
00397     ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex,
00398                               ace_mon,
00399                               this->lock_,
00400                               -1));
00401 
00402     return_value = find_i (sr->name (), i, &s, false);
00403 
00404     // Adding an entry.
00405     if (s != 0)
00406       {
00407         this->service_vector_[i] = sr;
00408       }
00409     else
00410       {
00411         // New services are always added where current_size_ points,
00412         // because if any DLL relocation needs to happen, it will be
00413         // performed on services with indexes between some old
00414         // current_size_ and the new current_size_ value.  See
00415         // ACE_Service_Type_Dynamic_Guard ctor and dtor for details.
00416 
00417         if (i < this->current_size_)
00418           i = this->current_size_;
00419 
00420         if (i < this->total_size_)
00421           {
00422             this->service_vector_[i] = sr;
00423             this->current_size_++;
00424             return_value = 0;
00425           }
00426         else
00427           {
00428             return_value = -1; // no space left
00429           }
00430 
00431         // Since there may be "holes" left by removed services one
00432         // could consider wrapping current_size_ modulo
00433         // total_size_. This is going to impact
00434         // ACE_Service_Type_Dynamic_Guard, too and is tricky. Perhaps
00435         // a new directive, like "reload" would be better as it can
00436         // combine the removal and insertion in an atomic step and
00437         // avoid creating too many "holes".
00438       }
00439   }
00440 #ifndef ACE_NLOGGING
00441   if (ACE::debug ())
00442     ACE_DEBUG ((LM_DEBUG,
00443                 ACE_TEXT ("ACE (%P|%t) SR::insert - repo=%@ [%d] (%d),")
00444                 ACE_TEXT (" name=%s (%s) (type=%@, object=%@, active=%d)\n"),
00445                 this,
00446                 i,
00447                 this->total_size_,
00448                 sr->name(),
00449                 (return_value == 0 ? ((s==0) ? "new" : "replacing") : "failed"),
00450                 sr->type (),
00451                 (sr->type () != 0) ? sr->type ()->object () : 0,
00452                 sr->active ()));
00453 #endif
00454 
00455   // If necessary, delete but outside the lock. (s may be 0, but
00456   // that's okay, too)
00457   delete s;
00458 
00459   if (return_value == -1)
00460     ACE_OS::last_error (ENOSPC);
00461 
00462   return return_value;
00463 }

ACE_Service_Repository * ACE_Service_Repository::instance ( ACE_Service_Repository  )  [static]

Set pointer to a process-wide ACE_Service_Repository and return existing pointer.

Definition at line 75 of file Service_Repository.cpp.

References ACE_GUARD_RETURN, ACE_TRACE, delete_svc_rep_, and svc_rep_.

00076 {
00077   ACE_TRACE ("ACE_Service_Repository::instance");
00078   ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon,
00079                             *ACE_Static_Object_Lock::instance (), 0));
00080 
00081   ACE_Service_Repository *t = ACE_Service_Repository::svc_rep_;
00082   // We can't safely delete it since we don't know who created it!
00083   ACE_Service_Repository::delete_svc_rep_ = false;
00084 
00085   ACE_Service_Repository::svc_rep_ = s;
00086   return t;
00087 }

ACE_Service_Repository * ACE_Service_Repository::instance ( size_t  size = ACE_Service_Repository::DEFAULT_SIZE  )  [static]

Get pointer to a process-wide ACE_Service_Repository.

Definition at line 49 of file Service_Repository.cpp.

References ACE_GUARD_RETURN, ACE_NEW_RETURN, ACE_TRACE, delete_svc_rep_, ACE_Object_Manager::shutting_down(), ACE_Object_Manager::starting_up(), and svc_rep_.

Referenced by ACE_Service_Config::fini_svcs(), ACE_Service_Gestalt::init_i(), ACE_Service_Manager::list_services(), ACE_Service_Config::open_i(), ACE_Service_Config::remove(), ACE_Service_Config::resume(), and ACE_Service_Config::suspend().

00050 {
00051   ACE_TRACE ("ACE_Service_Repository::instance");
00052 
00053   if (ACE_Service_Repository::svc_rep_ == 0)
00054     {
00055       // Perform Double-Checked Locking Optimization.
00056       ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon,
00057                                 *ACE_Static_Object_Lock::instance (), 0));
00058       if (ACE_Service_Repository::svc_rep_ == 0)
00059         {
00060           if (ACE_Object_Manager::starting_up () ||
00061               !ACE_Object_Manager::shutting_down ())
00062             {
00063               ACE_NEW_RETURN (ACE_Service_Repository::svc_rep_,
00064                               ACE_Service_Repository (size),
00065                               0);
00066               ACE_Service_Repository::delete_svc_rep_ = true;
00067             }
00068         }
00069     }
00070 
00071   return ACE_Service_Repository::svc_rep_;
00072 }

int ACE_Service_Repository::open ( size_t  size = DEFAULT_SIZE  ) 

Initialize the repository.

Definition at line 108 of file Service_Repository.cpp.

References ACE_NEW_RETURN, ACE_TRACE, service_vector_, and total_size_.

00109 {
00110   ACE_TRACE ("ACE_Service_Repository::open");
00111 
00112   ACE_Service_Type **temp = 0;
00113 
00114   ACE_NEW_RETURN (temp,
00115                   ACE_Service_Type *[size],
00116                   -1);
00117 
00118   this->service_vector_ = const_cast<const ACE_Service_Type **> (temp);
00119   this->total_size_ = size;
00120   return 0;
00121 }

int ACE_Service_Repository::relocate_i ( size_t  begin,
size_t  end,
const ACE_DLL adll 
) [private]

Relocate (static) services to another DLL.

If any have been registered in the context of a "forward declaration" guard, those really aren't static services. Their code is in the DLL's code segment, or in one of the dependent DLLs. Therefore, such services need to be associated with the proper DLL in order to prevent failures upon finalization. The method locks the repo.

Works by having the service type keep a reference to a specific DLL. No locking, caller makes sure calling it is safe. You can forcefully relocate any DLLs in the given range, not only the static ones - but that will cause Very Bad Things (tm) to happen.

Definition at line 308 of file Service_Repository.cpp.

References ACE_DEBUG, ACE_SHLIB_INVALID_HANDLE, ACE_TEXT, ACE::debug(), ACE_DLL::get_handle(), and LM_DEBUG.

Referenced by ACE_Service_Type_Dynamic_Guard::~ACE_Service_Type_Dynamic_Guard().

00311 {
00312   ACE_SHLIB_HANDLE new_handle = adll.get_handle (0);
00313 
00314   for (size_t i = begin; i < end; i++)
00315     {
00316       ACE_Service_Type *type =
00317         const_cast<ACE_Service_Type *> (this->service_vector_[i]);
00318 
00319       ACE_SHLIB_HANDLE old_handle = (type == 0) ? ACE_SHLIB_INVALID_HANDLE
00320                                                 : type->dll ().get_handle (0);
00321 
00322 #ifndef ACE_NLOGGING
00323       if (ACE::debug ())
00324         {
00325           if (type == 0)
00326             ACE_DEBUG ((LM_DEBUG,
00327                         ACE_TEXT ("ACE (%P|%t) SR::relocate_i - repo=%@ [%d] (size=%d)")
00328                         ACE_TEXT (": skipping empty slot\n"),
00329                         this,
00330                         i,
00331                         this->total_size_));
00332           else
00333             ACE_DEBUG ((LM_DEBUG,
00334                         ACE_TEXT ("ACE (%P|%t) SR::relocate_i - repo=%@ [%d] (size=%d)")
00335                         ACE_TEXT (": trying name=%s, handle: %d -> %d\n"),
00336                         this,
00337                         i,
00338                         this->total_size_,
00339                         type->name (),
00340                         old_handle,
00341                         new_handle));
00342         }
00343 #endif
00344 
00345       if (type != 0  // skip any gaps
00346           && old_handle == ACE_SHLIB_INVALID_HANDLE
00347           && new_handle != old_handle)
00348         {
00349 #ifndef ACE_NLOGGING
00350           if (ACE::debug ())
00351             ACE_DEBUG ((LM_DEBUG,
00352                         ACE_TEXT ("ACE (%P|%t) SR::relocate_i - repo=%@ [%d] (size=%d)")
00353                         ACE_TEXT (": relocating name=%s, handle: %d -> %d\n"),
00354                         this,
00355                         i,
00356                         this->total_size_,
00357                         type->name (),
00358                         old_handle,
00359                         new_handle));
00360 #endif
00361           type->dll (adll); // ups the refcount on adll
00362         }
00363     }
00364 
00365   return 0;
00366 }

int ACE_Service_Repository::remove ( const   ACE_TCHAR[],
ACE_Service_Type **  sr = 0 
)

Completely remove a <name> entry from the Repository and dynamically unlink it if it was originally dynamically linked.

Remove an existing service record. If sr == 0, the service record is deleted before control is returned to the caller. If sr != 0, the service's record is removed from the repository, but not deleted; sr receives the service record pointer and the caller is responsible for properly disposing of it.

Definition at line 503 of file Service_Repository.cpp.

References ACE_GUARD_RETURN, and ACE_TRACE.

Referenced by ACE_Service_Gestalt::initialize(), ACE_Service_Gestalt::initialize_i(), ACE_Service_Gestalt::remove(), and ACE_Service_Config::remove().

00504 {
00505   ACE_TRACE ("ACE_Service_Repository::remove");
00506   ACE_Service_Type *s = 0;
00507   {
00508     ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->lock_, -1));
00509 
00510     // Not found!?
00511     if (this->remove_i (name, &s) == -1)
00512       return -1;
00513   }
00514 
00515   if (ps != 0)
00516     *ps = s;
00517   else
00518     delete s;
00519   return 0;
00520 }

int ACE_Service_Repository::remove_i ( const   ACE_TCHAR[],
ACE_Service_Type **  sr 
) [private]

Remove an existing service record. It requires sr != 0, which receives the service record pointer and the caller is responsible for properly disposing of it.

int ACE_Service_Repository::resume ( const   ACE_TCHAR[],
const ACE_Service_Type **  = 0 
)

Resume a service record.

Definition at line 467 of file Service_Repository.cpp.

References ACE_GUARD_RETURN, ACE_TRACE, ACE_Service_Type::resume(), and service_vector_.

Referenced by ACE_Service_Gestalt::resume(), and ACE_Service_Config::resume().

00469 {
00470   ACE_TRACE ("ACE_Service_Repository::resume");
00471   ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->lock_, -1));
00472 
00473   size_t i = 0;
00474   if (-1 == this->find_i (name, i, srp, 0))
00475     return -1;
00476 
00477   return this->service_vector_[i]->resume ();
00478 }

int ACE_Service_Repository::suspend ( const   ACE_TCHAR[],
const ACE_Service_Type **  = 0 
)

Suspend a service record.

Definition at line 484 of file Service_Repository.cpp.

References ACE_GUARD_RETURN, ACE_TRACE, service_vector_, and ACE_Service_Type::suspend().

Referenced by ACE_Service_Gestalt::suspend(), and ACE_Service_Config::suspend().

00486 {
00487   ACE_TRACE ("ACE_Service_Repository::suspend");
00488   ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex, ace_mon, this->lock_, -1));
00489   size_t i = 0;
00490   if (-1 == this->find_i (name, i, srp, 0))
00491     return -1;
00492 
00493   return this->service_vector_[i]->suspend ();
00494 }

ACE_INLINE size_t ACE_Service_Repository::total_size ( void   )  const

Return the total size of the repository.

Definition at line 29 of file Service_Repository.inl.

References ACE_GUARD_RETURN, ACE_TRACE, and total_size_.

00030 {
00031   ACE_TRACE ("ACE_Service_Repository::total_size");
00032   ACE_MT (ACE_GUARD_RETURN (ACE_Recursive_Thread_Mutex,
00033                             ace_mon,
00034                             (ACE_Recursive_Thread_Mutex &) this->lock_, 0));
00035   return this->total_size_;
00036 }


Friends And Related Function Documentation

friend class ACE_Service_Repository_Iterator [friend]

Definition at line 51 of file Service_Repository.h.

friend class ACE_Service_Type_Dynamic_Guard [friend]

Definition at line 145 of file Service_Repository.h.


Member Data Documentation

ACE_Service_Repository::ACE_ALLOC_HOOK_DECLARE

Declare the dynamic allocation hooks.

Definition at line 141 of file Service_Repository.h.

size_t ACE_Service_Repository::current_size_ [private]

Current number of services.

Definition at line 199 of file Service_Repository.h.

Referenced by close(), current_size(), ACE_Service_Repository_Iterator::done(), find_i(), and insert().

bool ACE_Service_Repository::delete_svc_rep_ = false [static, private]

Must delete the <svc_rep_> if true.

Definition at line 208 of file Service_Repository.h.

Referenced by close_singleton(), and instance().

const ACE_Service_Type** ACE_Service_Repository::service_vector_ [private]

Contains all the configured services.

Definition at line 196 of file Service_Repository.h.

Referenced by close(), find_i(), fini(), insert(), open(), resume(), and suspend().

ACE_BEGIN_VERSIONED_NAMESPACE_DECL ACE_Service_Repository * ACE_Service_Repository::svc_rep_ = 0 [static, private]

Pointer to a process-wide ACE_Service_Repository.

Definition at line 205 of file Service_Repository.h.

Referenced by close_singleton(), and instance().

size_t ACE_Service_Repository::total_size_ [private]

Maximum number of services.

Definition at line 202 of file Service_Repository.h.

Referenced by insert(), open(), and total_size().


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