TwirreLink
 All Classes Functions Pages
DeviceProvider.h
1 /*
2  * Twirre: architecture for autonomous UAVs using interchangeable commodity components
3  *
4  * Copyright© 2017 Centre of expertise in Computer Vision & Data Science, NHL Stenden University of applied sciences
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
7  *
8  * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
9  *
10  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
11  */
12 
13 #ifndef DEVICEPROVIDER_H_
14 #define DEVICEPROVIDER_H_
15 
16 #include <map>
17 #include <set>
18 
19 #include "Core/Actuator.h"
20 #include "Core/Sensor.h"
21 #include "Core/Value.h"
22 #include "Logger/TwirreLogger.h"
23 
24 namespace twirre
25 {
26  class TwirreLink;
27 
34  {
35  friend class TwirreLink;
36  public:
41  virtual ~DeviceProvider();
47  virtual void addActuator(Actuator * a);
53  virtual void addSensor(Sensor * s);
59  virtual const std::map<std::string, Actuator*> & getActuators();
65  virtual const std::map<std::string, Sensor*> & getSensors();
66  protected:
70  void doNotifyChange();
71 
72  void addLogger(TwirreLogger * log);
73  void removeLogger(TwirreLogger * log);
74  std::map<std::string, Sensor*> _sensors;
75  std::map<std::string, Actuator*> _actuators;
76  private:
77  void sensorLoggerCallback(Sensor * sensor, std::map<std::string, Value*>& sensorValues);
78  void actuatorLoggerCallback(Actuator * actuators, std::map<std::string, Parameter*>& actuatorParameters);
79  std::set<TwirreLogger *> _loggers;
80  std::set<TwirreLink *> _links;
81  void addLink(TwirreLink * link);
82  void removeLink(TwirreLink * link);
83  };
84 
85 } /* namespace twirre */
86 
87 #endif /* DEVICEPROVIDER_H_ */
DeviceProvider()
Default empty constructor.
Definition: DeviceProvider.h:40
void doNotifyChange()
Notifies all connected instances of TwirreLink that they should update, because a change (added/remov...
Definition: DeviceProvider.cpp:56
virtual const std::map< std::string, Sensor * > & getSensors()
Get all available sensors.
Definition: DeviceProvider.cpp:46
Definition: TwirreLogger.h:31
Definition: Sensor.h:22
virtual const std::map< std::string, Actuator * > & getActuators()
Get all available actuators.
Definition: DeviceProvider.cpp:51
virtual void addActuator(Actuator *a)
Add an Actuator to this provider.
Definition: DeviceProvider.cpp:40
A DeviceProvider is a collection of Actuators and Sensors which can be connected to a TwirreLink inst...
Definition: DeviceProvider.h:33
virtual void addSensor(Sensor *s)
Add a Sensor to this provider.
Definition: DeviceProvider.cpp:34
Actuator is the base class for all 'actuator'-type devices.
Definition: Actuator.h:41