// Copyright (C) 2014-2017 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/. #ifndef VSOMEIP_V3_ENDPOINT_IMPL_HPP_ #define VSOMEIP_V3_ENDPOINT_IMPL_HPP_ #include #include #include #include #include #include #include "buffer.hpp" #include "endpoint.hpp" #include "../../configuration/include/configuration.hpp" namespace vsomeip_v3 { class endpoint_host; class routing_host; template class endpoint_impl: public virtual endpoint { public: typedef typename Protocol::endpoint endpoint_type; endpoint_impl(const std::shared_ptr& _endpoint_host, const std::shared_ptr& _routing_host, const endpoint_type& _local, boost::asio::io_service &_io, std::uint32_t _max_message_size, configuration::endpoint_queue_limit_t _queue_limit, const std::shared_ptr& _configuration); virtual ~endpoint_impl(); void enable_magic_cookies(); void add_default_target(service_t, const std::string &, uint16_t); void remove_default_target(service_t); virtual std::uint16_t get_local_port() const = 0; virtual void set_local_port(uint16_t _port) = 0; virtual bool is_reliable() const = 0; void increment_use_count(); void decrement_use_count(); uint32_t get_use_count(); void register_error_handler(error_handler_t _error_handler); virtual void print_status() = 0; virtual size_t get_queue_size() const = 0; public: // required virtual bool is_client() const = 0; virtual void receive() = 0; virtual void restart(bool _force) = 0; protected: uint32_t find_magic_cookie(byte_t *_buffer, size_t _size); protected: enum class cms_ret_e : uint8_t { MSG_TOO_BIG, MSG_OK, MSG_WAS_SPLIT }; // Reference to service context boost::asio::io_service &service_; // References to hosts std::weak_ptr endpoint_host_; std::weak_ptr routing_host_; bool is_supporting_magic_cookies_; std::atomic has_enabled_magic_cookies_; // Filter configuration std::map opened_; std::uint32_t max_message_size_; std::atomic use_count_; std::atomic sending_blocked_; std::mutex local_mutex_; endpoint_type local_; error_handler_t error_handler_; std::mutex error_handler_mutex_; const configuration::endpoint_queue_limit_t queue_limit_; std::shared_ptr configuration_; bool is_supporting_someip_tp_; }; } // namespace vsomeip_v3 #endif // VSOMEIP_V3_ENDPOINT_IMPL_HPP_