Fawkes API Fawkes Development Version
image-rest-api.h
1
2/***************************************************************************
3 * image-rest-api.h - Image REST API
4 *
5 * Created: Sun Apr 8 19:07:16 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/ImageInfo.h"
25
26#include <aspect/blackboard.h>
27#include <aspect/clock.h>
28#include <aspect/configurable.h>
29#include <aspect/logging.h>
30#include <aspect/thread_producer.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#include <map>
37#include <string>
38#include <utility>
39
40namespace fawkes {
41class WebviewJpegStreamProducer;
42}
43
51{
52public:
55
56 virtual void init();
57 virtual void loop();
58 virtual void finalize();
59
60private:
61 WebviewRestArray<ImageInfo> cb_list_images();
62
63 std::shared_ptr<fawkes::WebviewJpegStreamProducer> get_stream(const std::string &image_id);
64
65 std::unique_ptr<fawkes::WebReply> cb_get_image(fawkes::WebviewRestParams &params);
66
67private:
68 fawkes::WebviewRestApi * rest_api_;
69 std::map<std::string, std::shared_ptr<fawkes::WebviewJpegStreamProducer>> streams_;
70};
REST API backend for the image.
virtual void loop()
Code to execute in the thread.
virtual void init()
Initialize the thread.
~ImageRestApi()
Destructor.
ImageRestApi()
Constructor.
virtual void finalize()
Finalize the thread.
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
Thread aspect to access configuration data.
Definition: configurable.h:33
Thread aspect to log output.
Definition: logging.h:33
Aspect for thread producing threads.
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
Fawkes library namespace.