155 lines
4.7 KiB
C++
155 lines
4.7 KiB
C++
/*
|
||
* Copyright Onix Solutions Limited [OnixS]. All rights reserved.
|
||
*
|
||
* This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
|
||
* and international copyright treaties.
|
||
*
|
||
* Access to and use of the software is governed by the terms of the applicable OnixS Software
|
||
* Services Agreement (the Agreement) and Customer end user license agreements granting
|
||
* a non-assignable, non-transferable and non-exclusive license to use the software
|
||
* for it's own data processing purposes under the terms defined in the Agreement.
|
||
*
|
||
* Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
|
||
* of this source code or associated reference material to any other location for further reproduction
|
||
* or redistribution, and any amendments to this copyright notice, are expressly prohibited.
|
||
*
|
||
* Any reproduction or redistribution for sale or hiring of the Software not in accordance with
|
||
* the terms of the Agreement is a violation of copyright law.
|
||
*/
|
||
|
||
#pragma once
|
||
|
||
#include <OnixS/ICE/iMpact/MarketData/ABI.h>
|
||
#include <OnixS/ICE/iMpact/MarketData/Types.h>
|
||
|
||
#include <iosfwd>
|
||
#include <string>
|
||
|
||
namespace OnixS { namespace ICE { namespace iMpact { namespace MarketData {
|
||
|
||
/// List of known warnings.
|
||
struct ONIXS_ICE_IMPACT_MD_API KnownWarnings
|
||
{
|
||
/// List of known warnings.
|
||
enum Enum
|
||
{
|
||
/// General-purpose warning.
|
||
Generic,
|
||
|
||
/// For each feed channel server sends out messages
|
||
/// or heartbeats at fixed intervals. If the Handler
|
||
/// hasn’t received any message or a heartbeat for an
|
||
/// extended period of time, NoNetworkActivity
|
||
/// warning is raised by the Handler to identify that
|
||
/// either multicast channel is no longer active or
|
||
/// there is a network related issue.
|
||
NoNetworkActivity,
|
||
|
||
/// Has a session number which is used to easily detect when
|
||
/// a new session has started after the daily maintenance window
|
||
/// or failure on the server side. If session number is different
|
||
/// from previous one for a given multicast channel, error of
|
||
/// sessionNumberMismatch code is reported by the Handler.
|
||
SessionNumberMismatch,
|
||
|
||
/// Tells that there is sequence number
|
||
/// gap in packets from a multicast feed.
|
||
PacketGap,
|
||
|
||
/// Indicates that one of internal queues
|
||
/// used by the Handler to store packets
|
||
/// coming from network is overflowed.
|
||
PacketQueueOverflow,
|
||
|
||
/// Indicates failure in the user-space code.
|
||
/// When the Handler catches exception from the
|
||
/// user-space code, warning of given code reported.
|
||
ListenerFailure,
|
||
|
||
/// Indicates there are no UDS for requested market type
|
||
NoUdsForMarketType,
|
||
};
|
||
|
||
/// Returns constant from its text presentation.
|
||
static Enum deserialize(const char* value);
|
||
|
||
/// Returns description of a particular warning.
|
||
static const char* toString(Enum value);
|
||
};
|
||
|
||
/// Code of warning.
|
||
typedef KnownWarnings::Enum WarningCode;
|
||
|
||
/// Warning.
|
||
class ONIXS_ICE_IMPACT_MD_API Warning
|
||
{
|
||
public:
|
||
/// Initializes instance with just a code.
|
||
Warning(const std::string& source, WarningCode code);
|
||
|
||
/// Initializes instance with code and description.
|
||
Warning(const std::string& source, WarningCode code, const std::string& description);
|
||
|
||
/// Initializes as clone of another warning.
|
||
Warning(const Warning& other);
|
||
|
||
/// Cleans internal resources.
|
||
~Warning();
|
||
|
||
/// Code of warning.
|
||
WarningCode code() const;
|
||
|
||
/// Human readable description.
|
||
const char* description() const;
|
||
|
||
/// Origin of the warning.
|
||
const char* source() const;
|
||
|
||
/// String presentation of an warning.
|
||
std::string toString() const;
|
||
|
||
/// Appends presentation of an warning to the string.
|
||
void toString(std::string&) const;
|
||
|
||
/// Copies warning attributes from another instance.
|
||
Warning& operator=(const Warning& other);
|
||
|
||
private:
|
||
enum Traits
|
||
{
|
||
SourceMaxLength = 128,
|
||
DescriptionMaxLength = 1024
|
||
};
|
||
|
||
WarningCode code_;
|
||
char source_[SourceMaxLength];
|
||
char description_[DescriptionMaxLength];
|
||
};
|
||
|
||
/// Make it printable to formatted C++ I/O streams.
|
||
ONIXS_ICE_IMPACT_MD_API std::ostream& operator<<(std::ostream&, const Warning&);
|
||
|
||
inline WarningCode Warning::code() const
|
||
{
|
||
return code_;
|
||
}
|
||
|
||
inline const char* Warning::description() const
|
||
{
|
||
return description_;
|
||
}
|
||
|
||
inline const char* Warning::source() const
|
||
{
|
||
return source_;
|
||
}
|
||
|
||
inline std::string Warning::toString() const
|
||
{
|
||
std::string str;
|
||
toString(str);
|
||
return str;
|
||
}
|
||
|
||
}}}} // namespace MarketData, iMpact, ICE, OnixS
|