aboutsummaryrefslogtreecommitdiff
path: root/src/CommandParser.hh
diff options
context:
space:
mode:
authormarkt <markt>2007-12-13 05:48:00 (GMT)
committermarkt <markt>2007-12-13 05:48:00 (GMT)
commit8b7464046cea5e521ac46811591b0fce0c45aca1 (patch)
tree09df752f426a249ae15375a626a98436c8727593 /src/CommandParser.hh
parentdaca07edafc2e75eb9ee04d35fe80759308a8583 (diff)
downloadfluxbox-8b7464046cea5e521ac46811591b0fce0c45aca1.zip
fluxbox-8b7464046cea5e521ac46811591b0fce0c45aca1.tar.bz2
added FbTk::CommandRegistry, decentralized command parsing, and made them auto-register
Diffstat (limited to 'src/CommandParser.hh')
-rw-r--r--src/CommandParser.hh81
1 files changed, 0 insertions, 81 deletions
diff --git a/src/CommandParser.hh b/src/CommandParser.hh
deleted file mode 100644
index 1bc3094..0000000
--- a/src/CommandParser.hh
+++ /dev/null
@@ -1,81 +0,0 @@
1// CommandParser.hh for Fluxbox - an X11 Window manager
2// Copyright (c) 2003 - 2006 Henrik Kinnunen (fluxgen at fluxbox dot org)
3// and Simon Bowden (rathnor at users.sourceforge.net)
4//
5// Permission is hereby granted, free of charge, to any person obtaining a
6// copy of this software and associated documentation files (the "Software"),
7// to deal in the Software without restriction, including without limitation
8// the rights to use, copy, modify, merge, publish, distribute, sublicense,
9// and/or sell copies of the Software, and to permit persons to whom the
10// Software is furnished to do so, subject to the following conditions:
11//
12// The above copyright notice and this permission notice shall be included in
13// all copies or substantial portions of the Software.
14//
15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21// DEALINGS IN THE SOFTWARE.
22
23// $Id$
24
25#ifndef COMMANDPARSER_HH
26#define COMMANDPARSER_HH
27
28#include <string>
29#include <map>
30
31#include "RefCount.hh"
32
33namespace FbTk {
34class Command;
35};
36
37/// Creates commands from command and argument.
38/// Used for modules to add new commands in compile/run time
39class CommandFactory {
40public:
41 CommandFactory();
42 virtual ~CommandFactory();
43 virtual FbTk::Command *stringToCommand(const std::string &command,
44 const std::string &arguments,
45 bool trusted) = 0;
46protected:
47 void addCommand(const std::string &value);
48};
49
50/// Parses text into a command
51class CommandParser {
52public:
53 typedef std::map<std::string, CommandFactory *> CommandFactoryMap;
54
55 /// @return parses and returns a command matching the line
56 FbTk::Command *parseLine(const std::string &line, bool trusted = true);
57
58 CommandParser();
59
60 /// @return instance of command parser
61 static CommandParser &instance();
62 /// @return map of factorys
63 const CommandFactoryMap &factorys() const { return m_commandfactorys; }
64private:
65 // so CommandFactory can associate it's commands
66 friend class CommandFactory;
67 /// associate a command with a factory
68 void associateCommand(const std::string &name, CommandFactory &factory);
69 /// remove all associations with the factory
70 void removeAssociation(CommandFactory &factory);
71
72 /// search for a command in our command factory map
73 FbTk::Command *toCommand(const std::string &command,
74 const std::string &arguments, bool trusted);
75
76 CommandFactoryMap m_commandfactorys; ///< a string to factory map
77
78 static CommandParser *s_singleton;
79};
80
81#endif // COMMANDPARSER_HH