Lumiera  0.pre.03
»edit your freedom«
session-command-service.cpp
Go to the documentation of this file.
1 /*
2  SessionCommandService - public service to invoke commands on the session
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 
27 #include "include/logging.h"
28 #include "lib/depend.hpp"
29 #include "lib/symbol.hpp"
30 #include "lib/util.hpp"
31 
32 extern "C" {
34 }
35 
36 #include <string>
37 
38 
39 
40 
41 namespace steam {
42 namespace control {
43 
44  using lib::Symbol;
45  using std::string;
46 
47 
48  Symbol
49  SessionCommandService::cycle (Symbol cmdID, string const& invocationID)
50  {
51  return instanceManager_.newInstance(cmdID, invocationID);
52  }
53 
54 
67  void
68  SessionCommandService::trigger (Symbol cmdID, Rec const& argSeq)
69  {
70  instanceManager_.getInstance(cmdID)
71  .bindArg(argSeq);
72  instanceManager_.dispatch(cmdID);
73  }
74 
75 
85  void
86  SessionCommandService::bindArg (Symbol cmdID, Rec const& argSeq)
87  {
88  instanceManager_.getInstance(cmdID)
89  .bindArg(argSeq);
90  }
91 
92 
101  void
103  {
104  instanceManager_.dispatch(cmdID);
105  }
106 
107 
108  namespace { // facade implementation details
109 
110 
111  /* ================== define an lumieraorg_GuiNotification instance ======================= */
112 
113  LUMIERA_INTERFACE_INSTANCE (lumieraorg_interfacedescriptor, 0
114  ,lumieraorg_SessionCommandFacade_descriptor
115  , NULL, NULL, NULL
116  , LUMIERA_INTERFACE_INLINE (name,
117  const char*, (LumieraInterface ifa),
118  { (void)ifa; return "SessionCommand"; }
119  )
120  , LUMIERA_INTERFACE_INLINE (brief,
121  const char*, (LumieraInterface ifa),
122  { (void)ifa; return "Session Interface: invoke pre-defined commands to operate on the session"; }
123  )
124  , LUMIERA_INTERFACE_INLINE (homepage,
125  const char*, (LumieraInterface ifa),
126  { (void)ifa; return "http://www.lumiera.org/develompent.html" ;}
127  )
128  , LUMIERA_INTERFACE_INLINE (version,
129  const char*, (LumieraInterface ifa),
130  { (void)ifa; return "0.3~pre"; }
131  )
132  , LUMIERA_INTERFACE_INLINE (author,
133  const char*, (LumieraInterface ifa),
134  { (void)ifa; return "Hermann Vosseler"; }
135  )
136  , LUMIERA_INTERFACE_INLINE (email,
137  const char*, (LumieraInterface ifa),
138  { (void)ifa; return "Ichthyostega@web.de"; }
139  )
140  , LUMIERA_INTERFACE_INLINE (copyright,
141  const char*, (LumieraInterface ifa),
142  {
143  (void)ifa;
144  return
145  "Copyright (C)\n"
146  " 2016, Hermann Vosseler <Ichthyostega@web.de>";
147  }
148  )
149  , LUMIERA_INTERFACE_INLINE (license,
150  const char*, (LumieraInterface ifa),
151  {
152  (void)ifa;
153  return
154  "**Lumiera** is free software; you can redistribute it and/or modify it\n"
155  "under the terms of the GNU General Public License as published by the\n"
156  "Free Software Foundation; either version 2 of the License, or (at your\n"
157  "option) any later version. See the file COPYING for further details."
158  ;
159  }
160  )
161  , LUMIERA_INTERFACE_INLINE (state,
162  int, (LumieraInterface ifa),
163  {(void)ifa; return LUMIERA_INTERFACE_EXPERIMENTAL; }
164  )
165  , LUMIERA_INTERFACE_INLINE (versioncmp,
166  int, (const char* a, const char* b),
167  {(void)a;(void)b; return 0;}
168  )
169  );
170 
171 
172 
173 
174 
175  using LERR_(LIFECYCLE);
176 
178 
179 
180 
181  LUMIERA_INTERFACE_INSTANCE (lumieraorg_SessionCommand, 0
182  ,lumieraorg_SessionCommandService
183  , LUMIERA_INTERFACE_REF(lumieraorg_interfacedescriptor, 0, lumieraorg_SessionCommandFacade_descriptor)
184  , NULL /* on open */
185  , NULL /* on close */
186  , LUMIERA_INTERFACE_INLINE (cycle,
187  const char*, (const char* cmdID, const char* invocationID),
188  {
189  if (!_instance)
190  return lumiera_error_set (LUMIERA_ERROR_LIFECYCLE, cmdID);
191  else
192  return _instance().cycle(cmdID, invocationID);
193  }
194  )
195  , LUMIERA_INTERFACE_INLINE (trigger,
196  void, (const char* cmdID, const void* args),
197  {
198  if (!_instance) lumiera_error_set (LUMIERA_ERROR_LIFECYCLE, cmdID);
199  else
200  _instance().trigger(cmdID, *static_cast<Rec const *> (args));
201  }
202  )
203  , LUMIERA_INTERFACE_INLINE (bindArg,
204  void, (const char* cmdID, const void* args),
205  {
206  if (!_instance) lumiera_error_set (LUMIERA_ERROR_LIFECYCLE, cmdID);
207  else
208  _instance().bindArg(cmdID, *static_cast<Rec const *> (args));
209  }
210  )
211  , LUMIERA_INTERFACE_INLINE (invoke,
212  void, (const char* cmdID),
213  {
214  if (!_instance) lumiera_error_set (LUMIERA_ERROR_LIFECYCLE, cmdID);
215  else
216  _instance().invoke(cmdID);
217  }
218  )
219  );
220 
221 
222 
223  } // (END) facade implementation details
224 
225 
226 
229  : dispatcher_{dispatcherLoopInterface}
230  , instanceManager_{dispatcher_}
231  , serviceInstance_{ LUMIERA_INTERFACE_REF (lumieraorg_SessionCommand, 0, lumieraorg_SessionCommandService)}
232  {
233  INFO (stage, "SessionCommand Facade opened.");
234  }
235 
236 
237 
238 
239 }} // namespace steam::control
lib::Depend< SessionCommandService > _instance
a backdoor for the C Language impl to access the actual SessionCommand implementation...
Symbol newInstance(Symbol prototypeID, string const &invocationID)
Create and thus "open" a new anonymous command instance.
Symbol cycle(Symbol cmdID, string const &invocationID) override
start next command cycle and "open" a new anonymous command instance
A public service offered by the Session, implementing the SessionCommand facade interface.
This header is for including and configuring NoBug.
Steam-Layer implementation namespace root.
Access point to singletons and other kinds of dependencies designated by type.
Definition: depend.hpp:280
Not finished development code.
Command getInstance(Symbol instanceID)
access the currently "opened" instance with the given instanceID
#define LUMIERA_INTERFACE_INSTANCE(iname, version, name, descriptor, acquire, release,...)
Define an interface instance.
Definition: interface.h:185
Token or Atom with distinct identity.
Definition: symbol.hpp:117
Marker types to indicate a literal string and a Symbol.
#define LUMIERA_INTERFACE_REF(iname, version, dname)
Return a reference (pointer) to an interface implementation.
Definition: interface.h:119
Interface of a service to perform Commands on the session.
Lumiera GTK UI implementation root.
Definition: guifacade.cpp:37
Tiny helper functions and shortcuts to be used everywhere Consider this header to be effectively incl...
Steam-Layer command frontend.
Singleton services and Dependency Injection.
lumiera_err lumiera_error_set(lumiera_err nerr, const char *extra)
Set error state for the current thread.
Definition: error-state.c:96
SessionCommandService(CommandDispatch &dispatcherLoopInterface)
A data record to describe interface, interface instances and plug-in instances.
void dispatch(Symbol instanceID)
hand over the designated command instance to the dispatcher installed on construction.
ElementBoxWidget::Config::Qualifier name(string id)
define the name-ID displayed in the caption
void bindArg(Symbol cmdID, Rec const &args) override
void trigger(Symbol cmdID, Rec const &args) override