1 // Copyright (C) 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_CHANNEL_IMPL_HPP_ 7 #define VSOMEIP_V3_TRACE_CHANNEL_IMPL_HPP_ 8 9 #include <atomic> 10 #include <functional> 11 #include <map> 12 #include <mutex> 13 #include <string> 14 15 #include <vsomeip/trace.hpp> 16 17 namespace vsomeip_v3 { 18 namespace trace { 19 20 typedef std::function<bool (service_t, instance_t, method_t)> filter_func_t; 21 22 class channel_impl : public channel { 23 public: 24 channel_impl(const std::string &_id, const std::string &_name); 25 26 std::string get_id() const; 27 std::string get_name() const; 28 29 filter_id_t add_filter( 30 const match_t &_match, 31 bool _is_positive); 32 33 filter_id_t add_filter( 34 const std::vector<match_t> &_matches, 35 bool _is_positive); 36 37 filter_id_t add_filter( 38 const match_t &_from, const match_t &_to, 39 bool _is_positive); 40 41 void remove_filter( 42 filter_id_t _id); 43 44 bool matches(service_t _service, instance_t _instance, method_t _method); 45 46 private: 47 filter_id_t add_filter_intern(const filter_func_t& _func, bool _is_positive); 48 49 std::string id_; 50 std::string name_; 51 52 std::atomic<filter_id_t> current_filter_id_; 53 54 std::map<filter_id_t, filter_func_t> positive_; 55 std::map<filter_id_t, filter_func_t> negative_; 56 std::mutex mutex_; // protects positive_ & negative_ 57 }; 58 59 } // namespace trace 60 } // namespace vsomeip_v3 61 62 #endif // VSOMEIP_V3_TRACE_CHANNEL_IMPL_HPP_ 63