Svc_Conf_Param.h

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

Generated on Thu Nov 9 09:42:06 2006 for ACE by doxygen 1.3.6