Files

530 lines
10 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/Memory.h>
#include <OnixS/CME/MDH/Decimal.h>
#include <OnixS/CME/MDH/Fields.h>
ONIXS_CMEMDH_NAMESPACE_BEGIN
ONIXS_CMEMDH_DATA_PACKING_BEGIN(1)
/// Decimal with constant exponent -9.
typedef
FixedPointDecimal
<
Int64,
IntegralConstant<Int8, -9>
>
Decimal9;
/// Null values definition for optional Decimal9 field.
ONIXS_CMEMDH_LTWT_STRUCT NullDecimal9
{
/// Aliases the type whose null value
/// traits are exposed by the given class.
typedef Decimal9 Value;
/// Null value for optional Mantissa field.
typedef
IntegralConstant<Int64, 9223372036854775807LL>
NullMantissa;
/// Compares encoded data to NULL.
bool
operator ==(
const Value& other) const
{
return (
NullMantissa() ==
other.mantissa()
);
}
/// Compares encoded data to NULL.
bool
operator !=(
const Value& other) const
{
return !(*this == other);
}
};
/// A number representing quantity.
///
/// FIX type: Qty.
typedef
FixedPointDecimal
<
Int32,
IntegralConstant<Int8, -4>
>
DecimalQty;
/// Null values definition for optional DecimalQty field.
ONIXS_CMEMDH_LTWT_STRUCT NullDecimalQty
{
/// Aliases the type whose null value
/// traits are exposed by the given class.
typedef DecimalQty Value;
/// Null value for optional Mantissa field.
typedef
IntegralConstant<Int32, 2147483647>
NullMantissa;
/// Compares encoded data to NULL.
bool
operator ==(
const Value& other) const
{
return (
NullMantissa() ==
other.mantissa()
);
}
/// Compares encoded data to NULL.
bool
operator !=(
const Value& other) const
{
return !(*this == other);
}
};
/// Decimal.
typedef
FixedPointDecimal
<
Int64,
IntegralConstant<Int8, -7>
>
FLOAT;
/// Year, Month and Date.
///
/// FIX type: MonthYear.
ONIXS_CMEMDH_LTWT_CLASS MaturityMonthYear
{
public:
/// Size of composite.
enum { Size = 5 };
/// YYYY.
typedef UInt16 Year;
/// Null value for optional Year field.
typedef
IntegralConstant<UInt16, 65535>
NullYear;
/// MM.
typedef UInt8 Month;
/// Null value for optional Month field.
typedef
IntegralConstant<UInt8, 255>
NullMonth;
/// DD.
typedef UInt8 Day;
/// Null value for optional Day field.
typedef
IntegralConstant<UInt8, 255>
NullDay;
/// WW.
typedef UInt8 Week;
/// Null value for optional Week field.
typedef
IntegralConstant<UInt8, 255>
NullWeek;
/// Default constructor.
///
/// Initializes fields with appropriate null values.
MaturityMonthYear()
: year_(NullYear::value()),
month_(NullMonth::value()),
day_(NullDay::value()),
week_(NullWeek::value())
{
}
/// YYYY.
Year year() const
{
return year_;
}
/// MM.
bool
month(
Month& value) const
{
if (NullMonth() == month_) return false;
value = month_;
return true;
}
/// DD.
bool
day(
Day& value) const
{
if (NullDay() == day_) return false;
value = day_;
return true;
}
/// WW.
bool
week(
Week& value) const
{
if (NullWeek() == week_) return false;
value = week_;
return true;
}
private:
Year year_;
Month month_;
Day day_;
Week week_;
};
/// Null values definition for optional MaturityMonthYear field.
ONIXS_CMEMDH_LTWT_STRUCT NullMaturityMonthYear
{
/// Aliases the type whose null value
/// traits are exposed by the given class.
typedef MaturityMonthYear Value;
/// Compares encoded data to NULL.
bool
operator ==(
const Value& other) const
{
return (
MaturityMonthYear::NullYear() ==
other.year()
);
}
/// Compares encoded data to NULL.
bool
operator !=(
const Value& other) const
{
return !(*this == other);
}
};
/// PRICE.
typedef
FixedPointDecimal
<
Int64,
IntegralConstant<Int8, -7>
>
PRICE;
/// Null values definition for optional PRICE field.
ONIXS_CMEMDH_LTWT_STRUCT NullPRICE
{
/// Aliases the type whose null value
/// traits are exposed by the given class.
typedef PRICE Value;
/// Null value for optional Mantissa field.
typedef
IntegralConstant<Int64, 9223372036854775807LL>
NullMantissa;
/// Compares encoded data to NULL.
bool
operator ==(
const Value& other) const
{
return (
NullMantissa() ==
other.mantissa()
);
}
/// Compares encoded data to NULL.
bool
operator !=(
const Value& other) const
{
return !(*this == other);
}
};
/// Price with constant exponent -9.
typedef
FixedPointDecimal
<
Int64,
IntegralConstant<Int8, -9>
>
PRICE9;
/// Null values definition for optional PRICE9 field.
ONIXS_CMEMDH_LTWT_STRUCT NullPRICE9
{
/// Aliases the type whose null value
/// traits are exposed by the given class.
typedef PRICE9 Value;
/// Null value for optional Mantissa field.
typedef
IntegralConstant<Int64, 9223372036854775807LL>
NullMantissa;
/// Compares encoded data to NULL.
bool
operator ==(
const Value& other) const
{
return (
NullMantissa() ==
other.mantissa()
);
}
/// Compares encoded data to NULL.
bool
operator !=(
const Value& other) const
{
return !(*this == other);
}
};
/// Repeating group dimensions.
///
/// FIX type: NumInGroup.
ONIXS_CMEMDH_LTWT_CLASS GroupSize
{
public:
/// Size of composite.
enum { Size = 3 };
/// blockLength type.
typedef UInt16 BlockLength;
/// numInGroup type.
typedef UInt8 NumInGroup;
/// Default constructor.
///
/// Initializes fields with zero values.
GroupSize()
: blockLength_(0),
numInGroup_(0)
{
}
/// blockLength field.
BlockLength blockLength() const
{
return blockLength_;
}
/// numInGroup field.
NumInGroup numInGroup() const
{
return numInGroup_;
}
private:
BlockLength blockLength_;
NumInGroup numInGroup_;
};
/// 8 Byte aligned repeating group dimensions.
///
/// FIX type: NumInGroup.
ONIXS_CMEMDH_LTWT_CLASS GroupSize8Byte
{
public:
/// Size of composite.
enum { Size = 8 };
/// Length.
typedef UInt16 BlockLength;
/// NumInGroup.
typedef UInt8 NumInGroup;
/// Default constructor.
///
/// Initializes fields with zero values.
GroupSize8Byte()
: blockLength_(0),
numInGroup_(0)
{
}
/// Length.
BlockLength blockLength() const
{
return blockLength_;
}
/// NumInGroup.
NumInGroup numInGroup() const
{
return numInGroup_;
}
private:
BlockLength blockLength_;
Byte padding1[5];
NumInGroup numInGroup_;
};
/// Repeating group dimensions.
ONIXS_CMEMDH_LTWT_CLASS GroupSizeEncoding
{
public:
/// Size of composite.
enum { Size = 4 };
/// blockLength type.
///
/// FIX type: Length.
typedef UInt16 BlockLength;
/// numInGroup type.
///
/// FIX type: NumInGroup.
typedef UInt16 NumInGroup;
/// Default constructor.
///
/// Initializes fields with zero values.
GroupSizeEncoding()
: blockLength_(0),
numInGroup_(0)
{
}
/// blockLength field.
///
/// FIX type: Length.
BlockLength blockLength() const
{
return blockLength_;
}
/// numInGroup field.
///
/// FIX type: NumInGroup.
NumInGroup numInGroup() const
{
return numInGroup_;
}
private:
BlockLength blockLength_;
NumInGroup numInGroup_;
};
/// Template ID and length of message root.
ONIXS_CMEMDH_LTWT_CLASS MessageHeader
{
public:
/// Size of composite.
enum { Size = 8 };
/// blockLength type.
typedef UInt16 BlockLength;
/// templateId type.
typedef UInt16 TemplateId;
/// schemaId type.
typedef UInt16 SchemaId;
/// version type.
typedef UInt16 Version;
/// Default constructor.
///
/// Initializes fields with zero values.
MessageHeader()
: blockLength_(0),
templateId_(0),
schemaId_(0),
version_(0)
{
}
/// blockLength field.
BlockLength blockLength() const
{
return blockLength_;
}
/// templateId field.
TemplateId templateId() const
{
return templateId_;
}
/// schemaId field.
SchemaId schemaId() const
{
return schemaId_;
}
/// version field.
Version version() const
{
return version_;
}
private:
BlockLength blockLength_;
TemplateId templateId_;
SchemaId schemaId_;
Version version_;
};
ONIXS_CMEMDH_DATA_PACKING_END
ONIXS_CMEMDH_NAMESPACE_END