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_HANDLER_HPP
7 #define VSOMEIP_HANDLER_HPP
8 
9 #include <functional>
10 #include <memory>
11 
12 #include "../../compat/vsomeip/primitive_types.hpp"
13 
14 namespace vsomeip {
15 
16 class message;
17 
18 typedef std::function< void (state_type_e) > state_handler_t;
19 typedef std::function< void (const std::shared_ptr< message > &) > message_handler_t;
20 typedef std::function< void (service_t, instance_t, bool) > availability_handler_t;
21 typedef std::function< bool (client_t, bool) > subscription_handler_t;
22 typedef std::function< void (const uint16_t) > error_handler_t;
23 typedef std::function< void (const service_t, const instance_t, const eventgroup_t,
24                              const event_t, const uint16_t) > subscription_status_handler_t;
25 typedef std::function< void (client_t, bool, std::function< void (const bool) > )> async_subscription_handler_t;
26 
27 typedef std::function< void (const std::vector<std::pair<service_t, instance_t>> &_services) > offered_services_handler_t;
28 typedef std::function< void () > watchdog_handler_t;
29 
30 struct ip_address_t {
31     union {
32         ipv4_address_t v4_;
33         ipv6_address_t v6_;
34     } address_;
35     bool is_v4_;
36 
operator <vsomeip::ip_address_t37     bool operator<(const ip_address_t& _other) const {
38         if (is_v4_ && _other.is_v4_) {
39             return address_.v4_ < _other.address_.v4_;
40         } else if (!is_v4_ && !_other.is_v4_) {
41             return address_.v6_ < _other.address_.v6_;
42         } else if (is_v4_ && !_other.is_v4_) {
43             return true;
44         } else {
45             return false;
46         }
47     }
48 
operator ==vsomeip::ip_address_t49     bool operator==(const ip_address_t& _other) const {
50         if (is_v4_ && _other.is_v4_) {
51             return address_.v4_ == _other.address_.v4_;
52         } else if (!is_v4_ && !_other.is_v4_) {
53             return address_.v6_ == _other.address_.v6_;
54         } else {
55             return false;
56         }
57     }
58 
operator !=vsomeip::ip_address_t59     bool operator!=(const ip_address_t& _other) const {
60         return !(*this == _other);
61     }
62 
63 };
64 typedef std::function<bool(const ip_address_t&)> offer_acceptance_handler_t;
65 typedef std::function<void(const ip_address_t&)> reboot_notification_handler_t;
66 typedef std::function<void()> routing_ready_handler_t;
67 typedef std::function<void(routing_state_e)> routing_state_handler_t;
68 typedef std::function<void(security_update_state_e)> security_update_handler_t;
69 
70 } // namespace vsomeip
71 
72 #endif // VSOMEIP_HANDLER_HPP
73