OnixS ICE iMpact Multicast Price Feed Handler C++ library  8.15.1
API documentation
Warning.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Onix Solutions Limited. All rights reserved.
3  *
4  * This software owned by Onix Solutions Limited 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 #include "Export.h"
23 #include "Optional.h"
24 #include "Types.h"
25 
26 #include <iosfwd>
27 #include <string>
28 
29 namespace OnixS { namespace ICE { namespace iMpact { namespace MarketData {
30 
31 /// List of known warnings.
32 struct ONIXS_ICEMDH_EXPORT KnownWarnings
33 {
34  /// List of known warnings.
35  enum Enum
36  {
37  /// General-purpose warning.
39 
40  /// For each feed channel server sends out messages
41  /// or heartbeats at fixed intervals. If the Handler
42  /// hasn’t received any message or a heartbeat for an
43  /// extended period of time, NoNetworkActivity
44  /// warning is raised by the Handler to identify that
45  /// either multicast channel is no longer active or
46  /// there is a network related issue.
48 
49  /// Has a session number which is used to easily detect when
50  /// a new session has started after the daily maintenance window
51  /// or failure on the server side. If session number is different
52  /// from previous one for a given multicast channel, error of
53  /// sessionNumberMismatch code is reported by the Handler.
55 
56  /// Tells that there is sequence number
57  /// gap in packets from a multicast feed.
59 
60  /// Indicates that one of internal queues
61  /// used by the Handler to store packets
62  /// coming from network is overflowed.
64 
65  /// Indicates failure in the user-space code.
66  /// When the Handler catches exception from the
67  /// user-space code, warning of given code reported.
69 
70  /// Indicates there are no UDS for requested market type
72  };
73 
74  /// Returns constant from its text presentation.
75  static Enum deserialize(const char* value);
76 
77  /// Returns description of a particular warning.
78  static const char* toString(Enum value);
79 };
80 
81 /// Code of warning.
83 
84 /// Warning.
85 class ONIXS_ICEMDH_EXPORT Warning
86 {
87 public:
88  /// Initializes instance with just a code.
89  Warning(
90  const std::string& source
91  , WarningCode code
92  );
93 
94  /// Initializes instance with code and description.
95  Warning(
96  const std::string& source
97  , WarningCode code
98  , const std::string& description
99  );
100 
101  /// Initializes instance with code, description and feed ID.
102  Warning(
103  const std::string& source
104  , WarningCode code
105  , const std::string& description
106  , FeedId feedId
107  );
108 
109  /// Initializes as clone of another warning.
110  Warning(const Warning& other);
111 
112  /// Cleans internal resources.
113  ~Warning();
114 
115  /// Feed ID (if available).
116  const Optional<FeedId>& feedId() const;
117 
118  /// Code of warning.
119  WarningCode code() const;
120 
121  /// Human readable description.
122  const char* description() const;
123 
124  /// Origin of the warning.
125  const char* source() const;
126 
127  /// String presentation of an warning.
128  std::string toString() const;
129 
130  /// Appends presentation of an warning to the string.
131  void toString(std::string&) const;
132 
133  /// Copies warning attributes from another instance.
134  Warning& operator=(const Warning& other);
135 
136 private:
137  enum Traits
138  {
139  SourceMaxLength = 128,
140  DescriptionMaxLength = 1024
141  };
142 
143  WarningCode code_;
144  char source_[SourceMaxLength];
145  char description_[DescriptionMaxLength];
146  Optional<FeedId> feedId_;
147 };
148 
149 /// Make it printable to formatted C++ I/O streams.
150 ONIXS_ICEMDH_EXPORT std::ostream& operator<<(std::ostream&, const Warning&);
151 
152 inline const Optional<FeedId>& Warning::feedId() const
153 {
154  return feedId_;
155 }
156 
157 inline WarningCode Warning::code() const
158 {
159  return code_;
160 }
161 
162 inline const char* Warning::description() const
163 {
164  return description_;
165 }
166 
167 inline const char* Warning::source() const
168 {
169  return source_;
170 }
171 
172 inline std::string Warning::toString() const
173 {
174  std::string str;
175  toString(str);
176  return str;
177 }
178 
179 }}}} // namespace MarketData, iMpact, ICE, OnixS
const char * description() const
Human readable description.
Definition: Warning.h:162
WarningCode code() const
Code of warning.
Definition: Warning.h:157
const char * source() const
Origin of the warning.
Definition: Warning.h:167
std::ostream & operator<<(std::ostream &, const Error &)
Make it printable to formatted C++ I/O streams.
std::string toString() const
String presentation of an warning.
Definition: Warning.h:172
KnownWarnings::Enum WarningCode
Code of warning.
Definition: Warning.h:82
const Optional< FeedId > & feedId() const
Feed ID (if available).
Definition: Warning.h:152
Indicates there are no UDS for requested market type.
Definition: Warning.h:71
int FeedId
Alias for market types.
Definition: Types.h:30