yocto_realtimeclock.h
Go to the documentation of this file.
1 /*********************************************************************
2  *
3  * $Id: yocto_realtimeclock.h 28748 2017-10-03 08:23:39Z seb $
4  *
5  * Declares yFindRealTimeClock(), the high-level API for RealTimeClock functions
6  *
7  * - - - - - - - - - License information: - - - - - - - - -
8  *
9  * Copyright (C) 2011 and beyond by Yoctopuce Sarl, Switzerland.
10  *
11  * Yoctopuce Sarl (hereafter Licensor) grants to you a perpetual
12  * non-exclusive license to use, modify, copy and integrate this
13  * file into your software for the sole purpose of interfacing
14  * with Yoctopuce products.
15  *
16  * You may reproduce and distribute copies of this file in
17  * source or object form, as long as the sole purpose of this
18  * code is to interface with Yoctopuce products. You must retain
19  * this notice in the distributed source file.
20  *
21  * You should refer to Yoctopuce General Terms and Conditions
22  * for additional information regarding your rights and
23  * obligations.
24  *
25  * THE SOFTWARE AND DOCUMENTATION ARE PROVIDED 'AS IS' WITHOUT
26  * WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING
27  * WITHOUT LIMITATION, ANY WARRANTY OF MERCHANTABILITY, FITNESS
28  * FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO
29  * EVENT SHALL LICENSOR BE LIABLE FOR ANY INCIDENTAL, SPECIAL,
30  * INDIRECT OR CONSEQUENTIAL DAMAGES, LOST PROFITS OR LOST DATA,
31  * COST OF PROCUREMENT OF SUBSTITUTE GOODS, TECHNOLOGY OR
32  * SERVICES, ANY CLAIMS BY THIRD PARTIES (INCLUDING BUT NOT
33  * LIMITED TO ANY DEFENSE THEREOF), ANY CLAIMS FOR INDEMNITY OR
34  * CONTRIBUTION, OR OTHER SIMILAR COSTS, WHETHER ASSERTED ON THE
35  * BASIS OF CONTRACT, TORT (INCLUDING NEGLIGENCE), BREACH OF
36  * WARRANTY, OR OTHERWISE.
37  *
38  *********************************************************************/
39 
40 
41 #ifndef YOCTO_REALTIMECLOCK_H
42 #define YOCTO_REALTIMECLOCK_H
43 
44 #include "yocto_api.h"
45 #include <cfloat>
46 #include <cmath>
47 #include <map>
48 
49 //--- (YRealTimeClock return codes)
50 //--- (end of YRealTimeClock return codes)
51 //--- (YRealTimeClock definitions)
52 class YRealTimeClock; // forward declaration
53 
54 typedef void (*YRealTimeClockValueCallback)(YRealTimeClock *func, const string& functionValue);
55 #ifndef _Y_TIMESET_ENUM
56 #define _Y_TIMESET_ENUM
57 typedef enum {
62 #endif
63 #define Y_UNIXTIME_INVALID (YAPI_INVALID_LONG)
64 #define Y_DATETIME_INVALID (YAPI_INVALID_STRING)
65 #define Y_UTCOFFSET_INVALID (YAPI_INVALID_INT)
66 //--- (end of YRealTimeClock definitions)
67 
68 //--- (YRealTimeClock declaration)
78 #ifdef __BORLANDC__
79 #pragma option push -w-8022
80 #endif
81 //--- (end of YRealTimeClock declaration)
82 protected:
83  //--- (YRealTimeClock attributes)
84  // Attributes (function value cache)
85  s64 _unixTime;
86  string _dateTime;
90 
91  friend YRealTimeClock *yFindRealTimeClock(const string& func);
92  friend YRealTimeClock *yFirstRealTimeClock(void);
93 
94  // Function-specific method for parsing of JSON output and caching result
95  virtual int _parseAttr(YJSONObject* json_val);
96 
97  // Constructor is protected, use yFindRealTimeClock factory function to instantiate
98  YRealTimeClock(const string& func);
99  //--- (end of YRealTimeClock attributes)
100 
101 public:
102  ~YRealTimeClock();
103  //--- (YRealTimeClock accessors declaration)
104 
105  static const s64 UNIXTIME_INVALID = YAPI_INVALID_LONG;
106  static const string DATETIME_INVALID;
107  static const int UTCOFFSET_INVALID = YAPI_INVALID_INT;
108  static const Y_TIMESET_enum TIMESET_FALSE = Y_TIMESET_FALSE;
109  static const Y_TIMESET_enum TIMESET_TRUE = Y_TIMESET_TRUE;
110  static const Y_TIMESET_enum TIMESET_INVALID = Y_TIMESET_INVALID;
111 
120  s64 get_unixTime(void);
121 
122  inline s64 unixTime(void)
123  { return this->get_unixTime(); }
124 
134  int set_unixTime(s64 newval);
135  inline int setUnixTime(s64 newval)
136  { return this->set_unixTime(newval); }
137 
145  string get_dateTime(void);
146 
147  inline string dateTime(void)
148  { return this->get_dateTime(); }
149 
157  int get_utcOffset(void);
158 
159  inline int utcOffset(void)
160  { return this->get_utcOffset(); }
161 
172  int set_utcOffset(int newval);
173  inline int setUtcOffset(int newval)
174  { return this->set_utcOffset(newval); }
175 
184  Y_TIMESET_enum get_timeSet(void);
185 
186  inline Y_TIMESET_enum timeSet(void)
187  { return this->get_timeSet(); }
188 
216  static YRealTimeClock* FindRealTimeClock(string func);
217 
231 
232  virtual int _invokeValueCallback(string value);
233 
234 
235  inline static YRealTimeClock* Find(string func)
236  { return YRealTimeClock::FindRealTimeClock(func); }
237 
245  YRealTimeClock *nextRealTimeClock(void);
246  inline YRealTimeClock *next(void)
247  { return this->nextRealTimeClock();}
248 
258  static YRealTimeClock* FirstRealTimeClock(void);
259  inline static YRealTimeClock* First(void)
261 #ifdef __BORLANDC__
262 #pragma option pop
263 #endif
264  //--- (end of YRealTimeClock accessors declaration)
265 };
266 
267 //--- (YRealTimeClock functions declaration)
268 
296 inline YRealTimeClock* yFindRealTimeClock(const string& func)
297 { return YRealTimeClock::FindRealTimeClock(func);}
309 
310 //--- (end of YRealTimeClock functions declaration)
311 
312 #endif
static YRealTimeClock * Find(string func)
Y_TIMESET_enum _timeSet
string dateTime(void)
static YRealTimeClock * FirstRealTimeClock(void)
#define YAPI_INVALID_LONG
Definition: yocto_api.h:72
YRealTimeClock * yFirstRealTimeClock(void)
static const string DATETIME_INVALID
int setUnixTime(s64 newval)
virtual int _parseAttr(YJSONObject *json_val)
Definition: yocto_api.cpp:2367
static YRealTimeClock * FindRealTimeClock(string func)
YRealTimeClock * yFindRealTimeClock(const string &func)
virtual int registerValueCallback(YFunctionValueCallback callback)
Definition: yocto_api.cpp:2544
int setUtcOffset(int newval)
Y_TIMESET_enum
#define YOCTO_CLASS_EXPORT
Definition: yocto_api.h:61
YRealTimeClockValueCallback _valueCallbackRealTimeClock
static YRealTimeClock * First(void)
YRealTimeClock * next(void)
#define YAPI_INVALID_INT
Definition: yocto_api.h:70
Y_TIMESET_enum timeSet(void)
void(* YRealTimeClockValueCallback)(YRealTimeClock *func, const string &functionValue)
virtual int _invokeValueCallback(string value)
Definition: yocto_api.cpp:2563


yoctopuce_altimeter
Author(s): Anja Sheppard
autogenerated on Mon Jun 10 2019 15:49:11