Svc_Conf_Param.h

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    Svc_Conf_Param.h
00006  *
00007  *  $Id: Svc_Conf_Param.h 81312 2008-04-09 21:01:34Z iliyan $
00008  *
00009  *  @author Iliyan Jeliazkov <iliyan@ociweb.com>
00010  *  @author Based on code originally found in Svc_Conf.h by Doug
00011             Schmidt and Ossama Othman.
00012  */
00013 //=============================================================================
00014 
00015 
00016 #ifndef ACE_SVC_CONF_PARAM_H
00017 #define ACE_SVC_CONF_PARAM_H
00018 
00019 #include /**/ "ace/pre.h"
00020 
00021 // Globally visible macros, type decls, and extern var decls for
00022 // Service Configurator utility.
00023 
00024 #include "ace/Obstack.h"
00025 
00026 #if !defined (ACE_LACKS_PRAGMA_ONCE)
00027 # pragma once
00028 #endif /* ACE_LACKS_PRAGMA_ONCE */
00029 
00030 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
00031 
00032 // Forward declarations.
00033 struct ace_yy_buffer_state;
00034 class ACE_Service_Gestalt;
00035 
00036 extern void ace_yy_delete_buffer (ace_yy_buffer_state *buffer);
00037 
00038 /**
00039  * @class ACE_Svc_Conf_Param
00040  *
00041  * @brief An instance of this object will be passed down to the
00042  *        yyparse() and yylex() functions.
00043  *
00044  * This is intended for internal use within ACE service configuration
00045  * framework only.
00046  *
00047  * This class retains the state for a given parse/scan.  It primarily
00048  * makes it possible to hold the static object lock in the scanner
00049  * for as short a period of time as possible.  The resulting finer
00050  * grained locking prevents deadlocks from occuring when scanning a
00051  * `svc.conf' file and activating an ACE_Task, for example, as a
00052  * result of processing the directives in that file.
00053  */
00054 class ACE_Svc_Conf_Param
00055 {
00056 public:
00057 
00058   enum SVC_CONF_PARAM_TYPE
00059     {
00060       /// The lexer will scan a file containing one or more directives.
00061       SVC_CONF_FILE,
00062 
00063       /// The lexer will scan a string containing a directive.
00064       SVC_CONF_DIRECTIVE
00065     };
00066 
00067   /// Constructor
00068   ACE_Svc_Conf_Param (ACE_Service_Gestalt* config, FILE *file)
00069     : type (SVC_CONF_FILE),
00070       yyerrno (0),
00071       yylineno (1),
00072       buffer (0),
00073       obstack (),
00074       config (config)
00075   {
00076     source.file = file;
00077   }
00078 
00079   /// Constructor
00080   ACE_Svc_Conf_Param (ACE_Service_Gestalt* config, const ACE_TCHAR *directive)
00081     : type (SVC_CONF_DIRECTIVE),
00082       yyerrno (0),
00083       yylineno (1),
00084       buffer (0),
00085       obstack (),
00086       config (config)
00087   {
00088     source.directive = directive;
00089   }
00090 
00091   ~ACE_Svc_Conf_Param (void)
00092   {
00093     ace_yy_delete_buffer (this->buffer);
00094   }
00095 
00096 public:
00097 
00098   union
00099   {
00100     /// FILE stream from which directives will be scanned and parsed.
00101     FILE *file;
00102 
00103     /// String containing directive that will be scanned and parsed.
00104     const ACE_TCHAR *directive;
00105 
00106   } source;
00107 
00108   /// Discriminant use to determine which union member to use.
00109   SVC_CONF_PARAM_TYPE type;
00110 
00111   /// Keeps track of the number of errors encountered so far.
00112   int yyerrno;
00113 
00114   /// Keeps track of the current line number for error-handling routine.
00115   int yylineno;
00116 
00117   /// Lexer buffer that corresponds to the current Service
00118   /// Configurator file/direct scan.
00119   ace_yy_buffer_state *buffer;
00120 
00121   /// Obstack used for efficient memory allocation when
00122   /// parsing/scanning a service configurator directive.
00123   ACE_Obstack_T<ACE_TCHAR> obstack;
00124 
00125   /// A reference to the configuration
00126   ACE_Service_Gestalt *config;
00127 };
00128 
00129 
00130 // Parameter that is passed down to the yyparse() function, and
00131 // eventually to yylex().
00132 #define YYPARSE_PARAM ace_svc_conf_parameter
00133 
00134 #define YYLEX_PARAM YYPARSE_PARAM
00135 
00136 #define ACE_SVC_CONF_PARAM (static_cast<ACE_Svc_Conf_Param *> (YYLEX_PARAM))
00137 
00138 ACE_END_VERSIONED_NAMESPACE_DECL
00139 
00140 #include /**/ "ace/post.h"
00141 
00142 #endif /* ACE_SVC_CONF_PARAM_H */

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