A forward service declaration guard. More...
#include <Service_Gestalt.h>
Public Member Functions | |
ACE_Service_Type_Dynamic_Guard (ACE_Service_Repository &r, ACE_TCHAR const *name) | |
~ACE_Service_Type_Dynamic_Guard (void) | |
Destructor. | |
Private Attributes | |
ACE_Service_Repository & | repo_ |
size_t | repo_begin_ |
ACE_TCHAR const *const | name_ |
A forward service declaration guard.
Helps to resolve an issue with hybrid services, i.e. dynamic services, accompanied by static services in the same DLL. Only automatic instances of this class are supposed to exist. Those are created during (dynamic) service initialization and serve to:
(a) Ensure the service we are loading is ordered last in the repository, following any other services it may cause to register, as part of its own registration. This is a common case when loading dynamic services from DLLs - there are often static initializers, which register static services.
(b) The SDG instance destructor detects if the dynamic service initialized successfully and "fixes-up" all the newly registered static services to hold a reference to the DLL, from which they have originated.
Definition at line 502 of file Service_Gestalt.h.
ACE_Service_Type_Dynamic_Guard::ACE_Service_Type_Dynamic_Guard | ( | ACE_Service_Repository & | r, | |
ACE_TCHAR const * | name | |||
) |
ACE_Service_Type_Dynamic_Guard::~ACE_Service_Type_Dynamic_Guard | ( | void | ) |
Destructor.
Definition at line 77 of file Service_Gestalt.cpp.
{ const ACE_Service_Type *tmp = 0; // Lookup without ignoring suspended services. Making sure // not to ignore any inactive services, since those may be forward // declarations size_t slot = 0; int const ret = this->repo_.find_i (this->name_, slot, &tmp, false); // We inserted it (as inactive), so we expect to find it, right? if ((ret < 0 && ret != -2) || tmp == 0) { if (ACE::debug ()) ACE_ERROR ((LM_WARNING, ACE_TEXT ("ACE (%P|%t) STDG::<dtor> - Failed (%d) to find %s -> %@\n"), ret, this->name_, tmp)); return; } if (tmp->type () != 0) { // Something has registered a proper (non-forward-decl) service with // the same name as our dummy. if (ACE::debug ()) ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE (%P|%t) STDG::<dtor>, repo=%@ [%d], ") ACE_TEXT ("name=%s - updating dependents [%d - %d)\n"), &this->repo_, slot, this->name_, this->repo_begin_, this->repo_.current_size ())); // Relocate any services inserted since we were created. // Any (static, i.e. DLL = 0) services registered in // the context of this guard aren't really static because // their code belongs in the DLL's code segment this->repo_.relocate_i (this->repo_begin_, this->repo_.current_size (), tmp->dll()); if (ACE::debug ()) ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("ACE (%P|%t) STDG::<dtor>, repo=%@ [%d], ") ACE_TEXT ("name=%s - loaded (type=%@, impl=%@, object=%@, active=%d)\n"), &this->repo_, slot, this->name_, tmp, tmp->type (), tmp->type ()->object (), tmp->active ())); } }
ACE_TCHAR const* const ACE_Service_Type_Dynamic_Guard::name_ [private] |
Definition at line 513 of file Service_Gestalt.h.
Definition at line 511 of file Service_Gestalt.h.
size_t ACE_Service_Type_Dynamic_Guard::repo_begin_ [private] |
Definition at line 512 of file Service_Gestalt.h.