MotionLib  1.0.0
SamBuCa motion library
PlatformBase.hpp
1 /*
2  * Copyright (C) 2021 CERN
3  *
4  * This software is provided 'as-is', without any express or implied
5  * warranty. In no event will the authors be held liable for any damages
6  * arising from the use of this software.
7  *
8  * Permission is granted to anyone to use this software for any purpose,
9  * including commercial applications, and to alter it and redistribute it
10  * freely, subject to the following restrictions:
11  *
12  * 1. The origin of this software must not be misrepresented; you must not
13  * claim that you wrote the original software. If you use this software
14  * in a product, an acknowledgment in the product documentation would be
15  * appreciated but is not required.
16  * 2. Altered source versions must be plainly marked as such, and must not be
17  * misrepresented as being the original software.
18  * 3. This notice may not be removed or altered from any source distribution.
19  *
20  * Created on: 2021-10-29
21  * Author: Michal Mysior <mmysior> <michal.mysior@cern.ch>
22  *
23  */
24 
25 #ifndef PLATFORM_BASE_HPP__
26 #define PLATFORM_BASE_HPP__
27 
28 #include <list>
29 #include <set>
30 
31 #include "NotificationWorker.hpp"
32 #include "device/DeviceBase.hpp"
33 
34 namespace smc {
35 namespace internal {
36 
37 class NotificationWorker;
38 
47 class PlatformBase : public std::enable_shared_from_this<PlatformBase>
48 {
49 public:
50  typedef std::shared_ptr<PlatformBase> Shared;
51  typedef std::set<DeviceBase::DeviceType> DeviceTypeList;
52  typedef std::list<DeviceBase::Shared> DeviceList;
53 
54  virtual ~PlatformBase() = default;
55 
56  virtual DeviceTypeList getSupportedDevices() const = 0;
57 
58  virtual DeviceList generateDevices(const DeviceTypeList &deviceTypes) = 0;
59 
60  virtual void stop();
61 
62  virtual void setNotificationWorker(const NotificationWorker::Shared &worker);
63 
64  void notify(const DeviceId &id);
65  void notify(std::set<DeviceId> &&ids);
66 
67 protected:
68  std::weak_ptr<NotificationWorker> m_notificationWorker;
69 };
70 
74 } /* namespace internal */
75 } /* namespace smc */
76 
77 #endif /* PLATFORM_BASE_HPP__ */
main motion-lib namespace
Definition: Client.cpp:30