OnixS C++ Eurex T7 Market and Reference Data Interface (EMDI, RDI, EOBI) Handlers  8.1.0
API documentation
MessageQueue.cpp
Go to the documentation of this file.
1 /*
2 * Copyright Onix Solutions Limited [OnixS]. All rights reserved.
3 *
4 * This software owned by Onix Solutions Limited [OnixS] and is protected by copyright law
5 * and international copyright treaties.
6 *
7 * Access to and use of the software is governed by the terms of the applicable OnixS Software
8 * Services Agreement (the Agreement) and Customer end user license agreements granting
9 * a non-assignable, non-transferable and non-exclusive license to use the software
10 * for it's own data processing purposes under the terms defined in the Agreement.
11 *
12 * Except as otherwise granted within the terms of the Agreement, copying or reproduction of any part
13 * of this source code or associated reference material to any other location for further reproduction
14 * or redistribution, and any amendments to this copyright notice, are expressly prohibited.
15 *
16 * Any reproduction or redistribution for sale or hiring of the Software not in accordance with
17 * the terms of the Agreement is a violation of copyright law.
18 */
19 #include <OnixS/HandlerCore/Compiler.h>
20 
22 
23 #include "MessageQueue.h"
24 
25 
26 namespace OnixS {
27 namespace Eurex {
28 namespace MarketData {
29 namespace Implementation {
30 
32 {
35 };
36 
38 
39 MessageQueue::MessageQueue(size_t allocatorSize)
40  : messageInfoAllocator_(allocatorSize),
41  messages_()
42 {
43 }
44 
46 {
47  reset();
48 }
49 
50 bool MessageQueue::empty() const
51 {
52  return messages_.empty();
53 }
54 
56 {
57  while(!messages_.empty())
58  messages_.pop();
59 
60  messageInfoAllocator_.reset();
61 }
62 
63 void MessageQueue::push(const CORE::Message& message,
64  const DataSource& dataSource,
65  TemplateId templateId)
66 {
67  MessageMetaInfo* const info =
68  new(messageInfoAllocator_.allocate(sizeof(MessageMetaInfo))) MessageMetaInfo();
69 
70  info->dataSource = dataSource;
71  info->templateId = templateId;
72 
73  const_cast<CORE::Message&>(message).attachment(info);
74  messages_.push(&message);
75 }
76 
78 {
79  const CORE::Message* tmp(messages_.front());
80  BOOST_ASSERT(tmp != nullptr);
81 
82  MessageInfo result;
83 
84  MessageMetaInfo* const info = static_cast<MessageMetaInfo*>(tmp->attachment());
85  BOOST_ASSERT(info != nullptr);
86 
87  result.message = tmp;
88  result.dataSource = &info->dataSource;
89  result.templateId = info->templateId;
90 
91  messages_.pop();
92 
93  return result;
94 }
95 
96 }}}}
void push(const CORE::Message &message, const DataSource &dataSource, TemplateId templateId)
Definition: Defines.h:30
OnixS::FIX::Core::FAST::TemplateId TemplateId