~thomas-voss/dbus-cpp/force_gcc_4.7_and_symbols

« back to all changes in this revision

Viewing changes to include/core/dbus/service_watcher.h

  • Committer: Tarmac
  • Author(s): Pete Woods
  • Date: 2014-02-03 12:21:44 UTC
  • mfrom: (24.3.36 trunk)
  • Revision ID: tarmac-20140203122144-u15nf8142o7cplj3
Add service watcher class to allow watching DBus name ownership changes.

Approved by PS Jenkins bot, Thomas Voß.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright © 2014 Canonical Ltd.
 
3
 *
 
4
 * This program is free software: you can redistribute it and/or modify it
 
5
 * under the terms of the GNU Lesser General Public License version 3,
 
6
 * as published by the Free Software Foundation.
 
7
 *
 
8
 * This program is distributed in the hope that it will be useful,
 
9
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
10
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
11
 * GNU Lesser General Public License for more details.
 
12
 *
 
13
 * You should have received a copy of the GNU Lesser General Public License
 
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
15
 *
 
16
 * Authored by: Pete Woods <pete.woods@canonical.com>
 
17
 */
 
18
#ifndef CORE_DBUS_SERVICE_WATCHER_H_
 
19
#define CORE_DBUS_SERVICE_WATCHER_H_
 
20
 
 
21
#include <core/signal.h>
 
22
#include <core/dbus/dbus.h>
 
23
#include <core/dbus/visibility.h>
 
24
 
 
25
#include <memory>
 
26
#include <string>
 
27
 
 
28
namespace core
 
29
{
 
30
namespace dbus
 
31
{
 
32
class Object;
 
33
 
 
34
/**
 
35
 * @brief Allows watching for bus name owner changes.
 
36
 */
 
37
class ORG_FREEDESKTOP_DBUS_DLL_PUBLIC ServiceWatcher
 
38
{
 
39
friend DBus;
 
40
public:
 
41
    typedef std::shared_ptr<ServiceWatcher> Ptr;
 
42
 
 
43
    ServiceWatcher(const ServiceWatcher& rhs) = delete;
 
44
    ServiceWatcher& operator=(const ServiceWatcher& rhs) = delete;
 
45
    bool operator==(const ServiceWatcher&) const = delete;
 
46
 
 
47
    /**
 
48
     * @brief Emitted when DBus detects that an owner change has occurred for the specified name.
 
49
     * @return Signal instance
 
50
     */
 
51
    const core::Signal<std::string, std::string>& owner_changed() const;
 
52
 
 
53
    /**
 
54
     * @brief Emitted when DBus detects that an owner has been registered for the specified name.
 
55
     * @return Signal instance
 
56
     */
 
57
    const core::Signal<void>& service_registered() const;
 
58
 
 
59
    /**
 
60
     * @brief Emitted when DBus detects that an owner has been unregistered for the specified name.
 
61
     * @return Signal instance
 
62
     */
 
63
    const core::Signal<void>& service_unregistered() const;
 
64
 
 
65
private:
 
66
    ServiceWatcher(std::shared_ptr<Object> object, const std::string& name,
 
67
                DBus::WatchMode watch_mode = DBus::WatchMode::owner_change);
 
68
 
 
69
    struct Private;
 
70
    std::shared_ptr<Private> d;
 
71
};
 
72
}
 
73
}
 
74
 
 
75
#endif // CORE_DBUS_SERVICE_WATCHER_H_