news download themes documentation links










CommandParser.hh

00001 // CommandParser.hh for Fluxbox - an X11 Window manager
00002 // Copyright (c) 2003 Henrik Kinnunen (fluxgen{<a*t>}users.sourceforge.net)
00003 //                and Simon Bowden (rathnor at users.sourceforge.net)
00004 //
00005 // Permission is hereby granted, free of charge, to any person obtaining a
00006 // copy of this software and associated documentation files (the "Software"),
00007 // to deal in the Software without restriction, including without limitation
00008 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
00009 // and/or sell copies of the Software, and to permit persons to whom the
00010 // Software is furnished to do so, subject to the following conditions:
00011 //
00012 // The above copyright notice and this permission notice shall be included in
00013 // all copies or substantial portions of the Software.
00014 //
00015 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
00016 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00017 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
00018 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
00019 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
00020 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
00021 // DEALINGS IN THE SOFTWARE.
00022 
00023 // $Id: CommandParser.hh,v 1.3 2004/01/02 13:43:58 fluxgen Exp $
00024 
00025 #ifndef COMMANDPARSER_HH
00026 #define COMMANDPARSER_HH
00027 
00028 #include <string>
00029 #include <map>
00030 
00031 #include "RefCount.hh"
00032 
00033 namespace FbTk {
00034 class Command;
00035 };
00036 
00039 class CommandFactory {
00040 public:
00041     CommandFactory();
00042     virtual ~CommandFactory();
00043     virtual FbTk::Command *stringToCommand(const std::string &command, 
00044                                            const std::string &arguments) = 0;
00045 protected:
00046     void addCommand(const std::string &value);
00047 };
00048 
00050 class CommandParser {
00051 public:
00052     typedef std::map<std::string, CommandFactory *> CommandFactoryMap;
00053 
00055     FbTk::Command *parseLine(const std::string &line);
00056 
00058     static CommandParser &instance();
00060     const CommandFactoryMap &factorys() const { return m_commandfactorys; }
00061 private:
00062     // so CommandFactory can associate it's commands
00063     friend class CommandFactory;
00065     void associateCommand(const std::string &name, CommandFactory &factory);
00067     void removeAssociation(CommandFactory &factory);
00068 
00070     FbTk::Command *toCommand(const std::string &command,
00071                              const std::string &arguments);
00072     
00073     CommandFactoryMap m_commandfactorys; 
00074     
00075 };
00076 
00077 #endif // COMMANDPARSER_HH

Fluxbox CVS-Jan-2003




      



Got comments about the page? Send them to webmaster.
If you have general Fluxbox related questions ask them on our irc channel or mailing lists.

Show Source








Designed by aLEczapKA