Fawkes API Fawkes Development Version
blackboard-rest-api.h
1
2/***************************************************************************
3 * blackboard-rest-api.h - Blackboard REST API
4 *
5 * Created: Mon Mar 26 23:26:40 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/BlackboardGraph.h"
25#include "model/InterfaceData.h"
26#include "model/InterfaceInfo.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 <interface/field_iterator.h>
34#include <interface/interface_info.h>
35#include <webview/rest_api.h>
36#include <webview/rest_array.h>
37
38#include <map>
39#include <string>
40#include <utility>
41
47{
48public:
51
52 virtual void init();
53 virtual void loop();
54 virtual void finalize();
55
56private:
57 WebviewRestArray<InterfaceInfo> cb_list_interfaces();
58
59 InterfaceInfo cb_get_interface_info(fawkes::WebviewRestParams &params);
60
61 InterfaceData cb_get_interface_data(fawkes::WebviewRestParams &params);
62
63 BlackboardGraph cb_get_graph();
64
65 std::vector<std::shared_ptr<InterfaceFieldType>> gen_fields(fawkes::InterfaceFieldIterator begin,
67
68 InterfaceInfo gen_interface_info(const fawkes::InterfaceInfo &ii);
69 InterfaceData gen_interface_data(fawkes::Interface *iface, bool pretty);
70
71 std::string generate_graph(const std::string &for_owner = "");
72
73private:
74 fawkes::WebviewRestApi *rest_api_;
75
76 std::map<std::string,
77 std::pair<std::vector<std::shared_ptr<InterfaceFieldType>>,
78 std::vector<std::shared_ptr<InterfaceMessageType>>>>
79 type_info_cache_;
80};
BlackboardGraph representation for JSON transfer.
REST API backend for the blackboard.
virtual void loop()
Code to execute in the thread.
~BlackboardRestApi()
Destructor.
virtual void finalize()
Finalize the thread.
virtual void init()
Initialize the thread.
BlackboardRestApi()
Constructor.
InterfaceData representation for JSON transfer.
Definition: InterfaceData.h:28
InterfaceInfo representation for JSON transfer.
Definition: InterfaceInfo.h:31
Container to return array via REST.
Definition: rest_array.h:36
Thread aspect to access to BlackBoard.
Definition: blackboard.h:34
Thread aspect that allows to obtain the current time from the clock.
Definition: clock.h:34
Interface field iterator.
Interface info.
Base class for all Fawkes BlackBoard interfaces.
Definition: interface.h:80
Thread aspect to log output.
Definition: logging.h:33
Thread class encapsulation of pthreads.
Definition: thread.h:46
Thread aspect to provide web pages via Webview.
Definition: webview.h:37
Webview REST API component.
Definition: rest_api.h:221
REST parameters to pass to handlers.
Definition: rest_api.h:125