Lumiera  0.pre.03
»edit your freedom«
placeholder-command.hpp
Go to the documentation of this file.
1 /*
2  PLACEHOLDER-COMMAND.hpp - fake operation to mock command invocation from UI
3 
4  Copyright (C) Lumiera.org
5  2016, Hermann Vosseler <Ichthyostega@web.de>
6 
7  This program is free software; you can redistribute it and/or
8  modify it under the terms of the GNU General Public License as
9  published by the Free Software Foundation; either version 2 of
10  the License, or (at your option) any later version.
11 
12  This program is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU General Public License for more details.
16 
17  You should have received a copy of the GNU General Public License
18  along with this program; if not, write to the Free Software
19  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 
21 */
22 
23 
40 #ifndef STAGE_TEST_PLACEHOLDER_COMMAND_H
41 #define STAGE_TEST_PLACEHOLDER_COMMAND_H
42 
43 
44 #include "lib/error.hpp"
45 #include "lib/symbol.hpp"
46 #include "lib/idi/genfunc.hpp"
47 #include "lib/test/event-log.hpp"
49 #include "lib/format-util.hpp"
50 
51 #include <vector>
52 #include <string>
53 
54 
55 namespace stage {
56 namespace test{
57 
58  using std::string;
59  using lib::Symbol;
60 
61 
62 
63 
76  template<typename...ARGS>
78  {
79  static lib::test::EventLog log_;
80 
82  static string
84  {
85  return lib::idi::generateExtendedID<PlaceholderCommand>();
86  }
87 
88  static string
89  fullTypeID()
90  {
91  return lib::idi::typeFullID<PlaceholderCommand>();
92  }
93 
94 
96  static void
97  operate (ARGS ...args)
98  {
99  log_.call(fullTypeID(), "operate", std::forward<ARGS>(args)...);
100  }
101 
102  static string
103  capture (ARGS ...args)
104  {
105  return "Memento⧏" + util::join (util::stringify (args...),"⧓") + "⧐";
106  }
107 
108  static void
109  undo (ARGS ..., string memento)
110  {
111  log_.call(fullTypeID(), "undo", memento);
112  }
113 
114 
115  public:
117  fabricateNewInstance (lib::test::EventLog const& invocationLog)
118  {
119  log_ = invocationLog;
121  .operation(PlaceholderCommand::operate)
122  .captureUndo(PlaceholderCommand::capture)
123  .undoOperation(PlaceholderCommand::undo);
124 
125  }
126  };
127 
128 
129  template<typename...ARGS>
130  lib::test::EventLog PlaceholderCommand<ARGS...>::log_{"test-dummy-"+fullTypeID()};
131 
132 
133 
134 
135 }} // namespace stage::test
136 #endif /*STAGE_TEST_PLACEHOLDER_COMMAND_H*/
Helper class used solely for defining a Command-Object.
Support for verifying the occurrence of events from unit tests.
Definition: run.hpp:49
Helper to log and verify the occurrence of events.
Definition: event-log.hpp:284
static void operate(ARGS ...args)
a dummy command "operation
Generic functions to build identification schemes.
Token or Atom with distinct identity.
Definition: symbol.hpp:126
Set of stub command operations.
Marker types to indicate a literal string and a Symbol.
Lumiera GTK UI implementation root.
Definition: guifacade.cpp:46
EventLog & call(string target, string function)
Log occurrence of a function call with no arguments.
Definition: event-log.cpp:699
Lumiera error handling (C++ interface).
Handle object representing a single Command instance to be used by client code.
Definition: command.hpp:124
Collection of small helpers and convenience shortcuts for diagnostics & formatting.
Actually defining a command and binding it to execution parameters.