Files

161 lines
3.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 <vector>
#include <OnixS/CME/MDH/Order.h>
#include <OnixS/CME/MDH/Messages.h>
ONIXS_CMEMDH_NAMESPACE_BEGIN
/// Collection of order details
/// referring to a single trade.
ONIXS_CMEMDH_LTWT_CLASS TradeOrderIds
{
public:
/// Stores information on order id and other details.
ONIXS_CMEMDH_LTWT_CLASS Details
{
OrderId orderId_;
Int32 lastQty_;
public:
/// Initializes blank instance with no valid attributes.
Details()
: orderId_(0)
, lastQty_(0)
{
}
/// Retrieves order details from given market data entry.
template
<
class Entry
>
Details(
const Entry& entry)
: orderId_(entry.orderId())
, lastQty_(entry.lastQty())
{
}
/// Returns order identifier.
OrderId orderId() const
{
return orderId_;
}
/// Returns last quantity for order.
Int32 lastQty() const
{
return lastQty_;
}
};
/// Initializes blank instance.
TradeOrderIds()
{
}
/// Initializes blank instance capacious
/// enough to store given number of orders.
explicit
TradeOrderIds(
size_t capacity)
{
reserve(capacity);
}
/// Initializes as copy of other instance.
TradeOrderIds(
const TradeOrderIds& other)
: ids_(other.ids_)
{
}
/// Destructs internal storage.
~TradeOrderIds()
{
}
/// Indicates whether collection is empty.
bool empty() const
{
return ids_.empty();
}
/// Number of items in given collection.
size_t size() const
{
return ids_.size();
}
/// Provides access to item by its index.
const
Details&
operator [](
size_t index) const
{
assert(
index <
ids_.size());
return ids_[index];
}
/// Adds order details to collection.
template
<
class Entry
>
void
add(
const Entry& entry)
{
ids_.push_back(Details(entry));
}
/// Resets collection to blank state.
void clear()
{
ids_.clear();
}
/// Makes collection capacious enough
/// to store given number of items.
void
reserve(
size_t capacity)
{
ids_.reserve(capacity);
}
private:
typedef
std::vector<Details>
Ids;
Ids ids_;
};
ONIXS_CMEMDH_NAMESPACE_END