ONE - On-device Neural Engine
Loading...
Searching...
No Matches
Context.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2019 Samsung Electronics Co., Ltd. All Rights Reserved
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17#ifndef __HERMES_CONTEXT_H__
18#define __HERMES_CONTEXT_H__
19
20#include "hermes/core/Config.h"
21#include "hermes/core/Source.h"
22#include "hermes/core/Sink.h"
24
25#include <memory>
26#include <set>
27
28namespace hermes
29{
30
39class Context final : private MessageBus, private Source::Registry, private Sink::Registry
40{
41public:
43 const Config *config(void) const;
45 void config(std::unique_ptr<Config> &&);
46
47public:
48 MessageBus *bus(void) { return this; }
49
50private:
52 void post(std::unique_ptr<Message> &&msg) override;
53
54public:
55 Source::Registry *sources(void) { return this; }
56
57private:
59 void attach(Source *source) override;
61 void detach(Source *source) override;
62
63public:
64 Sink::Registry *sinks(void) { return this; }
65
66private:
68 void append(std::unique_ptr<Sink> &&sink) override;
69
70private:
71 std::unique_ptr<Config> _config;
72 std::set<Source *> _sources;
73 std::set<std::unique_ptr<Sink>> _sinks;
74};
75
76} // namespace hermes
77
78#endif // __HERMES_CONTEXT_H__
Logging controller.
Definition Context.h:40
Source::Registry * sources(void)
Definition Context.h:55
Sink::Registry * sinks(void)
Definition Context.h:64
MessageBus * bus(void)
Definition Context.h:48
const Config * config(void) const
Get the global configuration.
Definition Context.cpp:24
Message Source.
Definition Source.h:35
Top-level configuration interface.
Definition Config.h:35
A bridge between Source and Sink.
Definition MessageBus.h:31