Fawkes API  Fawkes Development Version
plugin-rest-api.h
1 
2 /***************************************************************************
3  * plugin-rest-api.h - Plugin REST API
4  *
5  * Created: Tue Apr 10 17:08:41 2018
6  * Copyright 2006-2018 Tim Niemueller [www.niemueller.de]
7  ****************************************************************************/
8 
9 /* This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17  * GNU Library General Public License for more details.
18  *
19  * Read the full text in the LICENSE.GPL file in the doc directory.
20  */
21 
22 #pragma once
23 
24 #include "model/Plugin.h"
25 #include "model/PluginOpRequest.h"
26 #include "model/PluginOpResponse.h"
27 
28 #include <aspect/logging.h>
29 #include <aspect/plugin_director.h>
30 #include <aspect/webview.h>
31 #include <core/threading/thread.h>
32 #include <webview/rest_api.h>
33 #include <webview/rest_array.h>
34 
35 #include <map>
36 #include <string>
37 
38 class PluginRestApi : public fawkes::Thread,
39  public fawkes::LoggingAspect,
42 {
43 public:
44  PluginRestApi();
46 
47  virtual void init();
48  virtual void loop();
49  virtual void finalize();
50 
51 private:
52  WebviewRestArray<::Plugin> cb_list_plugins();
53  PluginOpResponse cb_set_plugin_state(PluginOpRequest &request, fawkes::WebviewRestParams &params);
54 
55 private:
56  fawkes::WebviewRestApi *rest_api_;
57 };
PluginRestApi::finalize
virtual void finalize()
Finalize the thread.
Definition: plugin-rest-api.cpp:60
fawkes::PluginDirectorAspect
Definition: plugin_director.h:36
PluginRestApi
Definition: plugin-rest-api.h:37
PluginRestApi::~PluginRestApi
~PluginRestApi()
Destructor.
Definition: plugin-rest-api.cpp:41
fawkes::LoggingAspect
Definition: logging.h:36
WebviewRestArray
Container to return array via REST.
Definition: rest_array.h:34
fawkes::WebviewRestParams
REST parameters to pass to handlers.
Definition: rest_api.h:127
PluginRestApi::PluginRestApi
PluginRestApi()
Constructor.
Definition: plugin-rest-api.cpp:36
PluginOpRequest
PluginOpRequest representation for JSON transfer.
Definition: PluginOpRequest.h:25
fawkes::WebviewAspect
Definition: webview.h:40
PluginRestApi::loop
virtual void loop()
Code to execute in the thread.
Definition: plugin-rest-api.cpp:67
PluginRestApi::init
virtual void init()
Initialize the thread.
Definition: plugin-rest-api.cpp:46
fawkes::WebviewRestApi
Definition: rest_api.h:223
fawkes::Thread
Definition: thread.h:44
PluginOpResponse
PluginOpResponse representation for JSON transfer.
Definition: PluginOpResponse.h:25