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) 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 
36 #include "include/logging.h"
37 #include "lib/depend.hpp"
38 #include "lib/symbol.hpp"
39 #include "lib/util.hpp"
40 
41 extern "C" {
43 }
44 
45 #include <string>
46 
47 
48 
49 
50 namespace steam {
51 namespace control {
52 
53  using lib::Symbol;
54  using std::string;
55 
56 
57  Symbol
58  SessionCommandService::cycle (Symbol cmdID, string const& invocationID)
59  {
60  return instanceManager_.newInstance(cmdID, invocationID);
61  }
62 
63 
76  void
77  SessionCommandService::trigger (Symbol cmdID, Rec const& argSeq)
78  {
79  instanceManager_.getInstance(cmdID)
80  .bindArg(argSeq);
81  instanceManager_.dispatch(cmdID);
82  }
83 
84 
94  void
95  SessionCommandService::bindArg (Symbol cmdID, Rec const& argSeq)
96  {
97  instanceManager_.getInstance(cmdID)
98  .bindArg(argSeq);
99  }
100 
101 
110  void
112  {
113  instanceManager_.dispatch(cmdID);
114  }
115 
116 
117  namespace { // facade implementation details
118 
119 
120  /* ================== define an lumieraorg_GuiNotification instance ======================= */
121 
122  LUMIERA_INTERFACE_INSTANCE (lumieraorg_interfacedescriptor, 0
123  ,lumieraorg_SessionCommandFacade_descriptor
124  , NULL, NULL, NULL
125  , LUMIERA_INTERFACE_INLINE (name,
126  const char*, (LumieraInterface ifa),
127  { (void)ifa; return "SessionCommand"; }
128  )
129  , LUMIERA_INTERFACE_INLINE (brief,
130  const char*, (LumieraInterface ifa),
131  { (void)ifa; return "Session Interface: invoke pre-defined commands to operate on the session"; }
132  )
133  , LUMIERA_INTERFACE_INLINE (homepage,
134  const char*, (LumieraInterface ifa),
135  { (void)ifa; return "http://www.lumiera.org/develompent.html" ;}
136  )
137  , LUMIERA_INTERFACE_INLINE (version,
138  const char*, (LumieraInterface ifa),
139  { (void)ifa; return "0.3~pre"; }
140  )
141  , LUMIERA_INTERFACE_INLINE (author,
142  const char*, (LumieraInterface ifa),
143  { (void)ifa; return "Hermann Vosseler"; }
144  )
145  , LUMIERA_INTERFACE_INLINE (email,
146  const char*, (LumieraInterface ifa),
147  { (void)ifa; return "Ichthyostega@web.de"; }
148  )
149  , LUMIERA_INTERFACE_INLINE (copyright,
150  const char*, (LumieraInterface ifa),
151  {
152  (void)ifa;
153  return
154  "Copyright (C) Lumiera.org\n"
155  " 2016 Hermann Vosseler <Ichthyostega@web.de>";
156  }
157  )
158  , LUMIERA_INTERFACE_INLINE (license,
159  const char*, (LumieraInterface ifa),
160  {
161  (void)ifa;
162  return
163  "This program is free software; you can redistribute it and/or modify\n"
164  "it under the terms of the GNU General Public License as published by\n"
165  "the Free Software Foundation; either version 2 of the License, or\n"
166  "(at your option) any later version.\n"
167  "\n"
168  "This program is distributed in the hope that it will be useful,\n"
169  "but WITHOUT ANY WARRANTY; without even the implied warranty of\n"
170  "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n"
171  "GNU General Public License for more details.\n"
172  "\n"
173  "You should have received a copy of the GNU General Public License\n"
174  "along with this program; if not, write to the Free Software\n"
175  "Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA";
176  }
177  )
178  , LUMIERA_INTERFACE_INLINE (state,
179  int, (LumieraInterface ifa),
180  {(void)ifa; return LUMIERA_INTERFACE_EXPERIMENTAL; }
181  )
182  , LUMIERA_INTERFACE_INLINE (versioncmp,
183  int, (const char* a, const char* b),
184  {(void)a;(void)b; return 0;}
185  )
186  );
187 
188 
189 
190 
191 
192  using LERR_(LIFECYCLE);
193 
195 
196 
197 
198  LUMIERA_INTERFACE_INSTANCE (lumieraorg_SessionCommand, 0
199  ,lumieraorg_SessionCommandService
200  , LUMIERA_INTERFACE_REF(lumieraorg_interfacedescriptor, 0, lumieraorg_SessionCommandFacade_descriptor)
201  , NULL /* on open */
202  , NULL /* on close */
203  , LUMIERA_INTERFACE_INLINE (cycle,
204  const char*, (const char* cmdID, const char* invocationID),
205  {
206  if (!_instance)
207  return lumiera_error_set (LUMIERA_ERROR_LIFECYCLE, cmdID);
208  else
209  return _instance().cycle(cmdID, invocationID);
210  }
211  )
212  , LUMIERA_INTERFACE_INLINE (trigger,
213  void, (const char* cmdID, const void* args),
214  {
215  if (!_instance) lumiera_error_set (LUMIERA_ERROR_LIFECYCLE, cmdID);
216  else
217  _instance().trigger(cmdID, *static_cast<Rec const *> (args));
218  }
219  )
220  , LUMIERA_INTERFACE_INLINE (bindArg,
221  void, (const char* cmdID, const void* args),
222  {
223  if (!_instance) lumiera_error_set (LUMIERA_ERROR_LIFECYCLE, cmdID);
224  else
225  _instance().bindArg(cmdID, *static_cast<Rec const *> (args));
226  }
227  )
228  , LUMIERA_INTERFACE_INLINE (invoke,
229  void, (const char* cmdID),
230  {
231  if (!_instance) lumiera_error_set (LUMIERA_ERROR_LIFECYCLE, cmdID);
232  else
233  _instance().invoke(cmdID);
234  }
235  )
236  );
237 
238 
239 
240  } // (END) facade implementation details
241 
242 
243 
246  : dispatcher_{dispatcherLoopInterface}
247  , instanceManager_{dispatcher_}
248  , serviceInstance_{ LUMIERA_INTERFACE_REF (lumieraorg_SessionCommand, 0, lumieraorg_SessionCommandService)}
249  {
250  INFO (stage, "SessionCommand Facade opened.");
251  }
252 
253 
254 
255 
256 }} // 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:289
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:194
Token or Atom with distinct identity.
Definition: symbol.hpp:126
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:128
Interface of a service to perform Commands on the session.
Lumiera GTK UI implementation root.
Definition: guifacade.cpp:46
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:105
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