diff options
author | Mark Tiefenbruck <mark@fluxbox.org> | 2008-01-11 07:41:22 (GMT) |
---|---|---|
committer | Mark Tiefenbruck <mark@fluxbox.org> | 2008-01-11 07:41:22 (GMT) |
commit | 9f2f65a698c4cc71373a7fe9d73a0889e0d3487b (patch) | |
tree | 4ad67db771d73ea3c48f80a1244037fc9754edd2 /src/FbTk/LogicCommands.hh | |
parent | 1f01d84c080d607a91eb417efcaf5e500b5f1d7e (diff) | |
download | fluxbox-9f2f65a698c4cc71373a7fe9d73a0889e0d3487b.zip fluxbox-9f2f65a698c4cc71373a7fe9d73a0889e0d3487b.tar.bz2 |
make FbTk::Command a template class, split parsing information out of ObjectRegistry
Diffstat (limited to 'src/FbTk/LogicCommands.hh')
-rw-r--r-- | src/FbTk/LogicCommands.hh | 56 |
1 files changed, 28 insertions, 28 deletions
diff --git a/src/FbTk/LogicCommands.hh b/src/FbTk/LogicCommands.hh index 96d648e..5e84473 100644 --- a/src/FbTk/LogicCommands.hh +++ b/src/FbTk/LogicCommands.hh | |||
@@ -30,66 +30,66 @@ | |||
30 | 30 | ||
31 | namespace FbTk { | 31 | namespace FbTk { |
32 | 32 | ||
33 | /// executes a boolcommand and uses the result to decide what to do | 33 | /// executes a Command<bool> and uses the result to decide what to do |
34 | class IfCommand: public Command { | 34 | class IfCommand: public Command<void> { |
35 | public: | 35 | public: |
36 | IfCommand(RefCount<BoolCommand> &cond, | 36 | IfCommand(RefCount<Command<bool> > &cond, |
37 | RefCount<Command> &t, RefCount<Command> &f): | 37 | RefCount<Command<void> > &t, RefCount<Command<void> > &f): |
38 | m_cond(cond), m_t(t), m_f(f) { } | 38 | m_cond(cond), m_t(t), m_f(f) { } |
39 | void execute() { | 39 | void execute() { |
40 | if (m_cond->bool_execute()) { | 40 | if (m_cond->execute()) { |
41 | if (*m_t) m_t->execute(); | 41 | if (*m_t) m_t->execute(); |
42 | } else | 42 | } else |
43 | if (*m_f) m_f->execute(); | 43 | if (*m_f) m_f->execute(); |
44 | } | 44 | } |
45 | static Command *parse(const std::string &cmd, const std::string &args, | 45 | static Command<void> *parse(const std::string &cmd, const std::string &args, |
46 | bool trusted); | 46 | bool trusted); |
47 | private: | 47 | private: |
48 | RefCount<BoolCommand> m_cond; | 48 | RefCount<Command<bool> > m_cond; |
49 | RefCount<Command> m_t, m_f; | 49 | RefCount<Command<void> > m_t, m_f; |
50 | }; | 50 | }; |
51 | 51 | ||
52 | /// executes a list of boolcommands until one is true | 52 | /// executes a list of Command<bool>s until one is true |
53 | class OrCommand: public BoolCommand { | 53 | class OrCommand: public Command<bool> { |
54 | public: | 54 | public: |
55 | void add(RefCount<BoolCommand> &com); | 55 | void add(RefCount<Command<bool> > &com); |
56 | size_t size() const; | 56 | size_t size() const; |
57 | bool bool_execute(); | 57 | bool execute(); |
58 | 58 | ||
59 | private: | 59 | private: |
60 | std::vector<RefCount<BoolCommand> > m_commandlist; | 60 | std::vector<RefCount<Command<bool> > > m_commandlist; |
61 | }; | 61 | }; |
62 | 62 | ||
63 | /// executes a list of boolcommands until one is false | 63 | /// executes a list of Command<bool>s until one is false |
64 | class AndCommand: public BoolCommand { | 64 | class AndCommand: public Command<bool> { |
65 | public: | 65 | public: |
66 | void add(RefCount<BoolCommand> &com); | 66 | void add(RefCount<Command<bool> > &com); |
67 | size_t size() const; | 67 | size_t size() const; |
68 | bool bool_execute(); | 68 | bool execute(); |
69 | 69 | ||
70 | private: | 70 | private: |
71 | std::vector<RefCount<BoolCommand> > m_commandlist; | 71 | std::vector<RefCount<Command<bool> > > m_commandlist; |
72 | }; | 72 | }; |
73 | 73 | ||
74 | /// executes a list of boolcommands, returning the parity | 74 | /// executes a list of Command<bool>s, returning the parity |
75 | class XorCommand: public BoolCommand { | 75 | class XorCommand: public Command<bool> { |
76 | public: | 76 | public: |
77 | void add(RefCount<BoolCommand> &com); | 77 | void add(RefCount<Command<bool> > &com); |
78 | size_t size() const; | 78 | size_t size() const; |
79 | bool bool_execute(); | 79 | bool execute(); |
80 | 80 | ||
81 | private: | 81 | private: |
82 | std::vector<RefCount<BoolCommand> > m_commandlist; | 82 | std::vector<RefCount<Command<bool> > > m_commandlist; |
83 | }; | 83 | }; |
84 | 84 | ||
85 | /// executes a boolcommand and returns the negation | 85 | /// executes a Command<bool> and returns the negation |
86 | class NotCommand: public BoolCommand { | 86 | class NotCommand: public Command<bool> { |
87 | public: | 87 | public: |
88 | NotCommand(RefCount<BoolCommand> &com): m_command(com) { } | 88 | NotCommand(RefCount<Command<bool> > &com): m_command(com) { } |
89 | bool bool_execute() { return !m_command->bool_execute(); } | 89 | bool execute() { return !m_command->execute(); } |
90 | 90 | ||
91 | private: | 91 | private: |
92 | RefCount<BoolCommand> m_command; | 92 | RefCount<Command<bool> > m_command; |
93 | }; | 93 | }; |
94 | 94 | ||
95 | } // end namespace FbTk | 95 | } // end namespace FbTk |