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 
12 #include "dateSourceTypes.h"
13 
14 class RtcClient;
20 namespace dpyRtc {
21 
24 {
25  std::uint32_t sync_time_seconds;
26  std::uint32_t max_diff_time_seconds;
27 };
28 
33 typedef boost::function<void(const bool &available)> service_availability_handler;
34 
39 typedef boost::function<void(boost::system::error_code& ec)> result_handler;
40 
46 typedef boost::function<void(boost::system::error_code& ec, dpyRtc::ParamConfig &)> params_handler;
47 
54 typedef boost::function<void(boost::system::error_code& ec, struct tm date_and_time)> time_and_date_handler;
55 
62 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;
63 
69 typedef boost::function<void(boost::system::error_code& ec, std::map<std::string, dpyRtc::DateSources> sourceList)> sources_list_handler;
70 }
71 
77 class Rtc
78 {
79 private:
80  boost::shared_ptr<RtcClient> mClient;
81 public:
82 
87  explicit Rtc(std::string ip = "127.0.0.1");
88 
92  ~Rtc();
93  bool isAlive();
94  void monitorServiceAvailability_S(dpyRtc::service_availability_handler handler);
95  void monitorServiceAvailability_U();
101  void asyncSetSyncTime(std::uint32_t time_s, dpyRtc::result_handler handler);
102 
108  void asyncSetDiffTime(std::uint32_t time_s, dpyRtc::result_handler handler);
109 
114  void asyncGetConfigValues(dpyRtc::params_handler handler);
115 
121  void asyncGetDateTime(dpyRtc::time_and_date_handler handler);
122 
127  void asyncGetDateTime(dpyRtc::time_date_set_handler handler);
128 
133  void asyncGetSources(dpyRtc::sources_list_handler handler);
134 
146  boost::system::error_code getDateTime(struct tm & date_and_time);
147 
159  boost::system::error_code getDateTime(struct tm & date_and_time,struct tm &last_set_date_and_time );
160 
167  void asyncAddNewSourceDate(const std::string& source_name, const dpyRtc::DateSources& source, dpyRtc::result_handler handler);
168 
174  void asyncDeleteSourceDate(const std::string& source_name, dpyRtc::result_handler handler);
175 
182  boost::system::error_code addNewSourceDate(const std::string& source_name, const dpyRtc::DateSources& source);
183 
189  boost::system::error_code deleteSourceDate(const std::string& source_name);
190 };
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:26
boost::function< void(const bool &available)> service_availability_handler
Prototype of the handler function used to monitor service availability.
Definition: rtcApi.h:33
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:54
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:62
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:46
std::uint32_t sync_time_seconds
Synchronism time period in seconds.
Definition: rtcApi.h:25
Parameters struct which contains the response received from the service.
Definition: rtcApi.h:23
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:39
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:69
Deepsy Rtc namespace that includes the different enums, structs or method signatures that should be u...
Definition: rtcApi.h:14
Allows to interact with a RTC Service.
Definition: rtcApi.h:77