blob: 4943b6dd5398aba4a429f2c25797d7b8801e7379 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
// Copyright (C) 2014-2016 Bayerische Motoren Werke Aktiengesellschaft (BMW AG)
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
#include <vsomeip/defines.hpp>
#include "../include/application_impl.hpp"
#include "../include/runtime_impl.hpp"
#include "../../message/include/message_impl.hpp"
#include "../../message/include/payload_impl.hpp"
namespace vsomeip {
std::map<std::string, std::string> runtime_impl::properties_;
std::shared_ptr<runtime> runtime_impl::the_runtime_ = std::make_shared<runtime_impl>();
std::string runtime_impl::get_property(const std::string &_name) {
auto found_property = properties_.find(_name);
if (found_property != properties_.end())
return found_property->second;
return "";
}
void runtime_impl::set_property(const std::string &_name, const std::string &_value) {
properties_[_name] = _value;
}
std::shared_ptr<runtime> runtime_impl::get() {
return the_runtime_;
}
runtime_impl::~runtime_impl() {
}
std::shared_ptr<application> runtime_impl::create_application(
const std::string &_name) {
std::shared_ptr<application> application = std::make_shared<application_impl>(_name);
applications_[_name] = application;
return application;
}
std::shared_ptr<message> runtime_impl::create_message(bool _reliable) const {
std::shared_ptr<message_impl> its_message =
std::make_shared<message_impl>();
its_message->set_protocol_version(VSOMEIP_PROTOCOL_VERSION);
its_message->set_return_code(return_code_e::E_OK);
its_message->set_reliable(_reliable);
its_message->set_interface_version(DEFAULT_MAJOR);
return (its_message);
}
std::shared_ptr<message> runtime_impl::create_request(bool _reliable) const {
std::shared_ptr<message_impl> its_request =
std::make_shared<message_impl>();
its_request->set_protocol_version(VSOMEIP_PROTOCOL_VERSION);
its_request->set_message_type(message_type_e::MT_REQUEST);
its_request->set_return_code(return_code_e::E_OK);
its_request->set_reliable(_reliable);
its_request->set_interface_version(DEFAULT_MAJOR);
return (its_request);
}
std::shared_ptr<message> runtime_impl::create_response(
const std::shared_ptr<message> &_request) const {
std::shared_ptr<message_impl> its_response =
std::make_shared<message_impl>();
its_response->set_service(_request->get_service());
its_response->set_instance(_request->get_instance());
its_response->set_method(_request->get_method());
its_response->set_client(_request->get_client());
its_response->set_session(_request->get_session());
its_response->set_interface_version(_request->get_interface_version());
its_response->set_message_type(message_type_e::MT_RESPONSE);
its_response->set_return_code(return_code_e::E_OK);
its_response->set_reliable(_request->is_reliable());
return (its_response);
}
std::shared_ptr<message> runtime_impl::create_notification(
bool _reliable) const {
std::shared_ptr<message_impl> its_notification = std::make_shared<
message_impl>();
its_notification->set_protocol_version(VSOMEIP_PROTOCOL_VERSION);
its_notification->set_message_type(message_type_e::MT_NOTIFICATION);
its_notification->set_return_code(return_code_e::E_OK);
its_notification->set_reliable(_reliable);
its_notification->set_interface_version(DEFAULT_MAJOR);
return (its_notification);
}
std::shared_ptr<payload> runtime_impl::create_payload() const {
return (std::make_shared<payload_impl>());
}
std::shared_ptr<payload> runtime_impl::create_payload(const byte_t *_data,
uint32_t _size) const {
return (std::make_shared<payload_impl>(_data, _size));
}
std::shared_ptr<payload> runtime_impl::create_payload(
const std::vector<byte_t> &_data) const {
return (std::make_shared<payload_impl>(_data));
}
std::shared_ptr<application> runtime_impl::get_application(
const std::string &_name) const {
auto found_application = applications_.find(_name);
if(found_application != applications_.end())
return found_application->second;
return nullptr;
}
} // namespace vsomeip
|