Dynamic_Service_Base.cpp

Go to the documentation of this file.
00001 #include "ace/Dynamic_Service_Base.h"
00002 #include "ace/ACE.h"
00003 #include "ace/Service_Config.h"
00004 #include "ace/Service_Repository.h"
00005 #include "ace/Service_Types.h"
00006 #include "ace/Log_Msg.h"
00007 
00008 
00009 ACE_RCSID (ace,
00010            Dynamic_Service_Base,
00011            "Dynamic_Service_Base.cpp,v 4.9 2006/06/06 21:57:05 shuston Exp")
00012 
00013   ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00014 
00015 
00016 void
00017 ACE_Dynamic_Service_Base::dump (void) const
00018 {
00019 #if defined (ACE_HAS_DUMP)
00020   ACE_TRACE ("ACE_Dynamic_Service_Base::dump");
00021 
00022   ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this));
00023   ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\n")));
00024   ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP));
00025 #endif /* ACE_HAS_DUMP */
00026 }
00027 
00028 // Get the instance using <name> for the current global
00029 // service configuration repository.
00030 
00031 void *
00032 ACE_Dynamic_Service_Base::instance (const ACE_TCHAR *name, bool no_global)
00033 {
00034   ACE_TRACE ("ACE_Dynamic_Service_Base::instance");
00035   return instance (ACE_Service_Config::current (), name, no_global);
00036 }
00037 
00038 
00039 void *
00040 ACE_Dynamic_Service_Base::instance (const ACE_TCHAR *name)
00041 {
00042   ACE_TRACE ("ACE_Dynamic_Service_Base::instance");
00043   return instance (ACE_Service_Config::current (), name, false);
00044 }
00045 
00046 
00047 // Find a service registration
00048 
00049 const ACE_Service_Type *
00050 ACE_Dynamic_Service_Base::find_i (const ACE_Service_Gestalt* &repo,
00051                                   const ACE_TCHAR *name,
00052                                   bool no_global)
00053 {
00054   ACE_TRACE ("ACE_Dynamic_Service_Base::find_i");
00055   const ACE_Service_Type *svc_rec = 0;
00056 
00057   ACE_Service_Gestalt* global = ACE_Service_Config::global ();
00058 
00059   for ( ; (repo->find (name, &svc_rec) == -1) && !no_global; repo = global)
00060     {
00061       // Check the static repo, too if different
00062       if (repo == global)
00063   break;
00064     }
00065 
00066   return svc_rec;
00067 }
00068 
00069 
00070 // Get the instance using <name> for specific configuration repository.
00071 
00072 void *
00073 ACE_Dynamic_Service_Base::instance (const ACE_Service_Gestalt* repo,
00074                                     const ACE_TCHAR *name,
00075                                     bool no_global)
00076 {
00077   ACE_TRACE ("ACE_Dynamic_Service_Base::instance");
00078 
00079   void *obj = 0;
00080   const ACE_Service_Type_Impl *type = 0;
00081 
00082   const ACE_Service_Gestalt* repo_found = repo;
00083 
00084   const ACE_Service_Type *svc_rec = find_i (repo_found, name, no_global);
00085   if (svc_rec != 0)
00086     {
00087       type = svc_rec->type ();
00088       if (type != 0)
00089   obj = type->object ();
00090     }
00091 
00092   if (ACE::debug ())
00093     {
00094       ACE_DEBUG ((LM_DEBUG,
00095       ACE_LIB_TEXT ("(%P|%t) DSB::instance, repo=%@, name=%s, ")
00096       ACE_LIB_TEXT ("type=%@ => %@"),
00097       repo->repo_, name, type, obj));
00098 
00099       if (repo->repo_ != repo_found->repo_)
00100   ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT (" [in repo=%@]\n"),
00101         repo_found->repo_));
00102       else
00103   ACE_DEBUG ((LM_DEBUG, ACE_LIB_TEXT ("\n")));
00104 
00105     }
00106 
00107   return obj;
00108 }
00109 
00110 
00111 // Get the instance using <name> for specific configuration repository.
00112 
00113 void *
00114 ACE_Dynamic_Service_Base::instance (const ACE_Service_Gestalt* repo,
00115                                     const ACE_TCHAR *name)
00116 {
00117   return instance(repo,name,false);
00118 }
00119 
00120 
00121 ACE_END_VERSIONED_NAMESPACE_DECL

Generated on Thu Nov 9 09:41:50 2006 for ACE by doxygen 1.3.6