Search:

SENF Extensible Network Framework

  • Home
  • Download
  • Wiki
  • BerliOS
  • ChangeLog
  • Browse SVN
  • Bug Tracker
  • Overview
  • Examples
  • HowTos
  • Glossary
  • PPI
  • Packets
  • Scheduler
  • Socket
  • Utils
  • Console
  • Daemon
  • Logger
  • Termlib
  • Main Page
  • Related Pages
  • Modules
  • Namespaces
  • Classes
  • Files
  • File List
  • File Members

Config.ih

Go to the documentation of this file.
00001 // $Id: Config.ih 1742 2010-11-04 14:51:56Z g0dil $
00002 //
00003 // Copyright (C) 2008
00004 // Fraunhofer (FOKUS)
00005 // Competence Center NETwork research (NET), St. Augustin, GERMANY
00006 //     Stefan Bund <g0dil@berlios.de>
00007 //
00008 // This program is free software; you can redistribute it and/or modify
00009 // it under the terms of the GNU General Public License as published by
00010 // the Free Software Foundation; either version 2 of the License, or
00011 // (at your option) any later version.
00012 //
00013 // This program is distributed in the hope that it will be useful,
00014 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00015 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016 // GNU General Public License for more details.
00017 //
00018 // You should have received a copy of the GNU General Public License
00019 // along with this program; if not, write to the
00020 // Free Software Foundation, Inc.,
00021 // 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00022 
00026 #ifndef IH_SENF_Scheduler_Console_Config_
00027 #define IH_SENF_Scheduler_Console_Config_ 1
00028 
00029 // Custom includes
00030 #include <boost/utility.hpp>
00031 #include <boost/intrusive_ptr.hpp>
00032 #include "Executor.hh"
00033 #include <senf/Utils/intrusive_refcount.hh>
00034 #include <senf/Utils/DiscardStream.hh>
00035 
00036 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00037 
00038 namespace senf {
00039 namespace console {
00040 namespace detail {
00041 
00047     class RestrictedExecutor
00048         : boost::noncopyable
00049     {
00050     public:
00051         typedef void result_type;
00052 
00053         //-/////////////////////////////////////////////////////////////////////////////////////////
00054         //\/name Structors and default members
00055         //\{
00056 
00057         RestrictedExecutor(DirectoryNode & root = senf::console::root());
00058 
00059         //\}
00060         //-/////////////////////////////////////////////////////////////////////////////////////////
00061 
00062         void execute(std::ostream & output, ParseCommandInfo const & command);
00064 
00067         void operator()(std::ostream & output, ParseCommandInfo const & command);
00069 
00072         GenericNode & getNode(ParseCommandInfo const & command);
00073 
00074         bool complete() const;          
00075         bool parsed(GenericNode & node) const; 
00076         void reset();                   
00077 
00081         DirectoryNode & root() const;
00082         void chroot(DirectoryNode & node);
00083 
00084         std::ostream & stream();
00085 
00086         class RestrictGuard;
00087 
00088     protected:
00089 
00090     private:
00091         void policyCallback(DirectoryNode & dir, std::string const & item);
00092         void insertParsedNode(DirectoryNode & node);
00093 
00094         typedef std::vector<DirectoryNode::weak_ptr> ParsedNodes;
00095 
00096         Executor executor_;
00097         ParsedNodes parsedNodes_;
00098         DirectoryNode::ptr restrict_;
00099         DiscardStream stream_;
00100 
00101         friend class RestrictGuard;
00102     };
00103 
00109     class RestrictedExecutor::RestrictGuard
00110     {
00111     public:
00112         //-/////////////////////////////////////////////////////////////////////////////////////////
00113         //\/name Structors and default members
00114         //\{
00115 
00116         explicit RestrictGuard(RestrictedExecutor & executor);
00117         RestrictGuard(RestrictedExecutor & executor, DirectoryNode & restrict);
00118         ~RestrictGuard();
00119 
00120         //\}
00121         //-/////////////////////////////////////////////////////////////////////////////////////////
00122 
00123     protected:
00124 
00125     private:
00126         RestrictedExecutor & executor_;
00127 
00128     };
00129 
00135     class ConfigSource
00136         : public senf::intrusive_refcount
00137     {
00138     public:
00139         typedef boost::intrusive_ptr<ConfigSource> ptr;
00140         virtual ~ConfigSource();
00141 
00142         void parse(RestrictedExecutor & executor);
00143 
00144     protected:
00145 
00146     private:
00147         virtual void v_parse(RestrictedExecutor & executor) = 0;
00148     };
00149 
00150 }}}
00151 
00152 //-/////////////////////////////////////////////////////////////////////////////////////////////////
00153 #endif
00154 
00155 
00156 // Local Variables:
00157 // mode: c++
00158 // fill-column: 100
00159 // comment-column: 40
00160 // c-file-style: "senf"
00161 // indent-tabs-mode: nil
00162 // ispell-local-dictionary: "american"
00163 // compile-command: "scons -u test"
00164 // End:

Contact: senf-dev@lists.berlios.de | © 2006-2010 Fraunhofer Institute for Open Communication Systems, Network Research