4 // Fraunhofer Institute for Open Communication Systems (FOKUS)
5 // Competence Center NETwork research (NET), St. Augustin, GERMANY
6 // Stefan Bund <g0dil@berlios.de>
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.
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.
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.
24 \brief Config public header */
26 #ifndef HH_SENF_Scheduler_Console_Config_
27 #define HH_SENF_Scheduler_Console_Config_ 1
30 #include <boost/utility.hpp>
32 #include "Executor.hh"
34 //#include "Config.mpp"
36 ///////////////////////////////hh.p////////////////////////////////////////
41 /** \brief Combine multiple configuration sources
43 A ConfigBundle combines several sources and parses them together, in the order they were
44 added. Parse restrictions are applied uniformly to all sources.
46 // Add three configuration sources: A system configuration file, a user configuration file
47 // and command line options
48 senf::console::ConfigBundle conf;
49 conf.add( senf::console::FileConfig("/etc/some.conf") );
50 conf.add( senf::console::FileConfig("local.conf") );
51 conf.add( senf::console::OptionsConfig(senf::Daemon::instance().argc(),
52 senf::Daemon::instance().argv()) );
57 This bundle may also be passed to other code which may use restricted parsing to parse
58 partial information from all configuration sources.
60 \ingroup console_access
65 ///////////////////////////////////////////////////////////////////////////
66 ///\name Structors and default members
70 ConfigBundle(DirectoryNode & root); ///< Set custom root node
73 ///////////////////////////////////////////////////////////////////////////
75 template <class Source>
76 Source & add(boost::intrusive_ptr<Source> source);
77 ///< Add configuration source
79 void parse(); ///< Parse config file
80 /**< All nodes already parsed are skipped */
81 void parse(DirectoryNode & restrict); ///< Parse config file under \a restrict
82 /**< Only nodes which are children of \a restrict are
85 bool complete() const; ///< \c true, if all nodes have been parsed
86 bool parsed(GenericNode & node) const; ///< \c true. if \a node has been parsed
87 void reset(); ///< Reset node parse info state
88 /**< After a call to reset(), all information about already
89 parsed nodes is cleared. Calling parse() will parse the
90 complete config file again. */
97 typedef std::vector<detail::ConfigSource::ptr> Sources;
100 detail::RestrictedExecutor executor_;
104 // hrmpf ... Can't place this into Config.ih ...
106 /** \brief Internal: Provide ConfigBundle facade for a single-source config.
108 The BundleMixin is used to define supplementary configuration objects for one specific
109 configuration source. A BundleMixin is \e not a ConfigBundle since it has no public \c add()
116 BundleMixin(DirectoryNode & root);
118 void parse(); ///< Parse config file
119 /**< All nodes already parsed are skipped */
120 void parse(DirectoryNode & restrict); ///< Parse config file under \a restrict
121 /**< Only nodes which are children of \a restrict are
124 bool complete() const; ///< \c true, if all nodes have been parsed
125 bool parsed(GenericNode & node) const; ///< \c true. if \a node has been parsed
126 void reset(); ///< Reset node parse info state
127 /**< After a call to reset(), all information about already
128 parsed nodes is cleared. Calling parse() will parse the
129 complete config file again. */
132 template <class Source>
133 Source & add(boost::intrusive_ptr<Source> source);
136 ConfigBundle bundle_;
141 ///////////////////////////////hh.e////////////////////////////////////////
142 #include "Config.cci"
143 //#include "Config.ct"
144 #include "Config.cti"
151 // comment-column: 40
152 // c-file-style: "senf"
153 // indent-tabs-mode: nil
154 // ispell-local-dictionary: "american"
155 // compile-command: "scons -u test"