OnixS ICE iMpact Multicast Price Feed Handler C++ library  8.18.0
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(const std::string& source, WarningCode code);
90 
91  /// Initializes instance with code and description.
92  Warning(const std::string& source, WarningCode code, const std::string& description);
93 
94  /// Initializes instance with code, description and feed ID.
95  Warning(const std::string& source, WarningCode code, const std::string& description, FeedId feedId);
96 
97  /// Initializes as clone of another warning.
98  Warning(const Warning& other);
99 
100  /// Cleans internal resources.
101  ~Warning();
102 
103  /// Feed ID (if available).
104  const Optional<FeedId>& feedId() const;
105 
106  /// Code of warning.
107  WarningCode code() const;
108 
109  /// Human readable description.
110  const char* description() const;
111 
112  /// Origin of the warning.
113  const char* source() const;
114 
115  /// String presentation of an warning.
116  std::string toString() const;
117 
118  /// Appends presentation of an warning to the string.
119  void toString(std::string&) const;
120 
121  /// Copies warning attributes from another instance.
122  Warning& operator=(const Warning& other);
123 
124 private:
125  enum Traits
126  {
127  SourceMaxLength = 128,
128  DescriptionMaxLength = 1024
129  };
130 
131  WarningCode code_;
132  char source_[SourceMaxLength];
133  char description_[DescriptionMaxLength];
134  Optional<FeedId> feedId_;
135 };
136 
137 /// Make it printable to formatted C++ I/O streams.
138 ONIXS_ICEMDH_EXPORT std::ostream& operator<<(std::ostream&, const Warning&);
139 
140 inline const Optional<FeedId>& Warning::feedId() const
141 {
142  return feedId_;
143 }
144 
145 inline WarningCode Warning::code() const
146 {
147  return code_;
148 }
149 
150 inline const char* Warning::description() const
151 {
152  return description_;
153 }
154 
155 inline const char* Warning::source() const
156 {
157  return source_;
158 }
159 
160 inline std::string Warning::toString() const
161 {
162  std::string str;
163  toString(str);
164  return str;
165 }
166 
167 }}}} // namespace OnixS::ICE::iMpact::MarketData
const char * description() const
Human readable description.
Definition: Warning.h:150
WarningCode code() const
Code of warning.
Definition: Warning.h:145
const char * source() const
Origin of the warning.
Definition: Warning.h:155
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:160
KnownWarnings::Enum WarningCode
Code of warning.
Definition: Warning.h:82
const Optional< FeedId > & feedId() const
Feed ID (if available).
Definition: Warning.h:140
Indicates there are no UDS for requested market type.
Definition: Warning.h:71
int FeedId
Alias for market types.
Definition: Types.h:30