Files
externals/linux/include/OnixS/CME/MDH/Typification.h
T
2017-09-11 10:17:55 -04:00

257 lines
5.5 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/CME/MDH/Messages.h>
ONIXS_CMEMDH_NAMESPACE_BEGIN
/// Casts SBE-encoded message to given type.
template
<
class Message
>
inline
Message
typify(
const
BinaryMessage& message)
{
return
Message(
message.binary(),
message.binarySize());
}
/// Casts given binary message according to template/type
/// information and processes casted messages by given processor.
///
/// Returned value indicates whether message type was successfully
/// recognized and pushed to processor for further processing. Unknown
/// messages aren't processed and thus false result is returned.
template
<
class Processor
>
bool
processTypified(
const BinaryMessage& binary,
Processor& processor)
{
switch (binary.templateId())
{
case ChannelReset::TemplateId:
{
processor(
typify
<ChannelReset>
(binary));
return true;
}
case AdminHeartbeat::TemplateId:
{
processor(
typify
<AdminHeartbeat>
(binary));
return true;
}
case AdminLogin::TemplateId:
{
processor(
typify
<AdminLogin>
(binary));
return true;
}
case AdminLogout::TemplateId:
{
processor(
typify
<AdminLogout>
(binary));
return true;
}
case InstrumentDefinitionFuture::TemplateId:
{
processor(
typify
<InstrumentDefinitionFuture>
(binary));
return true;
}
case InstrumentDefinitionSpread::TemplateId:
{
processor(
typify
<InstrumentDefinitionSpread>
(binary));
return true;
}
case SecurityStatus::TemplateId:
{
processor(
typify
<SecurityStatus>
(binary));
return true;
}
case IncrementalRefreshBook::TemplateId:
{
processor(
typify
<IncrementalRefreshBook>
(binary));
return true;
}
case IncrementalRefreshDailyStatistics::TemplateId:
{
processor(
typify
<IncrementalRefreshDailyStatistics>
(binary));
return true;
}
case IncrementalRefreshLimitsBanding::TemplateId:
{
processor(
typify
<IncrementalRefreshLimitsBanding>
(binary));
return true;
}
case IncrementalRefreshSessionStatistics::TemplateId:
{
processor(
typify
<IncrementalRefreshSessionStatistics>
(binary));
return true;
}
case IncrementalRefreshTrade::TemplateId:
{
processor(
typify
<IncrementalRefreshTrade>
(binary));
return true;
}
case IncrementalRefreshVolume::TemplateId:
{
processor(
typify
<IncrementalRefreshVolume>
(binary));
return true;
}
case SnapshotFullRefresh::TemplateId:
{
processor(
typify
<SnapshotFullRefresh>
(binary));
return true;
}
case QuoteRequest::TemplateId:
{
processor(
typify
<QuoteRequest>
(binary));
return true;
}
case InstrumentDefinitionOption::TemplateId:
{
processor(
typify
<InstrumentDefinitionOption>
(binary));
return true;
}
case IncrementalRefreshTradeSummary::TemplateId:
{
processor(
typify
<IncrementalRefreshTradeSummary>
(binary));
return true;
}
case IncrementalRefreshOrderBook::TemplateId:
{
processor(
typify
<IncrementalRefreshOrderBook>
(binary));
return true;
}
case SnapshotFullRefreshOrderBook::TemplateId:
{
processor(
typify
<SnapshotFullRefreshOrderBook>
(binary));
return true;
}
default:
return false;
}
}
ONIXS_CMEMDH_NAMESPACE_END