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

173 lines
3.9 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/Integral.h>
#include <OnixS/CME/MDH/Composites.h>
ONIXS_CMEMDH_NAMESPACE_BEGIN
/// Type for order identification.
typedef UInt64 OrderId;
/// Type for order priority.
typedef UInt64 OrderPriority;
/// Presents display quantity.
typedef Int32 DisplayQuantity;
/// Some basic traits for the order.
ONIXS_CMEMDH_LTWT_STRUCT
OrderTraits
{
/// Returns null order id.
static OrderId nullId()
{
return 18446744073709551615ul;
}
/// Returns null order priority.
static OrderPriority nullPriority()
{
return 18446744073709551615ul;
}
/// Returns null price.
static PRICE nullPrice()
{
return PRICE(9223372036854775807l);
}
/// Returns null display quantity.
static DisplayQuantity nullQuantity()
{
return 2147483647;
}
};
/// Order as the member of the Market By Order (MBO) book.
ONIXS_CMEMDH_LTWT_CLASS Order
{
public:
/// Initializes instance according to given values.
/// By default, initializes null order.
Order(
OrderId id =
OrderTraits::nullId(),
OrderPriority priority =
OrderTraits::nullPriority(),
PRICE price =
OrderTraits::nullPrice(),
DisplayQuantity quantity =
OrderTraits::nullQuantity())
: id_(id)
, priority_(priority)
, price_(price)
, quantity_(quantity)
{
}
/// Order identifier.
OrderId id() const
{
return id_;
}
/// Updates order identifier.
void
id(
OrderId id)
{
id_ = id;
}
/// Order priority.
OrderPriority priority() const
{
return priority_;
}
/// Updates order priority.
void
priority(
OrderPriority priority)
{
priority_ = priority;
}
/// Order price.
const PRICE& price() const
{
return price_;
}
/// Updates order price.
void
price(
const PRICE& price)
{
price_ = price;
}
/// Display quantity.
DisplayQuantity quantity() const
{
return quantity_;
}
/// Updates display quantity.
void
quantity(
DisplayQuantity quantity)
{
quantity_ = quantity;
}
protected:
OrderId id_;
OrderPriority priority_;
PRICE price_;
DisplayQuantity quantity_;
};
/// Appends representation of order to given string.
ONIXS_CMEMDH_EXPORTED
void
toStr(
std::string&,
const Order&);
/// Returns string representation of the order.
inline
std::string
toStr(
const Order& order)
{
std::string str;
toStr(str, order);
return str;
}
ONIXS_CMEMDH_NAMESPACE_END