TimeManager.h
2.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#ifndef TIMEMANAGER_H
#define TIMEMANAGER_H
#include <ctime>
#include "../Common/Singleton.h"
#include "../Application/Application.h"
#include "../Common/TREPSTypes.h"
#include "../DataRecord/DataRecord.h"
#include "../XMLManager/XMLManager.h"
#include "TimePattern.h"
#define TREPS_TIMES_XSD "times.xsd"
using namespace TREPS::Common;
using namespace TREPS::DataRecord;
using namespace TREPS::Application;
using namespace TREPS::XMLManager;
namespace TREPS
{
namespace TimeManager
{
class TimeManagerClass : public SingletonClass<TimeManagerClass>
{
friend class SingletonClass<TimeManagerClass>;
public :
TimeManagerClass(void);
~TimeManagerClass(void);
//load time formats file
bool init(const char *file_path);
//get pattern from time id
string getPatternFromTimeId(const char *timeId);
//retrieve time id from pattern
string getTimeIdFromPattern(const char *pattern);
//get time format from time id
t_TimeFormat getFormatFromTimeId(const char *timeId);
//retrieve time id from time format and pattern
string getTimeIdFromFormatAndPattern(t_TimeFormat format, const char *pattern);
//set current pattern
bool setCurrentPattern(const char *pattern);
//get current pattern used
int getCurrentPatternSize(void);
//try to detect the pattern
string detectPattern(const char *value);
//load from pattern
bool from_PATTERN(const char *time, t_Time &t, bool verbose = true);
//load from timestamp
bool from_TIMESTAMP(time_t tt, t_Time &t);
//load from decimal time
bool from_DECIMAL(double d, t_Time &t);
//laod from epoch time (CDF)
bool from_EPOCH(double e, t_Time &t);
//load from tt200 time (CDF)
bool from_TT2000(long long tt, t_Time &t);
//laod from ddtime (CDPP/DDServer)
bool from_DDTIME(const char *dd_time, t_Time &t);
//write to pattern
string to_PATTERN(t_Time t);
//write to timestamp
time_t to_TIMESTAMP(t_Time t);
//write to decimal time
double to_DECIMAL(t_Time t);
//write to epoch (CDF)
double to_EPOCH(t_Time t);
//write to tt2000 (CDF)
long long int to_TT2000(t_Time t);
//Write to ddtime (CDPP/DDServer)
string to_DDTIME(t_Time t);
//write to string
string to_string(t_Time t, t_TimeFormat format, const char *pattern);
private:
ApplicationClass *app;
XMLManagerClass *loader;
TimePatternClass *crtPattern;
NodeList getTimeNodeList(void);
};
}
}
#endif