| 1 |
/*=========================================================================== |
| 2 |
FILE: |
| 3 |
ProtocolLog.h |
| 4 |
|
| 5 |
DESCRIPTION: |
| 6 |
Simple protocol 'log' class declaration |
| 7 |
|
| 8 |
PUBLIC CLASSES AND METHODS: |
| 9 |
cProtocolLog |
| 10 |
This class stores protocol buffers in to a flat array (actually a |
| 11 |
double-ended queue) so that they can be accessed by other objects |
| 12 |
during the flow of normal processing. Note that the storage is |
| 13 |
in-memory and therefore finite |
| 14 |
|
| 15 |
Copyright (c) 2012, Code Aurora Forum. All rights reserved. |
| 16 |
|
| 17 |
Redistribution and use in source and binary forms, with or without |
| 18 |
modification, are permitted provided that the following conditions are met: |
| 19 |
* Redistributions of source code must retain the above copyright |
| 20 |
notice, this list of conditions and the following disclaimer. |
| 21 |
* Redistributions in binary form must reproduce the above copyright |
| 22 |
notice, this list of conditions and the following disclaimer in the |
| 23 |
documentation and/or other materials provided with the distribution. |
| 24 |
* Neither the name of Code Aurora Forum nor |
| 25 |
the names of its contributors may be used to endorse or promote |
| 26 |
products derived from this software without specific prior written |
| 27 |
permission. |
| 28 |
|
| 29 |
|
| 30 |
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 31 |
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 32 |
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 33 |
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE |
| 34 |
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 35 |
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 36 |
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 37 |
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 38 |
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 39 |
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 40 |
POSSIBILITY OF SUCH DAMAGE. |
| 41 |
===========================================================================*/ |
| 42 |
|
| 43 |
//--------------------------------------------------------------------------- |
| 44 |
// Pragmas |
| 45 |
//--------------------------------------------------------------------------- |
| 46 |
#pragma once |
| 47 |
|
| 48 |
//--------------------------------------------------------------------------- |
| 49 |
// Include Files |
| 50 |
//--------------------------------------------------------------------------- |
| 51 |
#include "ProtocolBuffer.h" |
| 52 |
#include "SyncQueue.h" |
| 53 |
|
| 54 |
#include <climits> |
| 55 |
|
| 56 |
//--------------------------------------------------------------------------- |
| 57 |
// Definitions |
| 58 |
//--------------------------------------------------------------------------- |
| 59 |
const ULONG INVALID_LOG_INDEX = ULONG_MAX; |
| 60 |
|
| 61 |
/*=========================================================================*/ |
| 62 |
// Class cProtocolLog |
| 63 |
/*=========================================================================*/ |
| 64 |
class cProtocolLog |
| 65 |
{ |
| 66 |
public: |
| 67 |
// Constructor |
| 68 |
cProtocolLog( ULONG maxBuffers ); |
| 69 |
|
| 70 |
// Destructor |
| 71 |
virtual ~cProtocolLog(); |
| 72 |
|
| 73 |
// Add an protocol buffer to the end of the log |
| 74 |
virtual ULONG AddBuffer( sProtocolBuffer & buf ); |
| 75 |
|
| 76 |
// Return the protocol buffer at the given index from the log |
| 77 |
virtual sProtocolBuffer GetBuffer( ULONG idx ) const; |
| 78 |
|
| 79 |
// Return the underlying signal event |
| 80 |
virtual cEvent & GetSignalEvent() const; |
| 81 |
|
| 82 |
// Return the total number of buffers added to the log |
| 83 |
virtual ULONG GetCount() const; |
| 84 |
|
| 85 |
// Clear the log |
| 86 |
virtual void Clear(); |
| 87 |
|
| 88 |
protected: |
| 89 |
/* The underlying 'log' */ |
| 90 |
cSyncQueue <sProtocolBuffer> mLog; |
| 91 |
}; |