1 // Copyright (C) 2014-2017 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
2 // This Source Code Form is subject to the terms of the Mozilla Public
3 // License, v. 2.0. If a copy of the MPL was not distributed with this
4 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 
6 #ifndef VSOMEIP_V3_RUNTIME_IMPL_HPP_
7 #define VSOMEIP_V3_RUNTIME_IMPL_HPP_
8 
9 #include <vsomeip/runtime.hpp>
10 #include <map>
11 #include <mutex>
12 
13 namespace vsomeip_v3 {
14 
15 class runtime_impl: public runtime {
16 public:
17 
18     static std::string get_property(const std::string &_name);
19     static void set_property(const std::string &_name, const std::string &_value);
20 
21     static std::shared_ptr<runtime> get();
22 
23     virtual ~runtime_impl();
24 
25     std::shared_ptr<application> create_application(
26             const std::string &_name);
27 
28     std::shared_ptr<message> create_message(bool _reliable) const;
29     std::shared_ptr<message> create_request(bool _reliable) const;
30     std::shared_ptr<message> create_response(
31             const std::shared_ptr<message> &_request) const;
32     std::shared_ptr<message> create_notification(bool _reliable) const;
33 
34     std::shared_ptr<payload> create_payload() const;
35     std::shared_ptr<payload> create_payload(const byte_t *_data,
36             uint32_t _size) const;
37     std::shared_ptr<payload> create_payload(
38             const std::vector<byte_t> &_data) const;
39 
40     std::shared_ptr<application> get_application(
41             const std::string &_name) const;
42 
43     void remove_application( const std::string &_name);
44 
45 private:
46     static std::map<std::string, std::string> properties_;
47 
48     std::map<std::string, std::weak_ptr<application>> applications_;
49 
50     mutable std::mutex applications_mutex_;
51 };
52 
53 } // namespace vsomeip_v3
54 
55 #endif // VSOMEIP_V3_RUNTIME_IMPL_HPP_
56