Service_Config.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //====================================================================
00004 /**
00005  *  @file    Service_Config.h
00006  *
00007  *  $Id: Service_Config.h 81673 2008-05-09 19:09:43Z iliyan $
00008  *
00009  *  @author Douglas C. Schmidt <schmidt@cs.wustl.edu>
00010  */
00011 //====================================================================
00012 
00013 #ifndef ACE_SERVICE_CONFIG_H
00014 #define ACE_SERVICE_CONFIG_H
00015 
00016 #include /**/ "ace/pre.h"
00017 
00018 #include /**/ "ace/config-all.h"
00019 #include "ace/Default_Constants.h"
00020 #include "ace/Intrusive_Auto_Ptr.h"
00021 #include "ace/Service_Gestalt.h"
00022 #include "ace/Synch_Traits.h"
00023 
00024 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00025 # pragma once
00026 #endif /* ACE_LACKS_PRAGMA_ONCE */
00027 
00028 #include "ace/OS_NS_signal.h"
00029 
00030 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00031 
00032 // Forward decl.
00033 class ACE_Service_Object;
00034 class ACE_Service_Type;
00035 class ACE_Service_Type_Impl;
00036 class ACE_Service_Repository;
00037 class ACE_Sig_Adapter;
00038 class ACE_Allocator;
00039 class ACE_Reactor;
00040 class ACE_Thread_Manager;
00041 class ACE_DLL;
00042 
00043 #if (ACE_USES_CLASSIC_SVC_CONF == 1)
00044 #define ACE_STATIC_SERVICE_DIRECTIVE(ident, parameters) \
00045   ACE_TEXT ("static ") \
00046   ACE_TEXT (ident) \
00047   ACE_TEXT (" \"") \
00048   ACE_TEXT (parameters) \
00049   ACE_TEXT ("\"")
00050 #define ACE_DYNAMIC_SERVICE_DIRECTIVE(ident, libpathname, objectclass, parameters) \
00051   ACE_TEXT ("dynamic ") \
00052   ACE_TEXT (ident) \
00053   ACE_TEXT (" Service_Object * ") \
00054   ACE_TEXT (libpathname) \
00055   ACE_TEXT (":") \
00056   ACE_TEXT (objectclass) \
00057   ACE_TEXT ("() \"") \
00058   ACE_TEXT (parameters) \
00059   ACE_TEXT ("\"")
00060 #define ACE_REMOVE_SERVICE_DIRECTIVE(ident) \
00061   ACE_TEXT ("remove ") \
00062   ACE_TEXT (ident)
00063 class ACE_Svc_Conf_Param;
00064 #else
00065 #define ACE_STATIC_SERVICE_DIRECTIVE(ident, parameters) \
00066   ACE_TEXT ("<ACE_Svc_Conf><static id=\"") \
00067   ACE_TEXT (ident) \
00068   ACE_TEXT ("\" params=\"") \
00069   ACE_TEXT (parameters) \
00070   ACE_TEXT ("\"/></ACE_Svc_Conf>")
00071 #define ACE_DYNAMIC_SERVICE_DIRECTIVE(ident, libpathname, objectclass, parameters) \
00072   ACE_TEXT ("<ACE_Svc_Conf><dynamic id=\"") \
00073   ACE_TEXT (ident) \
00074   ACE_TEXT ("\" type=\"Service_Object\">") \
00075   ACE_TEXT ("<initializer path=\"") \
00076   ACE_TEXT (libpathname) \
00077   ACE_TEXT ("\" init=\"") \
00078   ACE_TEXT (objectclass) \
00079   ACE_TEXT ("\"") \
00080   ACE_TEXT (" params=\"") \
00081   ACE_TEXT (parameters) \
00082   ACE_TEXT ("\"/></dynamic></ACE_Svc_Conf>")
00083 #define ACE_REMOVE_SERVICE_DIRECTIVE(ident) \
00084   ACE_TEXT ("<ACE_Svc_Conf><remove id=\"") \
00085   ACE_TEXT (ident) \
00086   ACE_TEXT ("\"></remove></ACE_Svc_Conf>")
00087 class ACE_XML_Svc_Conf;
00088 #endif /* ACE_USES_CLASSIC_SVC_CONF == 1 */
00089 
00090 ACE_END_VERSIONED_NAMESPACE_DECL
00091 
00092 extern "C"
00093 {
00094   typedef ACE_Service_Object *(*ACE_SERVICE_ALLOCATOR) (ACE_Service_Object_Exterminator *);
00095 }
00096 
00097 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00098 
00099 /**
00100  * @class ACE_Static_Svc_Descriptor
00101  *
00102  * @brief Holds the information necessary to describe a statically linked
00103  * Svc.
00104  */
00105 class ACE_Static_Svc_Descriptor
00106 {
00107 public:
00108   /// Name of the service.
00109   const ACE_TCHAR *name_;
00110 
00111   /// Type of service.
00112   int type_;
00113 
00114   /// Factory function that allocates the service.
00115   ACE_SERVICE_ALLOCATOR alloc_;
00116 
00117   /// Bitmask flags indicating how the framework should delete memory.
00118   u_int flags_;
00119 
00120   /// Flag indicating whether the service starts out active.
00121   int active_;
00122 
00123   /// Dump the state of an object.
00124   void dump (void) const;
00125 
00126   /// Declare the dynamic allocation hooks.
00127   ACE_ALLOC_HOOK_DECLARE;
00128 
00129 public:
00130   /// Compare two service descriptors for equality.
00131   bool operator== (ACE_Static_Svc_Descriptor &) const;
00132 
00133   /// Compare two service descriptors for inequality.
00134   bool operator!= (ACE_Static_Svc_Descriptor &) const;
00135 };
00136 
00137 
00138 /**
00139  * @class ACE_Threading_Helper
00140  *
00141  * @brief Encapsulates responsibility for allocating, destroying and
00142  * manipulating the value, associated with a thread-specific
00143  * key. Relates to the ability of the created thread to inherit the
00144  * parent thread's gestalt. Designed to be used as an instance member
00145  * of @c ACE_Service_Config.
00146  *
00147  * Partial specialization over ACE_SYNCH_MUTEX is used to implement
00148  * specific behavior in both multi- and single-threaded builds.
00149  */
00150 template <typename LOCK>
00151 class ACE_Threading_Helper
00152 {
00153 };
00154 
00155 /*
00156  * Specialization for a multi threaded program
00157  */
00158 template<>
00159 class ACE_Export ACE_Threading_Helper<ACE_Thread_Mutex>
00160 {
00161 public:
00162   ACE_Threading_Helper ();
00163   ~ACE_Threading_Helper ();
00164 
00165   void set (void*);
00166   void* get (void);
00167 
00168 private:
00169   /// Key for the thread-specific data, which is a simple pointer to
00170   /// the thread's (currently-) global configuration context.
00171   ACE_thread_key_t key_;
00172 };
00173 
00174 /*
00175  * Specialization for a single threaded program
00176  */
00177 template<>
00178 class ACE_Export ACE_Threading_Helper<ACE_Null_Mutex>
00179 {
00180 public:
00181   ACE_Threading_Helper ();
00182   ~ACE_Threading_Helper ();
00183 
00184   void set (void*);
00185   void* get (void);
00186 };
00187 
00188 #define ACE_Component_Config ACE_Service_Config
00189 
00190 /**
00191  * @class ACE_Service_Config
00192  *
00193  * @brief Supplies common server operations for dynamic and static
00194  * configuration of service.
00195  *
00196  * The ACE_Service_Config uses the Monostate pattern.  Therefore,
00197  * you can only have one of these instantiated per-process. It
00198  * represents the process-wide collection of services, which is
00199  * typicaly shared among all other configurable entities. The only
00200  * ACE_Service_Config instance is registered with and owned by the
00201  * ACE_Object_Manager.
00202  *
00203  * By contrast, the ACE_Service_Gestalt represents the collection
00204  * of services, pertaining to a configurable entity. Typicaly, a
00205  * "configurable entity" is an instance, which owns an instance of
00206  * ACE_Service_Gestalt in order to ensure full controll over the
00207  * services it needs.
00208  *
00209  * Another facet of ACE_Service_Config is that for a given thread,
00210  * it provides access to its current, process-global
00211  * ACE_Service_Gestalt instance through its curent() method.
00212  *
00213  * @note The signal_handler_ static member is allocated by the
00214  * ACE_Object_Manager.  The ACE_Service_Config constructor
00215  * uses signal_handler_.  Therefore, if the program has any
00216  * static ACE_Service_Config objects, there might be
00217  * initialization order problems.  They can be minimized, but
00218  * not eliminated, by _not_ #defining
00219  * ACE_HAS_NONSTATIC_OBJECT_MANAGER.
00220  */
00221 class ACE_Export ACE_Service_Config
00222 {
00223 
00224   /// The Instance, or the global (default) configuration context.
00225   /// The monostate would forward the calls to that instance. The TSS
00226   /// will point here
00227   ACE_Intrusive_Auto_Ptr<ACE_Service_Gestalt> instance_;
00228 
00229   /// A helper instance to manage thread-specific key creation.
00230   /// Dependent on the syncronization mutex ACE uses, the corresponding
00231   /// partial template instantiation will perform the right services
00232   /// that have to do with managing thread-specific storage. Note that,
00233   /// for single-threaded builds they would do (next to) nothing.
00234   ACE_Threading_Helper<ACE_SYNCH_MUTEX> threadkey_;
00235 
00236 public:
00237 
00238   // = Initialization and termination methods.
00239 
00240   /**
00241    * Initialize the Service Repository. Note that initialising @a
00242    * signum to a negative number will prevent a signal handler being
00243    * registered when the repository is opened.
00244    */
00245   ACE_Service_Config (bool ignore_static_svcs = true,
00246                       size_t size = ACE_DEFAULT_SERVICE_REPOSITORY_SIZE,
00247                       int signum = SIGHUP);
00248 
00249   /**
00250    * Performs an open without parsing command-line arguments.  The
00251    * @a logger_key indicates where to write the logging output, which
00252    * is typically either a STREAM pipe or a socket address.
00253    */
00254   ACE_Service_Config (const ACE_TCHAR program_name[],
00255                       const ACE_TCHAR *logger_key = ACE_DEFAULT_LOGGER_KEY);
00256 
00257   /// Perform user-specified close activities and remove dynamic
00258   /// memory.
00259   virtual ~ACE_Service_Config (void);
00260 
00261 private:
00262 
00263   /**
00264    * Performs an open without parsing command-line arguments.
00265    * Implements whats different in the opening sequence
00266    * for this class, as opposed to the base class.
00267    *
00268    * The @a logger_key indicates where to write the logging output, which
00269    * is typically either a STREAM pipe or a socket address.  If
00270    * @a ignore_default_svc_conf_file is non-0 then the "svc.conf" file
00271    * will be ignored.  If @a ignore_debug_flag is non-0 then the
00272    * application is responsible for setting the
00273    * @c ACE_Log_Msg::priority_mask() appropriately.  Returns number of
00274    * errors that occurred on failure and 0 otherwise.
00275    */
00276   virtual int open_i (const ACE_TCHAR program_name[],
00277                       const ACE_TCHAR *logger_key,
00278                       bool ignore_static_svcs,
00279                       bool ignore_default_svc_conf_file,
00280                       bool ignore_debug_flag);
00281 
00282   /**
00283    * Implements whats different in the command line parameter processing
00284    * for this class, as opposed to the base class.
00285    */
00286   virtual int parse_args_i (int argc, ACE_TCHAR *argv[]);
00287 
00288   /// = Static interfaces
00289 
00290  public:
00291  /**
00292    * Returns the process-wide global singleton instance. It would
00293    * have been created and will be managed by the Object Manager.
00294    */
00295   static ACE_Service_Config* singleton (void);
00296 
00297   /**
00298    * Mutator for the currently active configuration context instance
00299    * (gestalt). Intended for use by helper classes like @see
00300    * ACE_Service_Config_Guard. Stack-based instances can be used to
00301    * temporarily change which gestalt is seen as global by static
00302    * initializers (especially those in DLLs loaded at run-time).
00303    */
00304   static void current (ACE_Service_Gestalt*);
00305 
00306   /**
00307    * Accessor for the "current" service gestalt
00308    */
00309   static ACE_Service_Gestalt* current (void);
00310 
00311   /**
00312    * This is what the static service initializators are hard-wired to
00313    * use, so in order to avoid interface changes this method merely
00314    * forwards to @c ACE_Service_Config::current. This enables us to
00315    * enforce which Service Gestalt is used for services registering
00316    * through static initializers. Especially important for DLL-based
00317    * dynamic services, which can contain their own static services and
00318    * static initializers.
00319    *
00320    * @deprecated Use current() instead.
00321    */
00322   static ACE_Service_Gestalt* instance (void);
00323 
00324   /**
00325    * Returns a process-wide global singleton instance in contrast with
00326    * current (), which may return a different instance at different
00327    * times, dependent on the context. Modifying this method's return
00328    * value is strongly discouraged as it will circumvent the mechanism
00329    * for dynamically loading services. If you must, use with extreme
00330    * caution!
00331    */
00332   static ACE_Service_Gestalt* global (void);
00333 
00334   /**
00335    * Performs an open without parsing command-line arguments.  The
00336    * @a logger_key indicates where to write the logging output, which
00337    * is typically either a STREAM pipe or a socket address.  If
00338    * @a ignore_static_svcs is true then static services are not loaded,
00339    * otherwise, they are loaded.  If @a ignore_default_svc_conf_file is
00340    * non-0 then the <svc.conf> configuration file will be ignored.
00341    * Returns zero upon success, -1 if the file is not found or cannot
00342    * be opened (errno is set accordingly), otherwise returns the
00343    * number of errors encountered loading the services in the
00344    * specified svc.conf configuration file.  If @a ignore_debug_flag is
00345    * non-0 then the application is responsible for setting the
00346    * @c ACE_Log_Msg::priority_mask appropriately.
00347    */
00348   static int open (const ACE_TCHAR program_name[],
00349                    const ACE_TCHAR *logger_key = ACE_DEFAULT_LOGGER_KEY,
00350                    bool ignore_static_svcs = true,
00351                    bool ignore_default_svc_conf_file = false,
00352                    bool ignore_debug_flag = false);
00353 
00354   /**
00355    * This is the primary entry point into the ACE_Service_Config (the
00356    * constructor just handles simple initializations).  It parses
00357    * arguments passed in from @a argc and @a argv parameters.  The
00358    * arguments that are valid in a call to this method include:
00359    *
00360    * - '-b' Option to indicate that we should be a daemon. Note that when
00361    *        this option is used, the process will be daemonized before the
00362    *        service configuration file(s) are read. During daemonization,
00363    *        (on POSIX systems) the current directory will be changed to "/"
00364    *        so the caller should either fully specify the file names, or
00365    *        execute a @c chroot() to the appropriate directory.
00366    *        @sa ACE::daemonize().
00367    * - '-d' Turn on debugging mode
00368    * - '-f' Specifies a configuration file name other than the default
00369    *        svc.conf. Can be specified multiple times to use multiple files.
00370    * - '-k' Specifies the rendezvous point to use for the ACE distributed
00371    *        logger.
00372    * - '-y' Explicitly enables the use of static services. This flag
00373    *        overrides the @a ignore_static_svcs parameter value.
00374    * - '-n' Explicitly disables the use of static services. This flag
00375    *        overrides the @a ignore_static_svcs parameter value.
00376    * - '-p' Specifies a pathname which is used to store the process id.
00377    * - '-s' Specifies a signal number other than SIGHUP to trigger reprocessing
00378    *        of the configuration file(s). Ignored for platforms that do not
00379    *        have POSIX signals, such as Windows.
00380    * - '-S' Specifies a service directive string. Enclose the string in quotes
00381    *        and escape any embedded quotes with a backslash. This option
00382    *        specifies service directives without the need for a configuration
00383    *        file.
00384    *
00385    * @param argc The number of commandline arguments.
00386    * @param argv The array with commandline arguments
00387    * @param logger_key   Indicates where to write the logging output,
00388    *                     which is typically either a STREAM pipe or a
00389    *                     socket address.
00390    * @param ignore_static_svcs   If true then static services are not loaded,
00391    *                             otherwise, they are loaded.
00392    * @param ignore_default_svc_conf_file  If non-0 then the @c svc.conf
00393    *                                      configuration file will be ignored.
00394    * @param ignore_debug_flag If true then the application is responsible
00395    *                          for setting the @c ACE_Log_Msg::priority_mask
00396    *                          appropriately.
00397    *
00398    * @retval -1   The configuration file is not found or cannot
00399    *              be opened (errno is set accordingly).
00400    * @retval  0   Success.
00401    * @retval  >0  The number of errors encountered while processing
00402    *              the service configuration file(s).
00403    */
00404   static int open (int argc,
00405                    ACE_TCHAR *argv[],
00406                    const ACE_TCHAR *logger_key = ACE_DEFAULT_LOGGER_KEY,
00407                    bool ignore_static_svcs = true,
00408                    bool ignore_default_svc_conf_file = false,
00409                    bool ignore_debug_flag = false);
00410 
00411   /// Tidy up and perform last rites when ACE_Service_Config is shut
00412   /// down.  This method calls close_svcs().  Returns 0.
00413   static int close (void);
00414 
00415   /// Perform user-specified close hooks and possibly delete all of the
00416   /// configured services in the <Service_Repository>.
00417   static int fini_svcs (void);
00418 
00419   /// True if reconfiguration occurred.
00420   static int reconfig_occurred (void);
00421 
00422   /// Indicate that reconfiguration occurred.
00423   static void reconfig_occurred (int);
00424 
00425   /// Perform the reconfiguration process.
00426   static void reconfigure (void);
00427 
00428   // = The following methods are static in order to enforce Singleton
00429   // semantics for the Reactor, Service_Repository, Thread_Manager,
00430   // and Acceptor/Connector Strategy factory.  Other portions of the
00431   // system may need to access them at some point or another...
00432 
00433   // = This is not strictly needed, anymore since the service configurator
00434   // has been refactored to allow multiple service configuration
00435   // instances (called gestalts). The interfaces, however were retained in for
00436   // the sake of maintaining source-code compatibility.
00437 
00438 
00439   // = Accessors and mutators for process-wide Singletons.
00440 
00441   /// Returns a pointer to the list of statically linked services.
00442   ///
00443   /// @deprecated - Same as instance(), but still useful in legacy code,
00444   /// (notably, one that can not be easily modified) which uses the following
00445   /// idiom for registering static services:
00446   ///
00447   ///    ACE_Service_Config::static_svcs ()->insert (...);
00448   static ACE_Service_Gestalt* static_svcs (void);
00449 
00450   /// Insert a static service descriptor for processing on open_i(). The
00451   /// corresponding ACE_STATIC_SVC_* macros were chaged to use this method
00452   /// instead of obtaining a ptr to a container. See the note on static_svcs().
00453   /// Added to prevent exposing the internal storage representation of the
00454   /// services repository and provide a better way of debugging service
00455   /// loading and registration problems.
00456   static int insert (ACE_Static_Svc_Descriptor *svc);
00457 
00458   // = Utility methods.
00459   /// Dynamically link the shared object file and retrieve a pointer to
00460   /// the designated shared object in this file.
00461   static int initialize (const ACE_Service_Type *,
00462                          const ACE_TCHAR *parameters);
00463 
00464   /// Initialize and activate a statically @a svc_name service.
00465   static int initialize (const ACE_TCHAR *svc_name,
00466                          const ACE_TCHAR *parameters);
00467 
00468   /// Resume a @a svc_name that was previously suspended or has not yet
00469   /// been resumed (e.g., a static service).
00470   static int resume (const ACE_TCHAR svc_name[]);
00471 
00472   /**
00473    * Suspend @a svc_name.  Note that this will not unlink the service
00474    * from the daemon if it was dynamically linked, it will mark it as
00475    * being suspended in the Service Repository and call the <suspend>
00476    * member function on the appropriate ACE_Service_Object.  A
00477    * service can be resumed later on by calling the <RESUME> member
00478    * function...
00479    */
00480   static int suspend (const ACE_TCHAR svc_name[]);
00481 
00482   /// Totally remove @a svc_name from the daemon by removing it
00483   /// from the ACE_Reactor, and unlinking it if necessary.
00484   static int remove (const ACE_TCHAR svc_name[]);
00485 
00486 #if defined (ACE_HAS_WINCE) && defined (ACE_USES_WCHAR)
00487   // We must provide these function to bridge the Svc_Conf parser
00488   // with ACE.
00489   static int initialize (const ACE_Service_Type *, ACE_ANTI_TCHAR []);
00490   static int initialize (const char svc_name[], ACE_ANTI_TCHAR parameters[]);
00491   static int resume (const ACE_ANTI_TCHAR svc_name[]);
00492   static int suspend (const ACE_ANTI_TCHAR svc_name[]);
00493   static int remove (const ACE_ANTI_TCHAR svc_name[]);
00494 #endif /* ACE_HAS_WINCE */
00495 
00496   /// Dump the state of an object.
00497   void dump (void) const;
00498 
00499   /// Set the signal_handler;for internal use by ACE_Object_Manager only.
00500   static ACE_INLINE void signal_handler (ACE_Sig_Adapter *);
00501 
00502   /// Declare the dynamic allocation hooks.
00503   ACE_ALLOC_HOOK_DECLARE;
00504 
00505   /// Process a file containing a list of service configuration
00506   /// directives.
00507   static int process_file (const ACE_TCHAR file[]);
00508 
00509   /// Process one service configuration @a directive, which is passed as
00510   /// a string.  Returns the number of errors that occurred.
00511   static int process_directive (const ACE_TCHAR directive[]);
00512 
00513   /**
00514    * Process one static service definition.  Load a new static service
00515    * into the ACE_Service_Repository.
00516    *
00517    * @param ssd Service descriptor, see the document of
00518    *        ACE_Static_Svc_Descriptor for more details.
00519    *
00520    * @param force_replace If set the new service descriptor replaces
00521    *        any previous instance in the ACE_Service_Repository.
00522    *
00523    * @return Returns -1 if the service cannot be 'loaded'.
00524    */
00525   static int process_directive (const ACE_Static_Svc_Descriptor &ssd,
00526                                 bool force_replace = false);
00527 
00528   /**
00529    * Process (or re-process) service configuration requests that are
00530    * provided in the svc.conf file(s).  Returns the number of errors
00531    * that occurred.
00532    */
00533   static int process_directives (void);
00534 
00535   /// Handles signals to trigger reconfigurations.
00536   static void handle_signal (int sig, siginfo_t *, ucontext_t *);
00537 
00538   /**
00539    * Handle the command-line options intended for the
00540    * ACE_Service_Config.  Note that @c argv[0] is assumed to be the
00541    * program name.
00542    * The arguments that are valid in a call to this method are
00543    * - '-b' Option to indicate that we should be a daemon
00544    * - '-d' Turn on debugging mode
00545    * - '-f' Option to read in the list of svc.conf file names
00546    * - '-k' Option to read a wide string where in the logger output can
00547    *        be written
00548    * - '-y' Turn on the flag for a  repository of statically
00549    *        linked services
00550    * - '-n' Need not have a repository of statically linked services
00551    * - '-S' Option to read in the list of services on the command-line
00552    *        Please observe the difference between options '-f' that looks
00553    *        for a list of files and here a list of services.
00554    */
00555   static int parse_args (int, ACE_TCHAR *argv[]);
00556 
00557 #if (ACE_USES_CLASSIC_SVC_CONF == 0)
00558   static ACE_Service_Type *create_service_type  (const ACE_TCHAR *n,
00559                                                  ACE_Service_Type_Impl *o,
00560                                                  ACE_DLL &dll,
00561                                                  int active);
00562 #endif /* ACE_USES_CLASSIC_SVC_CONF == 0 */
00563 
00564   static ACE_Service_Type_Impl *
00565     create_service_type_impl (const ACE_TCHAR *name,
00566                               int type,
00567                               void *symbol,
00568                               u_int flags,
00569                               ACE_Service_Object_Exterminator gobbler);
00570 
00571   /// @deprecated
00572   /// Process service configuration requests that were provided on the
00573   /// command-line.  Returns the number of errors that occurred.
00574   static int process_commandline_directives (void);
00575 
00576   /// Become a daemon.
00577   static int start_daemon (void);
00578 
00579   // @deprecated
00580   // Add the default statically-linked services to the
00581   // ACE_Service_Repository.
00582   static int load_static_svcs (void);
00583 
00584 protected:
00585 
00586 #if (ACE_USES_CLASSIC_SVC_CONF == 1)
00587   /// @deprecated
00588   /// This is the implementation function that process_directives()
00589   /// and process_directive() both call.  Returns the number of errors
00590   /// that occurred.
00591   static int process_directives_i (ACE_Svc_Conf_Param *param);
00592 #endif /* ACE_USES_CLASSIC_SVC_CONF == 1 */
00593 
00594 
00595   // = Process-wide state.
00596 
00597 private:
00598 
00599   /// Have we called ACE_Service_Config::open() yet?
00600   bool is_opened_;
00601 
00602 #if defined (ACE_MT_SAFE) && (ACE_MT_SAFE != 0)
00603   /// Synchronization variable for open, etc.
00604   mutable ACE_SYNCH_MUTEX lock_;
00605 #endif /* ACE_MT_SAFE */
00606 
00607   /// True if reconfiguration occurred.
00608   static sig_atomic_t reconfig_occurred_;
00609 
00610   // = Set by command-line options.
00611   /// Shall we become a daemon process?
00612   static bool be_a_daemon_;
00613 
00614   /// Pathname of file to write process id.
00615   static ACE_TCHAR *pid_file_name_;
00616 
00617   /// Number of the signal used to trigger reconfiguration.
00618   static int signum_;
00619 
00620   /// Handles the reconfiguration signals.
00621   static ACE_Sig_Adapter *signal_handler_;
00622 
00623   /// Pointer to the Singleton (ACE_Cleanup) Gestalt instance.
00624   /// There is thread-specific global instance pointer, which is used to
00625   /// temporarily change which Gestalt instance is used for static service
00626   /// registrations.
00627   ///
00628   /// A specific use case is a thread, which loads a _dynamic_ service from
00629   /// a DLL. If the said DLL also contains additional _static_ services,
00630   /// those *must* be registered with the same configuration repository as
00631   /// the dynamic service. Otherwise, the DLL's static services would be
00632   /// registered with the global Gestalt and may outlive the DLL that
00633   /// contains their code and perhaps the memory in which they are in.
00634   /// This is a problem because if the DLL gets unloaded (as it will, if
00635   /// it was loaded in an instance of Gestalt), the DLL's memory will be
00636   /// deallocated, but the global service repository will still "think"
00637   /// it must finalize the (DLL's) static services - with disastrous
00638   /// consequences, occurring in the post-main code (at_exit()).
00639 
00640   /// This class needs the intimate access to be able to swap the
00641   /// current TSS pointer for the global Gestalt.
00642   friend class ACE_Service_Config_Guard;
00643 
00644   /// The helper needs intimate access (when building with no threads)
00645   friend class ACE_Threading_Helper <ACE_Thread_Mutex>;
00646   friend class ACE_Threading_Helper <ACE_Null_Mutex>;
00647 };
00648 
00649 /**
00650  * @class ACE_Service_Config_Guard
00651  *
00652  * @brief A guard class, designed to be instantiated on the stack.
00653  *
00654  * Instantiating it with a specific configuration ensures any references to
00655  * ACE_Service_Config::instance(), even when occuring in static constructors,
00656  * will allways access the designated configuration instance.
00657  * This comes very handy when a dynamic service also registers any static
00658  * services of its own and their static factories.
00659  */
00660 class ACE_Export ACE_Service_Config_Guard
00661 {
00662 public:
00663   ACE_Service_Config_Guard (ACE_Service_Gestalt* psg);
00664   ~ACE_Service_Config_Guard (void);
00665 
00666 private:
00667   // Private AND not implemented to disable copying
00668   ACE_Service_Config_Guard(const ACE_Service_Config_Guard&);
00669   ACE_Service_Config_Guard& operator= (const ACE_Service_Config_Guard&);
00670 
00671 private:
00672   ACE_Intrusive_Auto_Ptr<ACE_Service_Gestalt> saved_;
00673 };
00674 
00675 
00676 ACE_END_VERSIONED_NAMESPACE_DECL
00677 
00678 #if defined (__ACE_INLINE__)
00679 #include "ace/Service_Config.inl"
00680 #endif /* __ACE_INLINE__ */
00681 
00682 #include /**/ "ace/post.h"
00683 
00684 #endif /* ACE_SERVICE_CONFIG_H */

Generated on Tue Feb 2 17:18:42 2010 for ACE by  doxygen 1.4.7