| 1 | /*************************************************************************** |
| 2 | cpage.h - header file for cpage.cxx. |
| 3 | ------------------- |
| 4 | begin : Wed Sep 25 18:58:35 BST 2002 |
| 5 | copyright : (C) 2002 by Greg Reynolds, Jim Hawkridge |
| 6 | email : [email protected] |
| 7 | ***************************************************************************/ |
| 8 | |
| 9 | /*************************************************************************** |
| 10 | * * |
| 11 | * This program is free software; you can redistribute it and/or modify * |
| 12 | * it under the terms of the GNU General Public License as published by * |
| 13 | * the Free Software Foundation; either version 2 of the License, or * |
| 14 | * (at your option) any later version. * |
| 15 | * * |
| 16 | ***************************************************************************/ |
| 17 | #include <assert.h> |
| 18 | #include <string.h> |
| 19 | #include <stdlib.h> |
| 20 | |
| 21 | class CPage { |
| 22 | |
| 23 | public: |
| 24 | CPage(int nSize); |
| 25 | ~CPage(); |
| 26 | void display(); |
| 27 | |
| 28 | |
| 29 | inline void setAddress(long lAddress); |
| 30 | inline long getAddress(); |
| 31 | inline long getSize(); |
| 32 | inline void setByte(int nIndex, unsigned char ucVal); |
| 33 | inline unsigned char getByte(int nIndex); |
| 34 | inline void setNext(CPage* pNext); |
| 35 | inline CPage* getNext(); |
| 36 | inline unsigned char* getPage(); |
| 37 | |
| 38 | protected: |
| 39 | long m_lAddress; |
| 40 | int m_nSize; |
| 41 | unsigned char* m_pData; |
| 42 | |
| 43 | CPage* m_pNext; |
| 44 | }; |
| 45 | |
| 46 | inline unsigned char* CPage::getPage() |
| 47 | { |
| 48 | assert( m_pData ); |
| 49 | return m_pData; |
| 50 | } |
| 51 | |
| 52 | inline void CPage::setNext(CPage* pNext) |
| 53 | { |
| 54 | assert( pNext ); |
| 55 | m_pNext = pNext; |
| 56 | } |
| 57 | |
| 58 | inline CPage* CPage::getNext() |
| 59 | { |
| 60 | return m_pNext; |
| 61 | } |
| 62 | |
| 63 | inline unsigned char CPage::getByte(int nIndex) |
| 64 | { |
| 65 | assert( nIndex < m_nSize ); |
| 66 | return m_pData[nIndex]; |
| 67 | } |
| 68 | |
| 69 | inline void CPage::setByte(int nIndex, unsigned char ucVal) |
| 70 | { |
| 71 | assert( nIndex < m_nSize ); |
| 72 | m_pData[nIndex] = ucVal; |
| 73 | } |
| 74 | |
| 75 | inline void CPage::setAddress(long lAddress) |
| 76 | { |
| 77 | assert( lAddress >= 0 ); |
| 78 | m_lAddress = lAddress; |
| 79 | } |
| 80 | |
| 81 | inline long CPage::getAddress() |
| 82 | { |
| 83 | return m_lAddress; |
| 84 | } |
| 85 | |
| 86 | inline long CPage::getSize() |
| 87 | { |
| 88 | return m_nSize; |
| 89 | } |
| 90 |