Music Hub  ..
A session-wide music playback service
 All Classes Namespaces Files Functions Typedefs Enumerations Enumerator Friends
connection.h
Go to the documentation of this file.
1 /*
2  * Copyright © 2013 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: Thomas Voß <thomas.voss@canonical.com>
17  */
18 #ifndef COM_UBUNTU_MUSIC_CONNECTION_H_
19 #define COM_UBUNTU_MUSIC_CONNECTION_H_
20 
21 #include <functional>
22 #include <memory>
23 
24 namespace com
25 {
26 namespace ubuntu
27 {
28 namespace music
29 {
31 {
32  private:
33  struct Private;
34 
35  public:
36  Connection(const std::shared_ptr<Private>& d);
37  Connection(const Connection& rhs);
38  ~Connection();
39 
40  Connection& operator=(const Connection& rhs);
41  bool operator==(const Connection& rhs) const;
42 
43  bool is_connected() const;
44  void disconnect();
45 
46  private:
47  std::shared_ptr<Private> d;
48 };
49 
51 {
52  public:
53  ScopedConnection(const Connection& c) : connection(c)
54  {
55  }
56 
57  ScopedConnection(const ScopedConnection&) = delete;
58 
60  {
61  connection.disconnect();
62  }
63 
65  bool operator==(const ScopedConnection&) = delete;
66 
67  private:
68  Connection connection;
69 };
70 
71 }
72 }
73 }
74 
75 #endif // COM_UBUNTU_MUSIC_CONNECTION_H_