connectivity-cpp  0.0.1
service.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  * Authors:
17  * Antti Kaijanmäki <antti.kaijanmaki@canonical.com>
18  */
19 
20 #ifndef COM_UBUNTU_CONNECTIVITY_NETWORKING_SERVICE
21 #define COM_UBUNTU_CONNECTIVITY_NETWORKING_SERVICE
22 
24 
25 #include <memory>
26 
27 namespace com {
28 namespace ubuntu {
29 namespace connectivity {
30 namespace networking {
31 
32 #ifndef CONNECTIVITY_CPP_EXPORT
33 #define CONNECTIVITY_CPP_EXPORT __attribute ((visibility ("default")))
34 #endif
35 
38 Service
39 {
40 public:
41 
42  typedef std::shared_ptr<Service> Ptr;
43 
44  enum class Type {
45  vpn,
46  tethering,
47  tor
48  };
49  virtual Type type() const = 0;
50 
51  enum class Status {
52  stopped,
53  starting,
54  running
55  };
56  virtual const core::Property<Status>& status() = 0;
57 
58  // which other Service this service requires to be active
59  // before it can be activated
60  virtual std::shared_ptr<Service> requires() = 0;
61 
62  // possible link this service provides.
63  // check with:
64  // if (service->link()) {
65  // // we have a link coming from the service
66  // do_something_with(link);
67  // }
68  virtual Link::Ptr link() = 0;
69 
70  virtual void start() = 0;
71  virtual void stop() = 0;
72 
73  typedef unsigned int Id;
74  virtual Id id() const = 0;
75 
76  virtual core::Property<std::string>& name() = 0;
77 };
78 
79 }
80 }
81 }
82 }
83 #endif
#define CONNECTIVITY_CPP_EXPORT
Definition: service.h:33