OpenMAMA
MamdaOrderBookPriceLevel.h
Go to the documentation of this file.
1 /* $Id$
2  *
3  * OpenMAMA: The open middleware agnostic messaging API
4  * Copyright (C) 2011 NYSE Technologies, Inc.
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19  * 02110-1301 USA
20  */
21 
22 #ifndef MamdaOrderBookPriceLevelH
23 #define MamdaOrderBookPriceLevelH
24 
28 #include <mama/mamacpp.h>
29 #include <stdlib.h>
30 #include <string.h>
31 
32 namespace Wombat
33 {
34 
35  class MamaSource;
36  class MamdaOrderBook;
37  class MamdaOrderBookEntry;
38  class MamdaOrderBookBasicDeltaList;
39 
44  class MAMDAOPTExpDLL MamdaOrderBookPriceLevel
45  {
46  public:
53  enum Action
54  {
59  };
60 
66  enum Side
67  {
71  };
72 
82  enum Reason
83  {
91  };
92 
97  enum OrderType
98  {
102  };
103 
105 
111 
115  MamdaOrderBookPriceLevel (double price,
116  Side side);
117 
118  MamdaOrderBookPriceLevel (MamaPrice& price,
119  Side side);
120 
122 
127  MamdaOrderBookPriceLevel& operator= (const MamdaOrderBookPriceLevel& rhs);
128 
133  void copy (const MamdaOrderBookPriceLevel& rhs);
134 
139  void copyLevelOnly (const MamdaOrderBookPriceLevel& rhs);
140 
141 
145  void addEntry (MamdaOrderBookEntry* entry);
146 
150  void updateEntry (const MamdaOrderBookEntry& entry);
151 
155  void removeEntryById (const MamdaOrderBookEntry& entry);
156 
161  void removeEntry (const MamdaOrderBookEntry* entry);
162 
170  void addEntriesFromLevel (
171  const MamdaOrderBookPriceLevel* level,
174 
182  void deleteEntriesFromSource (
183  const MamaSource* source,
185 
193  bool reevaluate ();
194 
195  // The following methods are intended to be used internally (e.g., by
196  // MamdaOrderBookListener).
197 
198  void clear ();
199  void setPrice (double price);
200  void setPrice (MamaPrice& price);
201  void setSize (mama_quantity_t size);
202  void setSizeChange (mama_quantity_t sizeChange);
203  void setNumEntries (mama_u32_t numEntries);
204  void setSide (Side side);
205  void setAction (Action action);
206  void setTime (const MamaDateTime& time);
207  void setDetails (const MamdaOrderBookPriceLevel& rhs);
208 
213  void markAllDeleted ();
214 
215  void setAsDifference (const MamdaOrderBookPriceLevel& lhs,
216  const MamdaOrderBookPriceLevel& rhs);
217 
223  double getPrice () const;
224  MamaPrice getMamaPrice () const;
225 
231  mama_quantity_t getSize () const;
232 
241  mama_quantity_t getSizeChange () const;
242 
252  mama_u32_t getNumEntries () const;
253 
258  mama_u32_t getNumEntriesTotal () const;
259 
265  bool empty () const;
266 
272  Side getSide () const;
273 
280  Action getAction () const;
281 
287  const MamaDateTime& getTime () const;
288 
297  bool operator== (const MamdaOrderBookPriceLevel& rhs) const;
298 
307  bool operator!= (const MamdaOrderBookPriceLevel& rhs) const
308  { return ! operator== (rhs); }
309 
317  void setOrderBook (MamdaOrderBook* book);
318 
324  MamdaOrderBook* getOrderBook() const;
325 
333  const char* getSymbol() const;
334 
342  MamdaOrderBookEntry* findEntry (
343  const char* id) const;
344 
352  MamdaOrderBookEntry* findOrCreateEntry (
353  const char* id);
354 
363  MamdaOrderBookEntry* findOrCreateEntry (
364  const char* id,
365  bool& newEntry);
366 
373  MamdaOrderBookEntry* getEntryAtPosition (
374  mama_u32_t pos) const;
375 
381  void setClosure (void* closure);
382 
388  void* getClosure () const;
389 
394  OrderType getOrderType () const;
395 
400  void setOrderType (OrderType orderType);
401 
412  void assertEqual (const MamdaOrderBookPriceLevel& rhs) const;
413 
414  class MAMDAOPTExpDLL iterator
415  {
416  protected:
418  struct iteratorImpl;
419  iteratorImpl& mImpl;
420  public:
421  iterator ();
422  iterator (const iterator& copy);
423  iterator (const iteratorImpl& copy);
424 
425  ~iterator ();
426 
427  iterator& operator= (const iterator& rhs);
428  iterator& operator++ ();
429  const iterator& operator++ () const;
430  bool operator== (const iterator& rhs) const;
431  bool operator!= (const iterator& rhs) const;
432  MamdaOrderBookEntry* operator* ();
433  const MamdaOrderBookEntry* operator* () const;
434  };
435 
436  typedef const iterator const_iterator;
437 
438  iterator begin ();
439  const_iterator begin () const;
440  iterator& begin (iterator& reuse);
441  const_iterator& begin (const_iterator& reuse) const;
442 
443  iterator end ();
444  const_iterator end () const;
445  iterator& end (iterator& reuse);
446  const_iterator& end (const_iterator& reuse) const;
447 
448  iterator findEntryAfter (iterator& start,
449  const char* id);
450  const_iterator findEntryAfter (const_iterator& start,
451  const char* id) const;
452 
460  static void setStrictChecking (bool strict);
461 
462 #ifndef __sun
463  static bool sortEntriesByTime;
464 #endif
465 
466  private:
467  struct MamdaOrderBookPriceLevelImpl;
468  MamdaOrderBookPriceLevelImpl& mImpl;
469  };
470 
471 } // namespace
472 
473 #endif // MamdaOrderBookPriceLevelH


© 2012 Linux Foundation