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_TRACE_CONNECTOR_HPP_ 7 #define VSOMEIP_V3_TRACE_CONNECTOR_HPP_ 8 9 #ifdef USE_DLT 10 #include <dlt/dlt.h> 11 #endif 12 13 #include <mutex> 14 #include <vector> 15 #include <map> 16 17 #include <boost/shared_ptr.hpp> 18 19 #include <vsomeip/primitive_types.hpp> 20 #include <vsomeip/export.hpp> 21 #include <vsomeip/trace.hpp> 22 23 #include "enumeration_types.hpp" 24 #include "header.hpp" 25 #include "../../endpoints/include/buffer.hpp" 26 27 namespace vsomeip_v3 { 28 29 namespace cfg { 30 struct trace; 31 } 32 33 namespace trace { 34 35 class channel_impl; 36 37 class connector_impl : public connector { 38 public: 39 VSOMEIP_EXPORT static std::shared_ptr<connector_impl> get(); 40 41 VSOMEIP_EXPORT connector_impl(); 42 VSOMEIP_EXPORT virtual ~connector_impl(); 43 44 VSOMEIP_EXPORT void configure(const std::shared_ptr<cfg::trace> &_configuration); 45 VSOMEIP_EXPORT void reset(); 46 47 VSOMEIP_EXPORT void set_enabled(const bool _enabled); 48 VSOMEIP_EXPORT bool is_enabled() const; 49 50 VSOMEIP_EXPORT void set_sd_enabled(const bool _sd_enabled); 51 VSOMEIP_EXPORT bool is_sd_enabled() const; 52 53 VSOMEIP_EXPORT bool is_sd_message(const byte_t *_data, uint16_t _data_size) const; 54 55 VSOMEIP_EXPORT std::shared_ptr<channel> add_channel(const std::string &_id, 56 const std::string &_description); 57 VSOMEIP_EXPORT bool remove_channel(const std::string &_id); 58 VSOMEIP_EXPORT std::shared_ptr<channel> get_channel(const std::string &_id) const; 59 60 VSOMEIP_EXPORT void trace(const byte_t *_header, uint16_t _header_size, 61 const byte_t *_data, uint16_t _data_size); 62 63 private: 64 bool is_enabled_; 65 bool is_sd_enabled_; 66 67 std::map<std::string, std::shared_ptr<channel_impl>> channels_; 68 mutable std::mutex channels_mutex_; 69 70 #ifdef USE_DLT 71 std::map<std::string, std::shared_ptr<DltContext>> contexts_; 72 mutable std::mutex contexts_mutex_; 73 #endif 74 75 }; 76 77 } // namespace trace 78 } // namespace vsomeip_v3 79 80 #endif // VSOMEIP_TC_TRACE_CONNECTOR_HPP 81