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_ENDPOINT_DEFINITION_HPP_ 7 #define VSOMEIP_V3_ENDPOINT_DEFINITION_HPP_ 8 9 #include <map> 10 #include <memory> 11 #include <atomic> 12 #include <mutex> 13 14 #include <boost/asio/ip/address.hpp> 15 #include <vsomeip/primitive_types.hpp> 16 17 #include <vsomeip/export.hpp> 18 19 namespace vsomeip_v3 { 20 21 class endpoint_definition { 22 public: 23 VSOMEIP_EXPORT static std::shared_ptr<endpoint_definition> get( 24 const boost::asio::ip::address &_address, 25 uint16_t _port, bool _is_reliable, service_t _service, instance_t _instance); 26 27 VSOMEIP_EXPORT const boost::asio::ip::address &get_address() const; 28 29 VSOMEIP_EXPORT uint16_t get_port() const; 30 31 VSOMEIP_EXPORT uint16_t get_remote_port() const; 32 VSOMEIP_EXPORT void set_remote_port(uint16_t _port); 33 34 VSOMEIP_EXPORT bool is_reliable() const; 35 36 VSOMEIP_EXPORT endpoint_definition( 37 const boost::asio::ip::address &_address, 38 uint16_t _port, bool _is_reliable); 39 private: 40 boost::asio::ip::address address_; 41 uint16_t port_; 42 std::atomic<uint16_t> remote_port_; 43 bool is_reliable_; 44 45 static std::mutex definitions_mutex_; 46 static std::map< 47 std::tuple<service_t, instance_t, boost::asio::ip::address, uint16_t, bool>, 48 std::shared_ptr<endpoint_definition> > definitions_; 49 }; 50 51 } // namespace vsomeip_v3 52 53 #endif // VSOMEIP_V3_ENDPOINT_DEFINITION_HPP_ 54