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)
5  2016, 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 
31 #ifndef STAGE_TEST_PLACEHOLDER_COMMAND_H
32 #define STAGE_TEST_PLACEHOLDER_COMMAND_H
33 
34 
35 #include "lib/error.hpp"
36 #include "lib/symbol.hpp"
37 #include "lib/idi/genfunc.hpp"
38 #include "lib/test/event-log.hpp"
40 #include "lib/format-util.hpp"
41 
42 #include <vector>
43 #include <string>
44 
45 
46 namespace stage {
47 namespace test{
48 
49  using std::string;
50  using lib::Symbol;
51 
52 
53 
54 
67  template<typename...ARGS>
69  {
70  static lib::test::EventLog log_;
71 
73  static string
75  {
76  return lib::idi::generateExtendedID<PlaceholderCommand>();
77  }
78 
79  static string
80  fullTypeID()
81  {
82  return lib::idi::typeFullID<PlaceholderCommand>();
83  }
84 
85 
87  static void
88  operate (ARGS ...args)
89  {
90  log_.call(fullTypeID(), "operate", std::forward<ARGS>(args)...);
91  }
92 
93  static string
94  capture (ARGS ...args)
95  {
96  return "Memento⧏" + util::join (util::stringify (args...),"⧓") + "⧐";
97  }
98 
99  static void
100  undo (ARGS ..., string memento)
101  {
102  log_.call(fullTypeID(), "undo", memento);
103  }
104 
105 
106  public:
108  fabricateNewInstance (lib::test::EventLog const& invocationLog)
109  {
110  log_ = invocationLog;
112  .operation(PlaceholderCommand::operate)
113  .captureUndo(PlaceholderCommand::capture)
114  .undoOperation(PlaceholderCommand::undo);
115 
116  }
117  };
118 
119 
120  template<typename...ARGS>
121  lib::test::EventLog PlaceholderCommand<ARGS...>::log_{"test-dummy-"+fullTypeID()};
122 
123 
124 
125 
126 }} // namespace stage::test
127 #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:40
Helper to log and verify the occurrence of events.
Definition: event-log.hpp:275
static void operate(ARGS ...args)
a dummy command "operation
Generic functions to build identification schemes.
Token or Atom with distinct identity.
Definition: symbol.hpp:117
Set of stub command operations.
Marker types to indicate a literal string and a Symbol.
Lumiera GTK UI implementation root.
Definition: guifacade.cpp:37
EventLog & call(string target, string function)
Log occurrence of a function call with no arguments.
Definition: event-log.cpp:690
Lumiera error handling (C++ interface).
Handle object representing a single Command instance to be used by client code.
Definition: command.hpp:115
Collection of small helpers and convenience shortcuts for diagnostics & formatting.
Actually defining a command and binding it to execution parameters.