Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Svc_Conf.h

Go to the documentation of this file.
00001 /* -*- C++ -*- */
00002 
00003 //=============================================================================
00004 /**
00005  *  @file    Svc_Conf.h
00006  *
00007  *  $Id: Svc_Conf.h,v 1.1.1.4 2003/02/21 18:36:32 chad Exp $
00008  *
00009  *  @author Doug Schmidt
00010  */
00011 //=============================================================================
00012 
00013 
00014 #ifndef ACE_SVC_CONF_H
00015 #define ACE_SVC_CONF_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 #include "ace/Service_Config.h"
00029 #include "ace/Parse_Node.h"
00030 
00031 #if (ACE_USES_CLASSIC_SVC_CONF == 1)
00032 
00033 // Forward declarations.
00034 struct ace_yy_buffer_state;
00035 
00036 // The following yylex() declarations require support for reentrant
00037 // parser generation (e.g. from GNU Bison).
00038 #if defined (DEBUGGING)
00039 #if defined (ACE_YY_DECL)
00040 #undef ACE_YY_DECL
00041 #endif /* ACE_YY_DECL */
00042 #define ACE_YY_DECL extern "C" char *ace_yylex (ACE_YYSTYPE *ace_yylval, void *ACE_YYLEX_PARAM)
00043 #else
00044 #define ACE_YY_DECL extern "C" int ace_yylex (ACE_YYSTYPE *ace_yylval, void *ACE_YYLEX_PARAM)
00045 #endif /* DEBUGGING */
00046 
00047 extern void ace_yy_delete_buffer (ace_yy_buffer_state *buffer);
00048 
00049 /**
00050  * @class ACE_Svc_Conf_Param
00051  *
00052  * @brief An instance of this object will be passed down to the
00053  *        yyparse() and yylex() functions.
00054  *
00055  * This class retains the state for a given parse/scan.  It primarily
00056  * makes it possible to hold the static object lock in the scanner
00057  * for as short a period of time as possible.  The resulting finer
00058  * grained locking prevents deadlocks from occuring when scanning a
00059  * `svc.conf' file and activating an ACE_Task, for example, as a
00060  * result of processing the directives in that file.
00061  */
00062 class ACE_Svc_Conf_Param
00063 {
00064 public:
00065 
00066   enum SVC_CONF_PARAM_TYPE
00067     {
00068       /// The lexer will scan a file containing one or more directives.
00069       SVC_CONF_FILE,
00070 
00071       /// The lexer will scan a string containing a directive.
00072       SVC_CONF_DIRECTIVE
00073     };
00074 
00075   /// Constructor
00076   ACE_Svc_Conf_Param (FILE *file)
00077     : type (SVC_CONF_FILE),
00078       yyerrno (0),
00079       yylineno (1),
00080       buffer (0),
00081       obstack ()
00082   {
00083     source.file = file;
00084   }
00085 
00086   /// Constructor
00087   ACE_Svc_Conf_Param (const ACE_TCHAR *directive)
00088     : type (SVC_CONF_DIRECTIVE),
00089       yyerrno (0),
00090       yylineno (1),
00091       buffer (0),
00092       obstack ()
00093   {
00094     source.directive = directive;
00095   }
00096 
00097   ~ACE_Svc_Conf_Param (void)
00098   {
00099     ace_yy_delete_buffer (this->buffer);
00100   }
00101 
00102 public:
00103 
00104   union
00105   {
00106     /// FILE stream from which directives will be scanned and parsed.
00107     FILE *file;
00108 
00109     /// String containing directive that will be scanned and parsed.
00110     const ACE_TCHAR *directive;
00111 
00112   } source;
00113 
00114   /// Discriminant use to determine which union member to use.
00115   SVC_CONF_PARAM_TYPE type;
00116 
00117   /// Keeps track of the number of errors encountered so far.
00118   int yyerrno;
00119 
00120   /// Keeps track of the current line number for error-handling routine.
00121   int yylineno;
00122 
00123   /// Lexer buffer that corresponds to the current Service
00124   /// Configurator file/direct scan.
00125   ace_yy_buffer_state *buffer;
00126 
00127   /// Obstack used for efficient memory allocation when
00128   /// parsing/scanning a service configurator directive.
00129   ACE_Obstack_T<ACE_TCHAR> obstack;
00130 
00131 };
00132 
00133 // Parameter that is passed down to the yyparse() function, and
00134 // eventually to yylex().
00135 #define ACE_YYPARSE_PARAM ace_svc_conf_parameter
00136 #define ACE_YYLEX_PARAM ACE_YYPARSE_PARAM
00137 
00138 #define ACE_SVC_CONF_PARAM (ACE_static_cast (ACE_Svc_Conf_Param *, ACE_YYLEX_PARAM))
00139 
00140 // The following definition for the ACE_YYSTYPE must occur before
00141 // ACE_YY_DECL is declared since ACE_YY_DECL expands to function
00142 // prototypes that use ACE_YYSTYPE.
00143 typedef union
00144 {
00145   int type_;
00146   ACE_Location_Node *location_node_;
00147   ACE_Parse_Node *parse_node_;
00148   ACE_Static_Node *static_node_;
00149   ACE_Service_Type *svc_record_;
00150   ACE_TCHAR *ident_;
00151 } ACE_YYSTYPE;
00152 
00153 // Forward declaration
00154 struct ace_yy_buffer_state;
00155 
00156 /// Create and push a new lexer buffer on to the buffer stack for use
00157 /// when scanning the given file.
00158 void ace_yy_push_buffer (FILE *file,
00159                          ace_yy_buffer_state *&buffer);
00160 
00161 /// Create and push a new lexer buffer on to the buffer stack for use
00162 /// when scanning the given directive.
00163 void ace_yy_push_buffer (const ACE_TCHAR *directive,
00164                          ace_yy_buffer_state *&buffer);
00165 
00166 /// Pop the current lexer buffer off of the buffer stack and
00167 /// deallocate it.
00168 void ace_yy_pop_buffer (ace_yy_buffer_state *buf);
00169 
00170 /// Performs the parsing
00171 #ifdef ACE_YYPARSE_PARAM
00172 int ace_yyparse (void *);
00173 #else
00174 int ace_yyparse (void);
00175 #endif
00176 
00177 /// Performs the lexical analysis
00178 ACE_YY_DECL;
00179 
00180 /// Name of input stream
00181 extern FILE *ace_yyin;
00182 
00183 /// Error handling routine required by YACC or BISON
00184 void ace_yyerror (int yyerrno, int yylineno, const ACE_TCHAR *);
00185 
00186 /// Holds the lexeme for the current token
00187 extern ACE_TCHAR *ace_yytext;
00188 
00189 /// Holds the length of the lexeme for the current token
00190 extern int ace_yyleng;
00191 
00192 #endif /* ACE_USES_CLASSIC_SVC_CONF == 1 */
00193 
00194 /// Factory that creates a new ACE_Service_Type_Impl.
00195 extern ACE_Service_Type_Impl *
00196 ace_create_service_type (const ACE_TCHAR *,
00197                          int,
00198                          void *,
00199                          unsigned int,
00200                          ACE_Service_Object_Exterminator = 0);
00201 
00202 
00203 #include "ace/post.h"
00204 
00205 #endif /* ACE_SVC_CONF_H */

Generated on Mon Jun 16 11:21:33 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002