Fix documentation build under maverick (doxygen 1.7.1)
[senf.git] / senf / Utils / Console / Config.ih
1 // $Id$
2 //
3 // Copyright (C) 2008
4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 //     Stefan Bund <g0dil@berlios.de>
7 //
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the
20 // Free Software Foundation, Inc.,
21 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
22
23 /** \file
24     \brief Config internal header */
25
26 #ifndef IH_SENF_Scheduler_Console_Config_
27 #define IH_SENF_Scheduler_Console_Config_ 1
28
29 // Custom includes
30 #include <boost/utility.hpp>
31 #include <boost/intrusive_ptr.hpp>
32 #include "Executor.hh"
33 #include <senf/Utils/intrusive_refcount.hh>
34 #include <senf/Utils/DiscardStream.hh>
35
36 //-/////////////////////////////////////////////////////////////////////////////////////////////////
37
38 namespace senf {
39 namespace console {
40 namespace detail {
41
42     /** \brief Internal: Executor wrapper implementing restricted execution
43
44         A RestrictedExecutor will only process commands which a re children of a given node. It does
45         \e not follow any links.
46      */
47     class RestrictedExecutor
48         : boost::noncopyable
49     {
50     public:
51         typedef void result_type;
52
53         //-/////////////////////////////////////////////////////////////////////////////////////////
54         //\/name Structors and default members
55         //\{
56
57         RestrictedExecutor(DirectoryNode & root = senf::console::root());
58
59         //\}
60         //-/////////////////////////////////////////////////////////////////////////////////////////
61
62         void execute(std::ostream & output, ParseCommandInfo const & command);
63                                         ///< Execute command
64                                         /**< Output will be written to \a output.
65                                              Same as operator()(). */
66
67         void operator()(std::ostream & output, ParseCommandInfo const & command);
68                                         ///< Execute command
69                                         /**< Output will be written to \a output.
70                                              Same as execute(). */
71
72         GenericNode & getNode(ParseCommandInfo const & command);
73
74         bool complete() const;          ///< \c true, if all nodes have been parsed
75         bool parsed(GenericNode & node) const; ///< \c true. if \a node has been parsed
76         void reset();                   ///< Reset node parse info state
77                                         /**< After a call to reset(), all information about already
78                                              parsed nodes is cleared. Calling parse() will parse the
79                                              complete config file again. */
80
81         DirectoryNode & root() const;
82         void chroot(DirectoryNode & node);
83
84         std::ostream & stream();
85
86         class RestrictGuard;
87
88     protected:
89
90     private:
91         void policyCallback(DirectoryNode & dir, std::string const & item);
92         void insertParsedNode(DirectoryNode & node);
93
94         typedef std::vector<DirectoryNode::weak_ptr> ParsedNodes;
95
96         Executor executor_;
97         ParsedNodes parsedNodes_;
98         DirectoryNode::ptr restrict_;
99         DiscardStream stream_;
100
101         friend class RestrictGuard;
102     };
103
104     /** \brief Internal: Set restricted node of a RestrictedExecutor
105
106         A RestrictGuard will set the node to which to restrict. It will automatically reset the node
107         in it's destructor.
108      */
109     class RestrictedExecutor::RestrictGuard
110     {
111     public:
112         //-/////////////////////////////////////////////////////////////////////////////////////////
113         //\/name Structors and default members
114         //\{
115
116         explicit RestrictGuard(RestrictedExecutor & executor);
117         RestrictGuard(RestrictedExecutor & executor, DirectoryNode & restrict);
118         ~RestrictGuard();
119
120         //\}
121         //-/////////////////////////////////////////////////////////////////////////////////////////
122
123     protected:
124
125     private:
126         RestrictedExecutor & executor_;
127
128     };
129
130     /** \brief Internal: ConfigSource base class
131
132         All configuration sources derive from ConfigSource. A ConigSource somehow reads
133         configuration commands and passes them to a RestrictedExecutor.
134       */
135     class ConfigSource
136         : public senf::intrusive_refcount
137     {
138     public:
139         typedef boost::intrusive_ptr<ConfigSource> ptr;
140         virtual ~ConfigSource();
141
142         void parse(RestrictedExecutor & executor);
143
144     protected:
145
146     private:
147         virtual void v_parse(RestrictedExecutor & executor) = 0;
148     };
149
150 }}}
151
152 //-/////////////////////////////////////////////////////////////////////////////////////////////////
153 #endif
154
155 \f
156 // Local Variables:
157 // mode: c++
158 // fill-column: 100
159 // comment-column: 40
160 // c-file-style: "senf"
161 // indent-tabs-mode: nil
162 // ispell-local-dictionary: "american"
163 // compile-command: "scons -u test"
164 // End: