This file is indexed.

/usr/include/mamda/MamdaOrderBook.h is in libmamda-dev 2.2.2.1-10.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
/* $Id$
 *
 * OpenMAMA: The open middleware agnostic messaging API
 * Copyright (C) 2011 NYSE Technologies, Inc.
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
 * 02110-1301 USA
 */

#ifndef MamdaOrderBookH
#define MamdaOrderBookH

#include <mamda/MamdaOrderBookEntry.h>
#include <mamda/MamdaOptionalConfig.h>
#include <mamda/MamdaOrderBookPriceLevel.h>
#include <mamda/MamdaOrderBookExceptions.h>
#include <mamda/MamdaOrderBookEntryFilter.h>
#include <mama/mamacpp.h>
#include <mama/MamaSourceDerivative.h>
#include <iosfwd>

using std::ostream;

namespace Wombat
{

    class MamdaOrderBookBasicDelta;
    class MamdaOrderBookBasicDeltaList;

    /**
     * MamdaOrderBook is a class that provides order book functionality,
     * including iterators over price levels and entries within price
     * levels.
     */
    class MAMDAOPTExpDLL MamdaOrderBook
    {
    public:
        MamdaOrderBook ();
        ~MamdaOrderBook ();

        // Copying and assignment
        MamdaOrderBook (const MamdaOrderBook&);
        MamdaOrderBook& operator= (const MamdaOrderBook&);

        /**
         * Clear the order book entirely.
         *
         * @param deleteLevels If true then the level objects will be deleted
         */
        void clear (bool deleteLevels = true);

        /**
         * The order book subscription symbol.
         *
         * @param symbol The subscription symbol.
         */
        void setSymbol (const char*  symbol);

        /**
         * The orderbook subscription symbol.
         * 
         * @return The orderbook subscription symbol.
         */
        const char*  getSymbol () const;

        /**
         * The orderbook participant id
         * @param partId The participant id
         */
        void setPartId (const char* partId);

        /**
         * The orderbook participant id
         * @return The orderbook participant id
         **/
        const char*  getPartId () const;

        /** 
         * The orderbook participant id
         * @return Whether this orderbook has a participant id
         **/
        bool hasPartId () const;

        /**
         * Create a price level in the orderbook for the given price/size.
         * The price level is initially empty and marked as "not used".
         * The "not used" status changes automatically when entries are
         * added to the price level.
         *
         * @param price  The price of the price level to find/create.
         * @param side   The side of the book of the price level to find/create.

         * @return The found or newly create price level.
         *
         * @throw <MamdaOrderBookException> When an error is encountered during
         * book processing.
         */
        MamdaOrderBookPriceLevel* findOrCreateLevel (
            double                              price,
            MamdaOrderBookPriceLevel::Side      side);

        MamdaOrderBookPriceLevel* findOrCreateLevel (
            MamaPrice&                          price,
            MamdaOrderBookPriceLevel::Side      side);

        MamdaOrderBookPriceLevel* findOrCreateLevel (
            double                              price,
            MamdaOrderBookPriceLevel::Side      side,
            MamdaOrderBookPriceLevel::Action&   action);

        MamdaOrderBookPriceLevel* findOrCreateLevel (
            MamaPrice&                          price,
            MamdaOrderBookPriceLevel::Side      side,
            MamdaOrderBookPriceLevel::Action&   action);

        MamdaOrderBookPriceLevel* findLevel (
            double                              price,
            MamdaOrderBookPriceLevel::Side      side);

        MamdaOrderBookPriceLevel* findLevel (
            MamaPrice&                          price,
            MamdaOrderBookPriceLevel::Side      side);
            
        /**
         * Add a price level to the orderbook.
         *
         * @param level The price level to add to the orderbook.
         *
         * @throw <MamdaOrderBookException> When an error is encountered during
         * book processing.
         */
        void addLevel    (const MamdaOrderBookPriceLevel&  level);

        /**
         * Update an existing level in the orderbook.
         *
         * @param level The details of the price level to update.
         *
         * @throw <MamdaOrderBookException> When an error is encountered during
         * book processing.
         */
        void updateLevel (const MamdaOrderBookPriceLevel&  level);

        /**
         * Delete a price level from the orderbook.
         *
         * @param level The price level to delete from the orderbook.
         *
         * @throw <MamdaOrderBookException> When an error is encountered during
         * book processing.
         */
        void deleteLevel (const MamdaOrderBookPriceLevel&  level);

        /**
         * Apply a delta to this (presumably) full book.
         *
         * @param deltaBook The delta to apply to the orderbook.
         *
         * @throw <MamdaOrderBookException> When an error is encountered during
         * book processing.
         */
        void apply (const MamdaOrderBook&  deltaBook);

        /**
         * Apply a delta to this book.
         *
         * @param delta The simple delta to apply to the orderbook.
         *
         * @throw <MamdaOrderBookException> When an error is encountered during
         * book processing.
         */
        void apply (const MamdaOrderBookBasicDelta&  delta);

        /**
         * Apply a delta to this book.
         *
         * @param delta The complex delta to apply to the orderbook.
         *
         * @throw <MamdaOrderBookException> When an error is encountered during
         * book processing.
         */
        void apply (const MamdaOrderBookBasicDeltaList&  delta);

        /**
         * Apply a market order delta to this book.
         *
         * @param delta The simple market order delta to apply to the orderbook.
         *
         * @throw <MamdaOrderBookException> When an error is encountered during
         * book processing.
         */
        void applyMarketOrder (const MamdaOrderBookBasicDelta&  delta);

        /**
         * Apply a market order delta to this book.
         *
         * @param delta The market ordercomplex delta to apply to the orderbook.
         *
         * @throw <MamdaOrderBookException> When an error is encountered during
         * book processing.
         */
        void applyMarketOrder (const MamdaOrderBookBasicDeltaList&  delta);
        
        /**
         * Copy a book.
         *
         * @param rhs The orderbook to copy.
         *
         * @throw <MamdaOrderBookException> When an error is encountered during
         * book processing.
         */
        void copy (const MamdaOrderBook&  rhs);

        /**
         * Set this order book to be a delta that would, when applied,
         * delete all of the fields in the bookToDelete.
         */
        void setAsDeltaDeleted (const MamdaOrderBook&  bookToDelete);

        /**
         * Set this order book to be a delta that would, when applied, be
         * the difference between two other books.
         */
        void setAsDeltaDifference (const MamdaOrderBook&  lhs,
                                   const MamdaOrderBook&  rhs);

        /**
         * Get the total number of price levels (both sides of order book).
         *
         * @return The total number of levels in the book.
         */
        size_t getTotalNumLevels() const;

        /**
         * Get the number of bid price levels.
         *
         * @return The total number of bid levels in the book.
         */
        size_t getNumBidLevels() const;

        /**
         * Get the number of ask price levels.
         *
         * @return The total number of ask levels in the book.
         */
        size_t getNumAskLevels() const;

         /**
         * Get the bid market orders.
         *
         * @return The market order bid level.
         */
        MamdaOrderBookPriceLevel* getBidMarketOrders() const;

        /**
         * Get the ask market orders.
         *
         * @return The market order ask level.
         */
        MamdaOrderBookPriceLevel* getAskMarketOrders() const;

        /**
         * Get the market orders for the specified side. Will return NULL if no
         * market orders exist in the book.
         *
         * @param side The market order side the price level to get.
         * @return The market order ask level.
         */
        MamdaOrderBookPriceLevel* getMarketOrdersSide (
            MamdaOrderBookPriceLevel::Side side);
            
        /**
         * Get the market orders for the specified side. Will create an empty level
         * if none exist.
         *
         * @param side The market order side the price level to get.
         * @return The market order ask level.
         */
        MamdaOrderBookPriceLevel* getOrCreateMarketOrdersSide (
            MamdaOrderBookPriceLevel::Side  side);
            
        /**
         * Detach the given level from the book
         *
         * @param level The level to detach
         */
        void detach (MamdaOrderBookPriceLevel* level);

        /**
         * Add the given entry to the detach list to be cleaned up
         *
         * @param entry The entry to detach
         */
        void detach (MamdaOrderBookEntry* entry);

        /**
         * Free resources associated with any detached price levels or entries, 
         * detached either through explicit calls to detach() or detached as a 
         * result or having no remaining entries.
         */
        void cleanupDetached ();

        /**
         * Get the "book time" (or "event time") of the last update.  The
         * book time is related to market data feeds: the time that the
         * market data feed suggests that the update actually happened.
         *
         * @return The book time of the last update.
         */
        const MamaDateTime& getBookTime() const;

            /**
         * Set the BookTime for this order book.
         *
         * @param bookTime The book time
         */
        void setBookTime(const MamaDateTime&  bookTime) const;
        
        /**
         * Set the MamaSourceDerivative for this order book.
         *
         * @param sourceDeriv The source derivative
         */
        void setSourceDerivative (const MamaSourceDerivative*  sourceDeriv);

        /**
         * Get the MamaSourceDerivative for this order book.
         * 
         * @return The source derivative.
         */
        const MamaSourceDerivative*  getSourceDerivative () const;

        /**
         * Get the MamaSource for this order book.
         * 
         * @return The source.
         */
        const MamaSource*  getSource () const;

        /**
         * Set the mamaQuality for this order book.
         *
         * @param quality The new quality.
         */
        void setQuality (mamaQuality  quality);

        /**
         * Get the mamaQuality for this order book.
         * 
         * @return The quality.
         */
        mamaQuality  getQuality () const;

        /**
         * Set the order book closure handle.
         *
         * @param closure The closure.
         */
        void setClosure (void*  closure);

        /**
         * Get the order book closure handle.
         * 
         * @return The orderbook closure.
         */
        void*  getClosure () const;

        /**
         * Equality operator.  Two books are equal if their symbols, price
         * levels and price level entries are identical.
         *
         * @param rhs The book to compare this book to.
         *
         * @return Whether the two books are equal.
         */
        bool operator== (const MamdaOrderBook&  rhs) const;

        /**
         * Non-equality operator.  Two books are equal if their symbols,
         * price levels and price level entries are identical.
         *
         * @param rhs The book to compare this book to.
         *
         * @return Whether the two books are not equal.
         */
        bool operator!= (const MamdaOrderBook&  rhs) const
        { return ! operator== (rhs); }

        /**
         * Add an entry to the order book and (if "delta" is not NULL)
         * record information about the delta related to this action.
         */
        void addEntry (
            MamdaOrderBookEntry*            entry,
            double                          price,
            MamdaOrderBookPriceLevel::Side  side,
            const MamaDateTime&             eventTime,
            MamdaOrderBookBasicDelta*       delta);

        /**
         * Add an entry to the order book and (if "delta" is not NULL)
         * record information about the delta related to this action.
         */
        void addEntry (
            MamdaOrderBookEntry*            entry,
            MamaPrice&                      price,
            MamdaOrderBookPriceLevel::Side  side,
            const MamaDateTime&             eventTime,
            MamdaOrderBookBasicDelta*       delta);
            
        /**
         * Add an entry to the order book and (if "delta" is not NULL)
         * record information about the delta related to this action.  The
         * new entry is returned.
         */
        MamdaOrderBookEntry* addEntry (
            const char*                     entryId,
            mama_quantity_t                 entrySize,
            double                          price,
            MamdaOrderBookPriceLevel::Side  side,
            const MamaDateTime&             eventTime,
            const MamaSourceDerivative*     sourceDeriv,
            MamdaOrderBookBasicDelta*       delta);

        /**
         * Add an entry to the order book and (if "delta" is not NULL)
         * record information about the delta related to this action.  The
         * new entry is returned.
         */
        MamdaOrderBookEntry* addEntry (
            const char*                     entryId,
            mama_quantity_t                 entrySize,
            MamaPrice&                      price,
            MamdaOrderBookPriceLevel::Side  side,
            const MamaDateTime&             eventTime,
            const MamaSourceDerivative*     sourceDeriv,
            MamdaOrderBookBasicDelta*       delta);
            
        /**
         * Update an entry in the order book and (if "delta" is not NULL)
         * record information about the delta related to this action.  If
         * the entry is not internally "wired" to the order book, a
         * MamdaOrderBookInvalidEntry exception is thrown.
         */
        void updateEntry (
            MamdaOrderBookEntry*            entry,
            mama_quantity_t                 size,
            const MamaDateTime&             eventTime,
            MamdaOrderBookBasicDelta*       delta);

        /**
         * Delete an entry in the order book and (if "delta" is not NULL)
         * record information about the delta related to this action.  If
         * the entry is not internally "wired" to the order book, a
         * MamdaOrderBookInvalidEntry exception is thrown.
         */
        void deleteEntry (
            MamdaOrderBookEntry*            entry,
            const MamaDateTime&             eventTime,
            MamdaOrderBookBasicDelta*       delta);

        /**
         * Add all entries from another book into this book.
         *
         * @param book    The source book to add.
         * @param filter  If not NULL, a filter to apply to each entry.
         * @param delta   An optional delta to collect the added entries.
         */
        void addEntriesFromBook (
            const MamdaOrderBook*           book,
            MamdaOrderBookEntryFilter*      filter,
            MamdaOrderBookBasicDeltaList*   delta);

        /**
         * Add all price levels from another book as entries (one per
         * price level) into this book using "source" as the entryId for
         * each entry.
         *
         * @param book    The source book to add.
         * @param source  The name to use as the entry ID.
         * @param delta   An optional delta to collect the added entries.
         */
        void addPriceLevelsFromBookAsEntries (
            const MamdaOrderBook*           book,
            const char*                     source,
            MamdaOrderBookBasicDeltaList*   delta);

        /**
         * Delete all entries in this book that have "source" as its MamaSource.
         *
         * @param source  The source to match.
         * @param delta   An optional delta to collect the deleted entries.
         */
        void deleteEntriesFromSource (
            const MamaSource*               source,
            MamdaOrderBookBasicDeltaList*   delta);

        /**
         * Re-evaluate the order book.  This would be performed after the
         * status of sources and/or subsources of an "aggregated order
         * book" (i.e. a book built from multiple sources) have changed.
         *
         * @return Whether the book info changed based on the re-evaluation.
         */
        bool reevaluate ();

        /**
         * Set whether this book needs a re-evaluation.
         */
        void setNeedsReevaluation (bool  need);

        /**
         * Get whether this book needs a re-evaluation.
         */
        bool getNeedsReevaluation () const;

        /**
         * Set whether to check the MamaSourceState when
         * adding/deleting/re-evaluating entries in the book.
         */
        void setCheckSourceState (bool  check);

        /**
         * Get whether to check the MamaSourceState when
         * adding/deleting/re-evaluating entries in the book.
         */
        bool getCheckSourceState () const;

        /**
         * Return the order book price level at "price" on "side" of the
         * order book.
         *
         * @param price  The price of the order book price level.
         * @param side   The side of the order book to search.
         * @return The order book price level or NULL if not found.
         *
         */
        MamdaOrderBookPriceLevel* getLevelAtPrice (
            double                          price,
            MamdaOrderBookPriceLevel::Side  side) const;

        /**
         * Return the order book price level at position "pos" in the
         * order book.
         *
         * @param pos   The position of the order book price level.
         * @param side  The side of the order book to search.
         * @return The order book price level or NULL if not found.
         *
         */
        MamdaOrderBookPriceLevel* getLevelAtPosition (
            mama_u32_t                      pos,
            MamdaOrderBookPriceLevel::Side  side) const;

        /**
         * Return the order book entry at position "pos" in the order book.
         *
         * @param pos  The position of the order book entry.
         * @param side The side of the order book to search
         * @return The order book entry or NULL if not found.
         */
        MamdaOrderBookEntry* getEntryAtPosition (
            mama_u32_t                      pos,
            MamdaOrderBookPriceLevel::Side  side) const;

        /**
         * Order book equality verification.  A MamdaOrderBookException is
         * thrown if the books are not equal, along with the reason for
         * the inequality.
         *
         * @param rhs The book to compare this book to.
         *
         * @throw MamdaOrderBookException When an error is encountered during
         * book processing.
         */
        void assertEqual (const MamdaOrderBook&  rhs) const;


        // Iterators

        class MAMDAOPTExpDLL bidIterator
        {
        protected:
            friend class MamdaOrderBook;
            struct bidIteratorImpl;
            bidIteratorImpl& mImpl;
        public:
            bidIterator ();
            bidIterator (const bidIterator& copy);
            bidIterator (const bidIteratorImpl& copy);
            ~bidIterator ();
            bidIterator&        operator=  (const bidIterator& rhs);
            bidIterator&        operator++ ();
            const bidIterator&  operator++ () const;
            bidIterator&        operator-- ();
            const bidIterator&  operator-- () const;
            bool                operator== (const bidIterator& rhs) const;
            bool                operator!= (const bidIterator& rhs) const;
            MamdaOrderBookPriceLevel*        operator*  ();
            const MamdaOrderBookPriceLevel*  operator*  () const;
        };

        class MAMDAOPTExpDLL askIterator
        {
        protected:
            friend class MamdaOrderBook;
            struct askIteratorImpl;
            askIteratorImpl& mImpl;
        public:
            askIterator ();
            askIterator (const askIterator& copy);
            askIterator (const askIteratorImpl& copy);
            ~askIterator ();
            askIterator&        operator=  (const askIterator& rhs);
            askIterator&        operator++ ();
            const askIterator&  operator++ () const;
            askIterator&        operator-- ();
            const askIterator&  operator-- () const;
            bool                operator== (const askIterator& rhs) const;
            bool                operator!= (const askIterator& rhs) const;
            MamdaOrderBookPriceLevel*        operator*  ();
            const MamdaOrderBookPriceLevel*  operator*  () const;
        };

        class MAMDAOPTExpDLL bidEntryIterator
        {
        protected:
            friend class MamdaOrderBook;
            struct bidEntryIteratorImpl;
            bidEntryIteratorImpl& mImpl;
        public:
            bidEntryIterator ();
            bidEntryIterator (const bidEntryIterator& copy);
            bidEntryIterator (const bidEntryIteratorImpl& copy);
            ~bidEntryIterator ();
            bidEntryIterator&       operator=  (const bidEntryIterator& rhs);
            bidEntryIterator&       operator++ ();
            const bidEntryIterator& operator++ () const;
            bool                    operator== (const bidEntryIterator& rhs) const;
            bool                    operator!= (const bidEntryIterator& rhs) const;
            MamdaOrderBookEntry*        operator*  ();
            const MamdaOrderBookEntry*  operator*  () const;
        };

        class MAMDAOPTExpDLL askEntryIterator
        {
        protected:
            friend class MamdaOrderBook;
            struct askEntryIteratorImpl;
            askEntryIteratorImpl& mImpl;
        public:
            askEntryIterator ();
            askEntryIterator (const askEntryIterator& copy);
            askEntryIterator (const askEntryIteratorImpl& copy);
            ~askEntryIterator ();
            askEntryIterator&       operator=  (const askEntryIterator& rhs);
            askEntryIterator&       operator++ ();
            const askEntryIterator& operator++ () const;
            bool                    operator== (const askEntryIterator& rhs) const;
            bool                    operator!= (const askEntryIterator& rhs) const;
            MamdaOrderBookEntry*        operator*  ();
            const MamdaOrderBookEntry*  operator*  () const;
        };

        typedef  const bidIterator       constBidIterator;
        typedef  const askIterator       constAskIterator;
        typedef  const bidEntryIterator  constBidEntryIterator;
        typedef  const askEntryIterator  constAskEntryIterator;

        bidIterator       bidBegin();
        constBidIterator  bidBegin() const;
        bidIterator       bidEnd();
        constBidIterator  bidEnd() const;
        askIterator       askBegin();
        constAskIterator  askBegin() const;
        askIterator       askEnd();
        constAskIterator  askEnd() const;

        bidEntryIterator       bidEntryBegin();
        constBidEntryIterator  bidEntryBegin() const;
        bidEntryIterator       bidEntryEnd();
        constBidEntryIterator  bidEntryEnd() const;
        askEntryIterator       askEntryBegin();
        constAskEntryIterator  askEntryBegin() const;
        askEntryIterator       askEntryEnd();
        constAskEntryIterator  askEntryEnd() const;

        /**
         * Set whether the order book is in a consistent or an an
         * inconsistent state. This method is typically called from within the
         * <code>MamdaOrderBookListener</code> in response to sequence number gap
         * detection and subsequent recovery from a gap event.
         *
         * @param isConsistent Whether the book is in a consistent state.
         */
        void setIsConsistent (bool  isConsistent);

        /**
         * Get whether the order book is in a consistent or an an
         * inconsistent state. A book is marked as being inconsistent by the
         * <code>MamdaOrderBookListener</code> whenever a sequence number gap in the
         * book updates is detected. The order book will be marked as consistent
         * once again once a recap for the book is received by the
         * <code>MamdaOrderBookListener</code>.
         *
         * @return Whether the book is in a consistent state.
         */
        bool getIsConsistent () const;

        /**
         * Dump the order book to the output stream.
         *
         * @param output The <code>ostream</code> to write the orderbook to.
         */
        void dump (ostream&  output) const;

        /**
         * Enforce strict checking of order book modifications (at the
         * expense of some performance).  This setting is passed on to the
         * MamdaOrderBookPriceLevel and MamdaOrderBookEntry classes.
         */
        static void setStrictChecking (bool strict);
        
        /**
         * Enable the generation of book deltas for this book. When delta generation is enabled
         * changes to the book are saved and can be popultaed to MamaMsgs. 
         * @param publish Whether book delta generation is enabled.
         */    
        void generateDeltaMsgs (bool generate);
        
        /**
         * Get whether book delta generation is enabled
         * @return Whether book delta generation is enabled.
         */
        bool getGenerateDeltaMsgs();
        
        /**
         * Populate a MamaMsg of the changes to this order book. 
         * This will include the changes from the last time this function was called
         * or all changes from the initial state. 
         *  @param msg A MamaMsg ref containing all changes to the current book.
         */   
        bool populateDelta (MamaMsg& msg);

        /**
         * Popuklate a MamaMsg with the current state of this order book.
         * @param msg A MamaMsg containing all book, price and entry 
         * (if applicable) details of the current book. 
         */  
        void populateRecap (MamaMsg& msg);

        /**
         * For book delta generation. 
         * Add a delta to the order book delta list for the publishing of
         * order book data
         * @param entry MamdaOrderBookEntry where change occurred.
         * @param level MamdaOrderBookPriceLevel where change occurred.
         * @param plDeltaSize Pricelevel size change.
         * @param plAction Pricelevel action.
         * @param entAction Entry action.     
         */ 
        void addDelta (MamdaOrderBookEntry*              entry,
                       MamdaOrderBookPriceLevel*         level,
                       mama_quantity_t                   plDeltaSize,
                       MamdaOrderBookPriceLevel::Action  plAction,
                       MamdaOrderBookEntry::Action       entAction);
                       
        /**
         * clear the delta list using for storing generated deltas
         */   
        void clearDeltaList();
        
        /**
         * Set the orderbook contributors
         * @param bookContributors The orderbook contributors
         */
        void setBookContributors (const char* bookContributors);

        /**
         * Get the orderbook contributors
         * @return The orderbook contributors
         **/
        const char* getBookContributors () const;

        /**
         * Is the orderbook contributors set
         * @return Whether this orderbook has a list of contributors
         **/
        bool hasBookContributors () const;

        /**
         * Get whether the books contributors have been modified.
         * @return Whether the book contributors have been modified.
         */
        bool getBookContributorsModified () const;

        /**
         * Set whether the books contributors have been modified.
         * @param modifies Whether the book contributors have been modified.
         */
        void setBookContributorsModified (bool modified);

    private:
        struct MamdaOrderBookImpl;
        MamdaOrderBookImpl& mImpl;
    };

} // namespace

#endif // MamdaOrderBookH