Lumiera  0.pre.03
»edit your freedom«
handling-patterns.hpp
Go to the documentation of this file.
1 /*
2  HANDLILNG-PATTERNS.hpp - Collection of predefined command handling patterns
3 
4  Copyright (C)
5  2009, Hermann Vosseler <Ichthyostega@web.de>
6 
7   **Lumiera** is free software; you can redistribute it and/or modify it
8   under the terms of the GNU General Public License as published by the
9   Free Software Foundation; either version 2 of the License, or (at your
10   option) any later version. See the file COPYING for further details.
11 
12 */
13 
14 
33 #ifndef CONTROL_HANDLING_PATTERNS_DEF_H
34 #define CONTROL_HANDLING_PATTERNS_DEF_H
35 
36 #include "lib/error.hpp"
37 #include "lib/multifact.hpp"
40 
41 
42 
43 namespace steam {
44 namespace control {
45 
46  namespace { // concrete command handling patterns
47 
48 
49 
50 
57  : public HandlingPattern
58  {
59  bool isValid() const { return true; }
60 
61  void
62  performExec (CommandImpl& command) const override
63  {
64  REQUIRE (command.canExec());
65  command.invokeCapture();
66  command.invokeOperation();
67  }
68 
69  void
70  performUndo (CommandImpl& command) const override
71  {
72  REQUIRE (command.canUndo());
73  command.invokeUndo();
74  }
75  };
76 
77 
78 
85  : public BasicHandlingPattern
86  {
87  void
88  performExec (CommandImpl& command) const override
89  {
90  UNIMPLEMENTED ("actually invoke a command, according to this pattern");
91  }
92 
93  void
94  performUndo (CommandImpl& command) const override
95  {
96  UNIMPLEMENTED ("actually undo the effect of a command, according to this pattern");
97  }
98 
99  bool
100  isValid() const override
101  {
102  UNIMPLEMENTED ("is this pattern currently able to handle commands?");
103  }
104  };
105 
106 
107 
115  : public BasicHandlingPattern
116  {
117  void
118  performExec (CommandImpl& command) const override
119  {
120  UNIMPLEMENTED ("actually invoke a command, according to this pattern");
121  }
122 
123  void
124  performUndo (CommandImpl& command) const override
125  {
126  UNIMPLEMENTED ("actually undo the effect of a command, according to this pattern");
127  }
128 
129  bool
130  isValid() const override
131  {
132  UNIMPLEMENTED ("is this pattern currently able to handle commands?");
133  }
134  };
135 
136 
137 
145  : public BasicHandlingPattern
146  {
147  void
148  performExec (CommandImpl& command) const override
149  {
150  UNIMPLEMENTED ("actually invoke a command, according to this pattern");
151  }
152 
153  void
154  performUndo (CommandImpl& command) const override
155  {
156  UNIMPLEMENTED ("actually undo the effect of a command, according to this pattern");
157  }
158 
159  bool
160  isValid() const override
161  {
162  UNIMPLEMENTED ("is this pattern currently able to handle commands?");
163  }
164  };
165 
166 
167 
168 
169 
170 
171  /* ======== Handling Pattern Table ========== */
172 
174 
176  HandlingPatternFactory patternTable;
177 
178  HandlingPatternFactory::Singleton<InvokeSyncNoThrow> holder1 (patternTable, HandlingPattern::SYNC);
179  HandlingPatternFactory::Singleton<InvokeSyncThrow> holder2 (patternTable, HandlingPattern::SYNC_THROW);
180  HandlingPatternFactory::Singleton<InvokeAsync> holder3 (patternTable, HandlingPattern::ASYNC);
181  HandlingPatternFactory::Singleton<BasicHandlingPattern> holder4 (patternTable, HandlingPattern::DUMMY);
182 
183 
185  inline HandlingPattern const&
186  getPatternInstance (HandlingPattern::ID id)
187  {
188  REQUIRE (patternTable.contains(id));
189 
190  return patternTable (id);
191  }
192 
193 
194  } // (END) definition of concrete handling patterns
195 
196 
197 
198 
199 
200 
201 
202 }} // namespace steam::control
203 #endif
Handling Pattern: invoke blocking, translate exceptions into an error state.
Handling Pattern: just schedule command to be invoked asynchronously.
Framework for building a configurable factory, to generate families of related objects.
bool canExec() const
< state check: sufficiently defined to be invoked
Top level of the command implementation.
Steam-Layer implementation namespace root.
Handling Pattern: invoke blocking, propagating any exceptions immediately.
HandlingPatternFactory patternTable
holds singleton pattern instances by ID
Factory for creating a family of objects by ID.
Definition: multifact.hpp:253
bool canUndo() const
< state check: has undo state been captured?
HandlingPattern const & getPatternInstance(HandlingPattern::ID id)
access the singleton instance for a given ID
Pre-defined command execution skeletons.
Lumiera error handling (C++ interface).
Handling Pattern Foundation: invoke command directly and without any external intervention.
Steam-Layer Command implementation.
Convenience shortcut for automatically setting up a production line, to fabricate a singleton instanc...
Definition: multifact.hpp:323
Interface: Operation Skeleton how to invoke or undo a command.