rtcApi.h
Go to the documentation of this file.
1 
6 #pragma once
7 
8 #include <boost/function.hpp>
9 #include <boost/system/error_code.hpp>
10 #include <boost/shared_ptr.hpp>
11 #include <map>
12 
13 #include "dateSourceTypes.h"
14 
15 class RtcClient;
21 namespace dpyRtc {
22 
25 {
26  std::uint32_t sync_time_seconds;
27  std::uint32_t max_diff_time_seconds;
28 };
29 
34 typedef boost::function<void(const bool &available)> service_availability_handler;
35 
40 typedef boost::function<void(boost::system::error_code& ec)> result_handler;
41 
47 typedef boost::function<void(boost::system::error_code& ec, dpyRtc::ParamConfig &)> params_handler;
48 
55 typedef boost::function<void(boost::system::error_code& ec, struct tm date_and_time)> time_and_date_handler;
56 
63 typedef boost::function<void(boost::system::error_code& ec, struct tm date_and_time,struct tm last_set_date_and_time)> time_date_set_handler;
64 
70 typedef boost::function<void(boost::system::error_code& ec, std::map<std::string, dpyRtc::DateSources> sourceList)> sources_list_handler;
71 }
72 
78 class Rtc
79 {
80 private:
81  boost::shared_ptr<RtcClient> mClient;
82 public:
83 
88  explicit Rtc(std::string ip = "127.0.0.1");
89 
93  ~Rtc();
94  bool isAlive();
95  void monitorServiceAvailability_S(dpyRtc::service_availability_handler handler);
96  void monitorServiceAvailability_U();
102  void asyncSetSyncTime(std::uint32_t time_s, dpyRtc::result_handler handler);
103 
109  void asyncSetDiffTime(std::uint32_t time_s, dpyRtc::result_handler handler);
110 
115  void asyncGetConfigValues(dpyRtc::params_handler handler);
116 
122  void asyncGetDateTime(dpyRtc::time_and_date_handler handler);
123 
128  void asyncGetDateTime(dpyRtc::time_date_set_handler handler);
129 
134  void asyncGetSources(dpyRtc::sources_list_handler handler);
135 
147  boost::system::error_code getDateTime(struct tm & date_and_time);
148 
160  boost::system::error_code getDateTime(struct tm & date_and_time,struct tm &last_set_date_and_time );
161 
168  void asyncAddNewSourceDate(const std::string& source_name, const dpyRtc::DateSources& source, dpyRtc::result_handler handler);
169 
175  void asyncDeleteSourceDate(const std::string& source_name, dpyRtc::result_handler handler);
176 
183  boost::system::error_code addNewSourceDate(const std::string& source_name, const dpyRtc::DateSources& source);
184 
190  boost::system::error_code deleteSourceDate(const std::string& source_name);
191 };
Interacts with RTC service.
Definition: rtcClient.h:16
Definition: dateSourceTypes.h:28
std::uint32_t max_diff_time_seconds
Maximum time in seconds allowed to RTC to be drifted from UTC valid time.
Definition: rtcApi.h:27
boost::function< void(const bool &available)> service_availability_handler
Prototype of the handler function used to monitor service availability.
Definition: rtcApi.h:34
boost::function< void(boost::system::error_code &ec, struct tm date_and_time)> time_and_date_handler
Handler for result function callback. This type of function is called when the status callback is don...
Definition: rtcApi.h:55
boost::function< void(boost::system::error_code &ec, struct tm date_and_time, struct tm last_set_date_and_time)> time_date_set_handler
Handler for result function callback. This type of function is called when the status callback is don...
Definition: rtcApi.h:63
boost::function< void(boost::system::error_code &ec, dpyRtc::ParamConfig &)> params_handler
Handler for result function callback. This type of function is called when the status callback is don...
Definition: rtcApi.h:47
std::uint32_t sync_time_seconds
Synchronism time period in seconds.
Definition: rtcApi.h:26
Parameters struct which contains the response received from the service.
Definition: rtcApi.h:24
boost::function< void(boost::system::error_code &ec)> result_handler
Handler for result function callback. This type of function is called when the status callback is don...
Definition: rtcApi.h:40
boost::function< void(boost::system::error_code &ec, std::map< std::string, dpyRtc::DateSources > sourceList)> sources_list_handler
Prototype of the handler function for getting sources list.
Definition: rtcApi.h:70
Deepsy Rtc namespace that includes the different enums, structs or method signatures that should be u...
Definition: rtcApi.h:15
Allows to interact with a RTC Service.
Definition: rtcApi.h:78