OnixS C++ MTS Bond Vision SDP Handler 1.3.0
API documentation
Loading...
Searching...
No Matches
Time.h
Go to the documentation of this file.
1/*
2* Copyright Onix Solutions Limited [OnixS]. All rights reserved.
3*
4* This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
5* and international copyright treaties.
6*
7* Access to and use of the software is governed by the terms of the applicable OnixS Software
8* Services Agreement (the Agreement) and Customer end user license agreements granting
9* a non-assignable, non-transferable and non-exclusive license to use the software
10* for it's own data processing purposes under the terms defined in the Agreement.
11*
12* Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
13* of this source code or associated reference material to any other location for further reproduction
14* or redistribution, and any amendments to this copyright notice, are expressly prohibited.
15*
16* Any reproduction or redistribution for sale or hiring of the Software not in accordance with
17* the terms of the Agreement is a violation of copyright law.
18*/
19
20#pragma once
21
22#if defined __linux__
23#include <unistd.h>
24#include <sys/time.h>
25#endif
26
28
29namespace OnixS {
30namespace Mts {
31namespace BondVision {
32namespace SDP {
33
34#if defined _WIN32
35
36typedef
37unsigned __int64
38AbsoluteHighResolutionTimeImpl;
39
40typedef
41__int64
42RelativeHighResolutionTimeImpl;
43
44#elif defined __linux__
45
46typedef timeval AbsoluteHighResolutionTimeImpl;
47typedef struct Nothing {} RelativeHighResolutionTimeImpl;
48#else
49
50#error High resolution time services are not defined for a given platform.
51
52#endif
55typedef AbsoluteHighResolutionTimeImpl Timestamp;
56
59struct ONIXS_MTS_BONDVISION_SDP_API HighResolutionTimeFields
60{
61 unsigned short year;
62 unsigned short month;
63 unsigned short day;
64
65 unsigned short hour;
66 unsigned short minute;
67 unsigned short seconds;
68
69 unsigned int microseconds;
70
73 void fromAbsolute (const AbsoluteHighResolutionTimeImpl&);
74
77 void toAbsolute (AbsoluteHighResolutionTimeImpl*) const;
78
81 void fromString (const std::string&);
82
85 std::string toString() const;
86};
87
88typedef long long HighResolutionTimeSpan;
89
92class ONIXS_MTS_BONDVISION_SDP_API HighResolutionTime
93{
94public:
98
102
106
110
113 bool isValid() const;
114
118
121 std::string toString() const;
122
125 void setToNow();
126
129 bool operator == (const HighResolutionTime&) const;
130
133 bool operator != (const HighResolutionTime&) const;
134
138
142
146
149 static HighResolutionTime parse (const std::string& time);
150
151protected:
152 friend struct TimestampHelpers;
153#if defined _WIN32
156 static HighResolutionTime createFromRelative (RelativeHighResolutionTimeImpl value);
157#elif defined __linux__
160 static HighResolutionTime createFromAbsolute (AbsoluteHighResolutionTimeImpl value);
161#endif
162private:
163 enum ValueKind { Invalid, Absolute, Relative };
164
165 union Value
166 {
167 AbsoluteHighResolutionTimeImpl asAbsolute;
168 RelativeHighResolutionTimeImpl asRelative;
169 };
170
171 Value value_;
172 ValueKind kind_;
173
174 HighResolutionTime (ValueKind kind);
175};
176
178{
179 return ! (Invalid == kind_);
180}
181
182ONIXS_MTS_BONDVISION_SDP_API std::ostream& operator << (std::ostream& os, const HighResolutionTime&);
183}
184}
185}
186}
static HighResolutionTime parse(const std::string &time)
HighResolutionTime(const HighResolutionTimeFields &)
HighResolutionTime(const HighResolutionTime &)
void getFields(HighResolutionTimeFields *fields) const
long long HighResolutionTimeSpan
Definition Time.h:88
AbsoluteHighResolutionTimeImpl Timestamp
Definition Time.h:55
unsigned long long UInt64
Definition Defines.h:47
ONIXS_MTS_BONDVISION_SDP_API std::ostream & operator<<(std::ostream &stream, TradeImpactService::Enum value)
void fromAbsolute(const AbsoluteHighResolutionTimeImpl &)
void toAbsolute(AbsoluteHighResolutionTimeImpl *) const