healthApi.h
Go to the documentation of this file.
1 
3 #pragma once
4 
8 #include <boost/function.hpp>
9 #include <boost/system/error_code.hpp>
10 #include <boost/shared_ptr.hpp>
11 #include <vector>
12 #include "healthTypes.h"
13 
14 class HealthClient;
15 
21 namespace dpyHealth {
22 
28 {
29 
30 public:
35  virtual void updateAvailability(const bool &available) = 0;
36 
41  {
42  }
43 };
44 
52 typedef boost::function<void(boost::system::error_code &ec)> handler_function;
53 
59 typedef boost::function<void(boost::system::error_code error_code, std::vector<dpyHealth::Status>&)> status_handler_function;
60 
66 typedef boost::function<void(boost::system::error_code error_code, std::vector<dpyHealth::DeviceInformation>&)> device_handler_function;
67 
68 } //dpyHealth
69 
70 //Note that the HEALTHApiCPP group must be defined in the general documentation
76 class Health
77 {
78 
79 private:
80  boost::shared_ptr<HealthClient> mClient;
81  std::vector<dpyHealth::ServiceAvailabilityObserver*> mAvailObserverList;
82 public:
83 
84  explicit Health(std::string ip = "127.0.0.1");
85  ~Health();
86 
87  bool isAlive();
88  boost::system::error_code monitorServiceAvailability_S(dpyHealth::ServiceAvailabilityObserver *observer);
89  boost::system::error_code monitorServiceAvailability_U(dpyHealth::ServiceAvailabilityObserver *observer);
90  void asyncGetCurrentStatusList(dpyHealth::status_handler_function handler);
91  void asyncGetPendingStatusList(dpyHealth::status_handler_function handler);
92  void asyncGetDevicesList(dpyHealth::device_handler_function handler);
93 
94  void asyncReportNewStatus(dpyHealth::handler_function handler, std::string key, std::string value, dpyHealth::Priority priority);
95  boost::system::error_code reportNewStatus(std::string key, std::string value, dpyHealth::Priority priority);
96 
97 };
virtual ~ServiceAvailabilityObserver()
Destructor.
Definition: healthApi.h:40
Priority
Priority of the message.
Definition: healthTypes.h:20
boost::function< void(boost::system::error_code error_code, std::vector< dpyHealth::Status > &)> status_handler_function
Handler for getStatusList function callback.
Definition: healthApi.h:59
Service Availability observer class.
Definition: healthApi.h:27
virtual void updateAvailability(const bool &available)=0
Method called when service availability changes.
boost::function< void(boost::system::error_code &ec)> handler_function
Handler for status function callback.
Definition: healthApi.h:52
Deepsy HEALTH namespace that includes the different enums, structs or method signatures that should b...
Definition: healthTypes.h:17
boost::function< void(boost::system::error_code error_code, std::vector< dpyHealth::DeviceInformation > &)> device_handler_function
Handler for getDeviceList function callback.
Definition: healthApi.h:66
Allows to interact with a Health service.
Definition: healthApi.h:76
Interacts with Health service.
Definition: healthClient.h:12