OnixS C++ Eurex T7 Market and Reference Data (EMDI, MDI, RDI, EOBI) Handlers  17.0.1
API documentation
Group.h
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 
20 #pragma once
21 
24 
25 namespace OnixS
26 {
27  namespace Eurex
28  {
29  namespace MarketData
30  {
31  ONIXS_EUREX_EMDI_API_DECL (class, Message);
32  ONIXS_EUREX_EMDI_API_DECL (class, Group);
33 
34  /// Single instance of FIX Repeating Group. Provides access
35  /// to the fields of a particular repeating group instance.
36  ///
37  /// Class behaves like a pointer/reference to a set of FIX
38  /// fields. Coping and assignment operations just update reference
39  /// to the field-set being pointed, no deep copying is performed.
40  class ONIXS_EUREX_EMDI_API GroupInstance : public FieldSet
41  {
42  public:
43  /// Initializes instance as reference to the other one.
44  GroupInstance (const GroupInstance& other);
45 
46  /// Reinitializes instance as reference of other one.
47  GroupInstance& operator = (const GroupInstance&);
48 
49  private:
50  friend class MessageOperator;
51 
52  GroupInstance (const Message*, void*);
53  };
54 
55  /// Encapsulates operations over FIX Repeating Group.
56  ///
57  /// Repeating group represents array of repeating group instances,
58  /// So, class exposes corresponding services to manipulate array
59  /// of repeating group instances. Similar to the OnixS::FIX::GroupInstance
60  /// it behaves like a pointer/reference to the underlying data. It's
61  /// a light-weight object which just wraps internal data.
62  ///
63  /// Group remains valid until corresponding field (which defines
64  /// size/length of repeating group) from field-set (message or outer
65  /// repeating group instance) is updated.
66  class ONIXS_EUREX_EMDI_API Group
67  {
68  public:
69  /// Initializes instance as reference to given repeating group.
70  Group (const Group& other);
71 
72  /// Indicated whether group refers to a valid instance.
73  operator bool() const;
74 
75  /// Return number of instances in repeating group.
76  ///
77  /// @warning Due to performance considerations,
78  /// instance is not checked for validness. Member
79  /// must be used only when instance is in valid state.
80  size_t size() const;
81 
82  /// Accesses to repeating group instance.
83  ///
84  /// @throw std::exception if If index exceeds allowed bounds.
85  ///
86  /// @warning Due to performance considerations,
87  /// instance is not checked for validness. Member
88  /// must be used only when instance is in valid state.
89  const GroupInstance at (size_t index) const;
90 
91  /// Accesses to repeating group instance.
92  ///
93  /// Does NOT check index validness.
94  ///
95  /// @warning Due to performance considerations,
96  /// instance is not checked for validness. Member
97  /// must be used only when instance is in valid state.
98  const GroupInstance operator [] (size_t index) const;
99 
100  /// Reinitializes instance as reference to other one.
101  Group& operator = (const Group& other);
102 
103 
104  ///
105  void swap(Group&) throw();
106 
107  private:
108  friend class MessageOperator;
109 
110  const Message* container_;
111 
112  void* impl_;
113 
114  Group (const Message*, void*);
115  };
116 
117  template<class Entry>
118  class TypedGroup : protected Group
119  {
120  public:
121  /// Return number of instances in the repeating group.
122  using Group::size;
123 
124  /// Indicates whether set has an entries.
125  bool empty() const
126  {
127  return 0 == size();
128  }
129 
130  /// Accesses to repeating group instance.
131  ///
132  /// @throw std::exception if If index exceeds allowed bounds.
133  const Entry at (size_t index) const
134  {
135  if (index < size() )
136  return Entry (this->Group::operator[] (index) );
137 
138  throw std::out_of_range ("Index");
139  }
140 
141  /// Accesses to repeating group instance.
142  ///
143  /// Does NOT check index validness.
144  Entry operator [] (size_t index) const
145  {
146  return Entry (this->Group::operator[] (index) );
147  }
148 
149  protected:
150  explicit
151  TypedGroup (const Group& group)
152  : Group (group)
153  {
154  }
155  };
156  }
157  }
158 }
bool empty() const
Indicates whether set has an entries.
Definition: Group.h:125
Definition: Defines.h:30
ONIXS_EUREX_EMDI_API_DECL(class, Message)
TypedGroup(const Group &group)
Definition: Group.h:151
const Entry at(size_t index) const
Definition: Group.h:133