Document return values
[ACE_TAO.git] / ACE / ace / Svc_Conf_Param.h
blob18c285a929045269c212a1f4617679f0d0f4c1ad
1 // -*- C++ -*-
3 //=============================================================================
4 /**
5 * @file Svc_Conf_Param.h
7 * @author Iliyan Jeliazkov <iliyan@ociweb.com>
8 * @author Based on code originally found in Svc_Conf.h by Doug
9 Schmidt and Ossama Othman.
11 //=============================================================================
14 #ifndef ACE_SVC_CONF_PARAM_H
15 #define ACE_SVC_CONF_PARAM_H
17 #include /**/ "ace/pre.h"
19 // Globally visible macros, type decls, and extern var decls for
20 // Service Configurator utility.
22 #include "ace/Obstack.h"
24 #if !defined (ACE_LACKS_PRAGMA_ONCE)
25 # pragma once
26 #endif /* ACE_LACKS_PRAGMA_ONCE */
28 ACE_BEGIN_VERSIONED_NAMESPACE_DECL
30 // Forward declarations.
31 struct ace_yy_buffer_state;
32 class ACE_Service_Gestalt;
34 extern void ace_yy_delete_buffer (ace_yy_buffer_state *buffer);
36 /**
37 * @class ACE_Svc_Conf_Param
39 * @brief An instance of this object will be passed down to the
40 * yyparse() and yylex() functions.
42 * This is intended for internal use within ACE service configuration
43 * framework only.
45 * This class retains the state for a given parse/scan. It primarily
46 * makes it possible to hold the static object lock in the scanner
47 * for as short a period of time as possible. The resulting finer
48 * grained locking prevents deadlocks from occurring when scanning a
49 * `svc.conf' file and activating an ACE_Task, for example, as a
50 * result of processing the directives in that file.
52 class ACE_Svc_Conf_Param
54 public:
55 enum SVC_CONF_PARAM_TYPE
57 /// The lexer will scan a file containing one or more directives.
58 SVC_CONF_FILE,
60 /// The lexer will scan a string containing a directive.
61 SVC_CONF_DIRECTIVE
64 /// Constructor
65 ACE_Svc_Conf_Param (ACE_Service_Gestalt* config, FILE *file)
66 : type (SVC_CONF_FILE),
67 yyerrno (0),
68 yylineno (1),
69 buffer (0),
70 obstack (),
71 config (config)
73 source.file = file;
76 /// Constructor
77 ACE_Svc_Conf_Param (ACE_Service_Gestalt* config, const ACE_TCHAR *directive)
78 : type (SVC_CONF_DIRECTIVE),
79 yyerrno (0),
80 yylineno (1),
81 buffer (0),
82 obstack (),
83 config (config)
85 source.directive = directive;
88 ~ACE_Svc_Conf_Param ()
90 ace_yy_delete_buffer (this->buffer);
93 public:
94 union
96 /// FILE stream from which directives will be scanned and parsed.
97 FILE *file;
99 /// String containing directive that will be scanned and parsed.
100 const ACE_TCHAR *directive;
101 } source;
103 /// Discriminant use to determine which union member to use.
104 SVC_CONF_PARAM_TYPE type;
106 /// Keeps track of the number of errors encountered so far.
107 int yyerrno;
109 /// Keeps track of the current line number for error-handling routine.
110 int yylineno;
112 /// Lexer buffer that corresponds to the current Service
113 /// Configurator file/direct scan.
114 ace_yy_buffer_state *buffer;
116 /// Obstack used for efficient memory allocation when
117 /// parsing/scanning a service configurator directive.
118 ACE_Obstack_T<ACE_TCHAR> obstack;
120 /// A reference to the configuration
121 ACE_Service_Gestalt *config;
125 // Parameter that is passed down to the yyparse() function, and
126 // eventually to yylex().
127 #define YYPARSE_PARAM ace_svc_conf_parameter
129 #define YYLEX_PARAM YYPARSE_PARAM
131 #define ACE_SVC_CONF_PARAM (static_cast<ACE_Svc_Conf_Param *> (YYLEX_PARAM))
133 ACE_END_VERSIONED_NAMESPACE_DECL
135 #include /**/ "ace/post.h"
137 #endif /* ACE_SVC_CONF_PARAM_H */