Ed Tanous | c9b5521 | 2017-06-12 13:25:51 -0700 | [diff] [blame] | 1 | // Copyright (c) Benjamin Kietzman (github.com/bkietz) |
| 2 | // |
| 3 | // Distributed under the Boost Software License, Version 1.0. (See accompanying |
| 4 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
| 5 | |
| 6 | #ifndef DBUS_MATCH_HPP |
| 7 | #define DBUS_MATCH_HPP |
| 8 | |
| 9 | #include <string> |
| 10 | #include <boost/asio.hpp> |
| 11 | |
| 12 | #include <dbus/connection.hpp> |
| 13 | #include <dbus/error.hpp> |
| 14 | |
| 15 | namespace dbus { |
| 16 | |
| 17 | /// Simple placeholder object for a match rule. |
| 18 | /** |
| 19 | * A match rule determines what messages will be received by this application. |
| 20 | * |
| 21 | * Each rule will be represented by an instance of match. To remove that rule, |
| 22 | * dispose of the object. |
| 23 | */ |
| 24 | class match { |
Ed Tanous | 5fceeb4 | 2017-06-28 09:43:09 -0700 | [diff] [blame^] | 25 | connection_ptr connection_; |
Ed Tanous | c9b5521 | 2017-06-12 13:25:51 -0700 | [diff] [blame] | 26 | std::string expression_; |
| 27 | |
| 28 | public: |
Ed Tanous | 5fceeb4 | 2017-06-28 09:43:09 -0700 | [diff] [blame^] | 29 | match(connection_ptr c, BOOST_ASIO_MOVE_ARG(std::string) e) |
Ed Tanous | c9b5521 | 2017-06-12 13:25:51 -0700 | [diff] [blame] | 30 | : connection_(c), expression_(BOOST_ASIO_MOVE_CAST(std::string)(e)) { |
Ed Tanous | 5fceeb4 | 2017-06-28 09:43:09 -0700 | [diff] [blame^] | 31 | connection_->new_match(*this); |
Ed Tanous | c9b5521 | 2017-06-12 13:25:51 -0700 | [diff] [blame] | 32 | } |
| 33 | |
Ed Tanous | 5fceeb4 | 2017-06-28 09:43:09 -0700 | [diff] [blame^] | 34 | ~match() { connection_->delete_match(*this); } |
Ed Tanous | c9b5521 | 2017-06-12 13:25:51 -0700 | [diff] [blame] | 35 | |
| 36 | const std::string& get_expression() const { return expression_; } |
| 37 | |
| 38 | match(match&&) = delete; |
| 39 | match& operator=(match&&) = delete; |
| 40 | }; |
| 41 | |
| 42 | } // namespace dbus |
| 43 | |
| 44 | #include <dbus/impl/match.ipp> |
| 45 | |
| 46 | #endif // DBUS_MATCH_HPP |