ubuntu-location-service  0.0.2
interface.h
1 /*
2  * Copyright © 2012-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 LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_INTERFACE_H_
19 #define LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_INTERFACE_H_
20 
21 #include "com/ubuntu/location/service/session/interface.h"
22 
23 #include <org/freedesktop/dbus/service.h>
24 #include <org/freedesktop/dbus/traits/service.h>
25 #include <org/freedesktop/dbus/types/object_path.h>
26 
27 #include <chrono>
28 #include <functional>
29 
30 namespace dbus = org::freedesktop::dbus;
31 
32 namespace com
33 {
34 namespace ubuntu
35 {
36 namespace location
37 {
38 
39 struct Criteria;
40 
41 namespace service
42 {
43 class Interface
44 {
45  protected:
46  struct Errors
47  {
48  struct InsufficientPermissions { inline static std::string name() { return "com.ubuntu.location.Service.Error.InsufficientPermissions"; } };
49  struct CreatingSession { inline static std::string name() { return "com.ubuntu.location.Service.Error.CreatingSession"; } };
50  };
51 
53  {
55 
56  inline static const std::string& name()
57  {
58  static const std::string s
59  {
60  "CreateSessionForCriteria"
61  };
62  return s;
63  }
64 
65  typedef dbus::types::ObjectPath ResultType;
66 
67  inline static const std::chrono::milliseconds default_timeout() { return std::chrono::seconds{1}; }
68  };
69 
70  Interface() = default;
71 
72  public:
73  typedef std::shared_ptr<Interface> Ptr;
74 
75  inline static const std::string& path()
76  {
77  static const std::string s{"/com/ubuntu/location/Service"};
78  return s;
79  }
80 
81  Interface(const Interface&) = delete;
82  Interface& operator=(const Interface&) = delete;
83  virtual ~Interface() = default;
84 
85  virtual session::Interface::Ptr create_session_for_criteria(const Criteria& criteria) = 0;
86 };
87 }
88 }
89 }
90 }
91 
92 namespace org
93 {
94 namespace freedesktop
95 {
96 namespace dbus
97 {
98 namespace traits
99 {
100 template<>
101 struct Service<com::ubuntu::location::service::Interface>
102 {
103  static const std::string& interface_name()
104  {
105  static const std::string s
106  {
107  "com.ubuntu.location.Service"
108  };
109  return s;
110  }
111 };
112 }
113 }
114 }
115 }
116 
117 #include "com/ubuntu/location/codec.h"
118 
119 #endif // LOCATION_SERVICE_COM_UBUNTU_LOCATION_SERVICE_INTERFACE_H_