Fawkes API  Fawkes Development Version
skiller-rest-api.h
1 
2 /***************************************************************************
3  * skiller-rest-api.h - Behavior Engine REST API
4  *
5  * Created: Mon Mar 26 22:00:43 2018 +0200
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/Skill.h"
25 #include "model/SkillCall.h"
26 #include "model/SkillInfo.h"
27 
28 #include <aspect/blackboard.h>
29 #include <aspect/clock.h>
30 #include <aspect/logging.h>
31 #include <aspect/webview.h>
32 #include <core/threading/thread.h>
33 #include <webview/rest_api.h>
34 #include <webview/rest_array.h>
35 
36 namespace fawkes {
37 class SkillerDebugInterface;
38 class SkillerInterface;
39 } // namespace fawkes
40 
41 class SkillerRestApi : public fawkes::Thread,
42  public fawkes::ClockAspect,
43  public fawkes::LoggingAspect,
46 {
47 public:
50 
51  virtual void init();
52  virtual void loop();
53  virtual void finalize();
54 
55 private:
56  WebviewRestArray<SkillInfo> cb_list_skills();
57 
58  Skill cb_get_skill(fawkes::WebviewRestParams &params);
59 
60  Skill cb_exec_skill(const SkillCall &call);
61 
62  std::unique_ptr<fawkes::WebviewRestReply> cb_stop_skill(fawkes::WebviewRestParams &params);
63 
64  void set_and_wait_graph(const char *graph);
65 
66 private:
67  fawkes::WebviewRestApi * rest_api_;
69  fawkes::SkillerInterface * skiller_if_;
70 };
SkillerRestApi::finalize
virtual void finalize()
Finalize the thread.
Definition: skiller-rest-api.cpp:72
SkillerRestApi::init
virtual void init()
Initialize the thread.
Definition: skiller-rest-api.cpp:47
SkillCall
SkillCall representation for JSON transfer.
Definition: SkillCall.h:26
SkillerRestApi::~SkillerRestApi
~SkillerRestApi()
Destructor.
Definition: skiller-rest-api.cpp:42
SkillerRestApi
Definition: skiller-rest-api.h:40
fawkes::BlackBoardAspect
Definition: blackboard.h:36
fawkes
fawkes::LoggingAspect
Definition: logging.h:36
Skill
Skill representation for JSON transfer.
Definition: Skill.h:26
fawkes::SkillerDebugInterface
Definition: SkillerDebugInterface.h:37
WebviewRestArray
Container to return array via REST.
Definition: rest_array.h:34
SkillerRestApi::SkillerRestApi
SkillerRestApi()
Constructor.
Definition: skiller-rest-api.cpp:37
fawkes::SkillerInterface
Definition: SkillerInterface.h:37
fawkes::WebviewRestParams
REST parameters to pass to handlers.
Definition: rest_api.h:127
fawkes::WebviewAspect
Definition: webview.h:40
fawkes::WebviewRestApi
Definition: rest_api.h:223
fawkes::Thread
Definition: thread.h:44
fawkes::ClockAspect
Definition: clock.h:38
SkillerRestApi::loop
virtual void loop()
Code to execute in the thread.
Definition: skiller-rest-api.cpp:79