ImR_Activator_i.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //=============================================================================
00003 /**
00004 *  @file   ImR_Activator_i.h
00005 *
00006 *  ImR_Activator_i.h,v 1.11 2005/05/23 17:58:34 michel_j Exp
00007 *
00008 *  @author Priyanka Gontla <gontla_p@ociweb.com>
00009 *  @author Darrell Brunsch <brunsch@cs.wustl.edu>
00010 */
00011 //=============================================================================
00012 
00013 #ifndef IMR_ACTIVATOR_I_H
00014 #define IMR_ACTIVATOR_I_H
00015 
00016 #include "activator_export.h"
00017 
00018 #include "ImR_ActivatorS.h"
00019 #include "ImR_LocatorC.h"
00020 
00021 #include "ace/Process_Manager.h"
00022 #include "ace/Hash_Map_Manager.h"
00023 #include "ace/Null_Mutex.h"
00024 #include "ace/SString.h"
00025 
00026 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00027 # pragma once
00028 #endif /* ACE_LACKS_PRAGMA_ONCE */
00029 
00030 class Activator_Options;
00031 
00032 // ace/Functor.h doesn't provide functors for every built in integer type.
00033 // Depending on the platform and what pid_t maps to, the functors may be missing.
00034 struct ACE_Hash_pid_t
00035 {
00036   unsigned long operator () (pid_t t) const
00037   {
00038     return t;
00039   }
00040 };
00041 
00042 struct ACE_Equal_To_pid_t
00043 {
00044   int operator () (const pid_t lhs, const pid_t rhs) const
00045   {
00046     return lhs == rhs;
00047   }
00048 };
00049 
00050 
00051 /**
00052 * @class ImR_Activator_i
00053 *
00054 * @brief IMR Activator Interface.
00055 *
00056 * This class provides the interface for the various activities
00057 * that can be done by the ImR_Activator.
00058 *
00059 */
00060 class Activator_Export ImR_Activator_i : public POA_ImplementationRepository::Activator,
00061                                          public ACE_Event_Handler
00062 {
00063 public:
00064   ImR_Activator_i (void);
00065 
00066  void start_server (
00067    const char* name,
00068    const char* cmdline,
00069    const char* dir,
00070    const ImplementationRepository::EnvironmentList & env ACE_ENV_ARG_DECL)
00071    ACE_THROW_SPEC ((CORBA::SystemException, ImplementationRepository::CannotActivate));
00072 
00073   void shutdown(ACE_ENV_SINGLE_ARG_DECL)
00074     ACE_THROW_SPEC ((CORBA::SystemException));
00075 
00076   /// Initialize the Server state - parsing arguments and waiting.
00077   int init (Activator_Options& opts ACE_ENV_ARG_DECL_WITH_DEFAULTS);
00078 
00079   /// Cleans up any state created by init*.
00080   int fini (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS);
00081 
00082   /// Runs the orb.
00083   int run (ACE_ENV_SINGLE_ARG_DECL_WITH_DEFAULTS);
00084 
00085   /// Shutdown the orb.
00086   void shutdown (bool wait_for_completion ACE_ENV_ARG_DECL);
00087 
00088 private:
00089 
00090   int init_with_orb (CORBA::ORB_ptr orb, const Activator_Options& opts ACE_ENV_ARG_DECL_WITH_DEFAULTS);
00091 
00092   void register_with_imr(ImplementationRepository::Activator_ptr activator);
00093 
00094   // Handles the death of the child processes of the ImR_Activator.
00095   // Informs the ImR_Locator too.
00096   int handle_exit (ACE_Process * process);
00097 
00098 private:
00099 
00100   typedef ACE_Hash_Map_Manager_Ex<pid_t,
00101                                   ACE_CString,
00102                                   ACE_Hash_pid_t,
00103                                   ACE_Equal_To_pid_t,
00104                                   ACE_Null_Mutex> ProcessMap;
00105 
00106   ACE_Process_Manager process_mgr_;
00107 
00108   PortableServer::POA_var root_poa_;
00109   PortableServer::POA_var imr_poa_;
00110 
00111   ImplementationRepository::Locator_var locator_;
00112 
00113   /// We're given a token when registering with the locator, which
00114   /// we must use when unregistering.
00115   CORBA::Long registration_token_;
00116 
00117   CORBA::ORB_var orb_;
00118 
00119   unsigned int debug_;
00120 
00121   bool notify_imr_;
00122 
00123   ACE_CString name_;
00124 
00125   ProcessMap process_map_;
00126 };
00127 
00128 #endif /* IMR_ACTIVATOR_I_H */

Generated on Thu Nov 9 13:36:19 2006 for TAO_Implementation_Repository by doxygen 1.3.6