summaryrefslogtreecommitdiff
path: root/implementation/tracing/include/channel_impl.hpp
diff options
context:
space:
mode:
Diffstat (limited to 'implementation/tracing/include/channel_impl.hpp')
-rw-r--r--implementation/tracing/include/channel_impl.hpp62
1 files changed, 62 insertions, 0 deletions
diff --git a/implementation/tracing/include/channel_impl.hpp b/implementation/tracing/include/channel_impl.hpp
new file mode 100644
index 0000000..9034657
--- /dev/null
+++ b/implementation/tracing/include/channel_impl.hpp
@@ -0,0 +1,62 @@
+// Copyright (C) 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_TRACING_CHANNEL_IMPL_HPP_
+#define VSOMEIP_TRACING_CHANNEL_IMPL_HPP_
+
+#include <atomic>
+#include <functional>
+#include <map>
+#include <mutex>
+#include <string>
+
+#include <vsomeip/trace.hpp>
+
+namespace vsomeip {
+namespace trace {
+
+typedef std::function<bool (service_t, instance_t, method_t)> filter_func_t;
+
+class channel_impl : public channel {
+public:
+ channel_impl(const std::string &_id, const std::string &_name);
+
+ std::string get_id() const;
+ std::string get_name() const;
+
+ filter_id_t add_filter(
+ const match_t &_match,
+ bool _is_positive);
+
+ filter_id_t add_filter(
+ const std::vector<match_t> &_matches,
+ bool _is_positive);
+
+ filter_id_t add_filter(
+ const match_t &_from, const match_t &_to,
+ bool _is_positive);
+
+ void remove_filter(
+ filter_id_t _id);
+
+ bool matches(service_t _service, instance_t _instance, method_t _method);
+
+private:
+ filter_id_t add_filter_intern(filter_func_t _func, bool _is_positive);
+
+ std::string id_;
+ std::string name_;
+
+ std::atomic<filter_id_t> current_filter_id_;
+
+ std::map<filter_id_t, filter_func_t> positive_;
+ std::map<filter_id_t, filter_func_t> negative_;
+ std::mutex mutex_; // protects positive_ & negative_
+};
+
+} // namespace trace
+} // namespace vsomeip
+
+#endif // VSOMEIP_TRACING_CHANNEL_IMPL_HPP_