aboutsummaryrefslogtreecommitdiff
path: root/src/FbTk/LogicCommands.hh
diff options
context:
space:
mode:
authormarkt <markt>2007-11-22 04:07:57 (GMT)
committermarkt <markt>2007-11-22 04:07:57 (GMT)
commit675bc5d66aa08311e99cb00cf836d16a910a73df (patch)
tree9118f77bcc38631f944cdf4a07d2173011a29a9b /src/FbTk/LogicCommands.hh
parent08ebff4b319f51b4263cded0bb9c04103bcd9c3a (diff)
downloadfluxbox-675bc5d66aa08311e99cb00cf836d16a910a73df.zip
fluxbox-675bc5d66aa08311e99cb00cf836d16a910a73df.tar.bz2
added conditional statements to keys file
Diffstat (limited to 'src/FbTk/LogicCommands.hh')
-rw-r--r--src/FbTk/LogicCommands.hh97
1 files changed, 97 insertions, 0 deletions
diff --git a/src/FbTk/LogicCommands.hh b/src/FbTk/LogicCommands.hh
new file mode 100644
index 0000000..a94dad8
--- /dev/null
+++ b/src/FbTk/LogicCommands.hh
@@ -0,0 +1,97 @@
1// LogicCommands.hh for FbTk
2// Copyright (c) 2007 Fluxbox Team (fluxgen at fluxbox dot org)
3//
4// Permission is hereby granted, free of charge, to any person obtaining a
5// copy of this software and associated documentation files (the "Software"),
6// to deal in the Software without restriction, including without limitation
7// the rights to use, copy, modify, merge, publish, distribute, sublicense,
8// and/or sell copies of the Software, and to permit persons to whom the
9// Software is furnished to do so, subject to the following conditions:
10//
11// The above copyright notice and this permission notice shall be included in
12// all copies or substantial portions of the Software.
13//
14// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
19// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
20// DEALINGS IN THE SOFTWARE.
21
22// $Id: $
23
24#ifndef FBTK_LOGICCOMMANDS_HH
25#define FBTK_LOGICCOMMANDS_HH
26
27#include "Command.hh"
28#include "RefCount.hh"
29
30#include <vector>
31
32namespace FbTk {
33
34/// executes a boolcommand and uses the result to decide what to do
35class IfCommand: public Command {
36public:
37 IfCommand(RefCount<BoolCommand> &cond,
38 RefCount<Command> &t, RefCount<Command> &f):
39 m_cond(cond), m_t(t), m_f(f) { }
40 void execute() {
41 if (m_cond->bool_execute())
42 m_t->execute();
43 else
44 m_f->execute();
45 }
46
47private:
48 RefCount<BoolCommand> m_cond;
49 RefCount<Command> m_t, m_f;
50};
51
52/// executes a list of boolcommands until one is true
53class OrCommand: public BoolCommand {
54public:
55 void add(RefCount<BoolCommand> &com);
56 size_t size() const;
57 bool bool_execute();
58
59private:
60 std::vector<RefCount<BoolCommand> > m_commandlist;
61};
62
63/// executes a list of boolcommands until one is false
64class AndCommand: public BoolCommand {
65public:
66 void add(RefCount<BoolCommand> &com);
67 size_t size() const;
68 bool bool_execute();
69
70private:
71 std::vector<RefCount<BoolCommand> > m_commandlist;
72};
73
74/// executes a list of boolcommands, returning the parity
75class XorCommand: public BoolCommand {
76public:
77 void add(RefCount<BoolCommand> &com);
78 size_t size() const;
79 bool bool_execute();
80
81private:
82 std::vector<RefCount<BoolCommand> > m_commandlist;
83};
84
85/// executes a boolcommand and returns the negation
86class NotCommand: public BoolCommand {
87public:
88 NotCommand(RefCount<BoolCommand> &com): m_command(com) { }
89 bool bool_execute() { return !m_command->bool_execute(); }
90
91private:
92 RefCount<BoolCommand> m_command;
93};
94
95} // end namespace FbTk
96
97#endif // FBTK_LOGICCOMMANDS_HH