ACE_Service_Type_Forward_Declaration_Guard Class Reference

Collaboration diagram for ACE_Service_Type_Forward_Declaration_Guard:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 ACE_Service_Type_Forward_Declaration_Guard (ACE_Service_Repository *r, ACE_TCHAR const *name)
 ~ACE_Service_Type_Forward_Declaration_Guard (void)

Private Attributes

const ACE_DLL dummy_dll_
ACE_Service_Repositoryrepo_
ACE_TCHAR const *const  name_
ACE_Service_Type const * dummy_

Constructor & Destructor Documentation

ACE_Service_Type_Forward_Declaration_Guard::ACE_Service_Type_Forward_Declaration_Guard ACE_Service_Repository r,
ACE_TCHAR const *  name
 

Definition at line 63 of file Service_Gestalt.cpp.

References ACE_ASSERT, ACE_DEBUG, ACE_LIB_TEXT, ACE_NEW_NORETURN, ACE_TCHAR, ACE::debug(), and LM_DEBUG.

00064     : repo_ (r)
00065     , name_ (name)
00066 {
00067   ACE_ASSERT (this->repo_ != 0); // No repository specified?
00068   ACE_ASSERT (this->name_ != 0); // No name?
00069 
00070   ACE_NEW_NORETURN (this->dummy_, // Allocate the forward declaration ...
00071                     ACE_Service_Type (this->name_,  // ... use the same name
00072                                       0,            // ... inactive
00073                                       this->dummy_dll_, // ... bogus ACE_DLL
00074                                       0));              // ... no type_impl
00075 
00076   ACE_ASSERT (this->dummy_ != 0); // No memory?
00077 
00078   if(ACE::debug ())
00079     ACE_DEBUG ((LM_DEBUG,
00080                 ACE_LIB_TEXT ("(%P|%t) FWDCL::start, repo=%@, \'%s\' ")
00081                 ACE_LIB_TEXT ("- type=%@ (impl=(nil))\n"),
00082                 this->repo_,
00083                 this->name_,
00084                 this->dummy_));
00085 
00086   // Note that the dummy_'s memory can disaper between invoking
00087   // the ctor and dtor, if the expected "real" dynamic service is
00088   // inserted in the repository.
00089   this->repo_->insert (this->dummy_);
00090 }

ACE_Service_Type_Forward_Declaration_Guard::~ACE_Service_Type_Forward_Declaration_Guard void   ) 
 

Definition at line 92 of file Service_Gestalt.cpp.

References ACE_DEBUG, ACE_ERROR, ACE_LIB_TEXT, ACE::debug(), dummy_, ACE_Service_Type::dump(), ACE_Service_Repository::find(), LM_DEBUG, LM_ERROR, LM_WARNING, ACE_Service_Repository::remove(), repo_, and ACE_Service_Type::type().

00093 {
00094   const ACE_Service_Type *tmp = 0;
00095 
00096   // Lookup without ignoring suspended services. Making sure
00097   // not to ignore any inactive services, since those may be forward
00098   // declarations
00099   int ret = this->repo_->find (this->name_, &tmp, 0);
00100 
00101   // We inserted it (as inactive), so we expect to find it, right?
00102   if (ret < 0 && ret != -2)
00103     {
00104       if(ACE::debug ())
00105         ACE_ERROR ((LM_WARNING,
00106                     ACE_LIB_TEXT ("(%P|%t) FWDCL::end - Failed (%d) to find %s\n"),
00107                     ret, this->name_));
00108       return;
00109     }
00110 
00111   if (tmp != 0 && tmp->type () != 0)
00112     {
00113       // Something has registered a proper (non-forward-decl) service with
00114       // the same name as our dummy. The ACE_Service_Gestalt::insert() modifies
00115       // the memory for the previous ACE_Service_Type instance. It has in fact
00116       // taken ownership and deleted the instance when it replaced it with the
00117       // actual implementation, so nothing is left to do. We are hereby giving
00118       // up any ownership claims.
00119       this->dummy_ = 0;
00120 
00121       if(ACE::debug ())
00122         {
00123           ACE_DEBUG ((LM_DEBUG,
00124                       ACE_LIB_TEXT ("(%P|%t) FWDCL::end, repo=%@ - ")
00125                       ACE_LIB_TEXT ("Found different decl - "),
00126                       this->repo_,
00127                       this->name_));
00128           tmp->dump ();
00129         }
00130 
00131     }
00132   else
00133     {
00134       if(ACE::debug ())
00135         {
00136           ACE_DEBUG ((LM_DEBUG,
00137                       ACE_LIB_TEXT ("(%P|%t) FWDCL::end, repo=%@ - ")
00138                       ACE_LIB_TEXT ("Removing incomplete decl - "),
00139                       this->repo_,
00140                       this->name_));
00141           this->dummy_->dump ();
00142         }
00143 
00144       // The (dummy) forward declaration is still there and is
00145       // the same, which means that no actual declaration was
00146       // provided inside the guarded scope. Therefore, the forward
00147       // declaration is no longer necessary.
00148       if (this->repo_->remove (this->name_,
00149                                const_cast< ACE_Service_Type**> (&this->dummy_)) == 0)
00150         {
00151           delete this->dummy_;
00152         }
00153       else
00154         {
00155           if(ACE::debug ())
00156             {
00157               ACE_ERROR ((LM_ERROR,
00158                           ACE_LIB_TEXT ("(%P|%t) FWDCL::end, repo=%@ - ")
00159                           ACE_LIB_TEXT ("Failed to remove incomplete decl"),
00160                           this->repo_,
00161                           this->name_));
00162               this->dummy_->dump ();
00163             }
00164         }
00165     }
00166 
00167   // Clean up
00168   this->dummy_ = 0;
00169   this->repo_ = 0;
00170 }


Member Data Documentation

ACE_Service_Type const* ACE_Service_Type_Forward_Declaration_Guard::dummy_ [private]
 

Definition at line 59 of file Service_Gestalt.cpp.

Referenced by ~ACE_Service_Type_Forward_Declaration_Guard().

const ACE_DLL ACE_Service_Type_Forward_Declaration_Guard::dummy_dll_ [private]
 

Definition at line 56 of file Service_Gestalt.cpp.

ACE_TCHAR const* const ACE_Service_Type_Forward_Declaration_Guard::name_ [private]
 

Definition at line 58 of file Service_Gestalt.cpp.

ACE_Service_Repository* ACE_Service_Type_Forward_Declaration_Guard::repo_ [private]
 

Definition at line 57 of file Service_Gestalt.cpp.

Referenced by ~ACE_Service_Type_Forward_Declaration_Guard().


The documentation for this class was generated from the following file:
Generated on Thu Nov 9 11:29:29 2006 for ACE by doxygen 1.3.6