diff options
| author | Mike Buland <eichlan@xagasoft.com> | 2010-05-15 07:44:10 +0000 |
|---|---|---|
| committer | Mike Buland <eichlan@xagasoft.com> | 2010-05-15 07:44:10 +0000 |
| commit | 306b80c1cf9ab490a83b36d3e7cf07e09f9e5d68 (patch) | |
| tree | 32c35f8507edb4ea403f4ebc4b625c1096f6f384 /src/nids.h | |
| parent | 11413d228bae2919fe69c83b74c7ff49209dd65a (diff) | |
| download | libbu++-306b80c1cf9ab490a83b36d3e7cf07e09f9e5d68.tar.gz libbu++-306b80c1cf9ab490a83b36d3e7cf07e09f9e5d68.tar.bz2 libbu++-306b80c1cf9ab490a83b36d3e7cf07e09f9e5d68.tar.xz libbu++-306b80c1cf9ab490a83b36d3e7cf07e09f9e5d68.zip | |
mkunit.sh was a little dumb, it didn't handle a number of things correctly.
I've written a new program that basically does the same thing, only it's much
more clever, and does many more of the translations and conversions better,
including the #line directives. Also, I dropped nids, we don't need it anymore.
But now I'm ready to write some serious tests for myriad.
Diffstat (limited to 'src/nids.h')
| -rw-r--r-- | src/nids.h | 121 |
1 files changed, 0 insertions, 121 deletions
diff --git a/src/nids.h b/src/nids.h deleted file mode 100644 index 0976e67..0000000 --- a/src/nids.h +++ /dev/null | |||
| @@ -1,121 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * Copyright (C) 2007-2010 Xagasoft, All rights reserved. | ||
| 3 | * | ||
| 4 | * This file is part of the libbu++ library and is released under the | ||
| 5 | * terms of the license contained in the file LICENSE. | ||
| 6 | */ | ||
| 7 | |||
| 8 | #ifndef BU_NIDS_H | ||
| 9 | #define BU_NIDS_H | ||
| 10 | |||
| 11 | #include <stdint.h> | ||
| 12 | #include "bu/bitstring.h" | ||
| 13 | #include "bu/exceptionbase.h" | ||
| 14 | |||
| 15 | namespace Bu | ||
| 16 | { | ||
| 17 | class Stream; | ||
| 18 | class NidsStream; | ||
| 19 | |||
| 20 | subExceptionDecl( NidsException ) | ||
| 21 | |||
| 22 | /** | ||
| 23 | * Numerically Indexed Data Streams. This is a working name so I can | ||
| 24 | * actually get some code written instead of agonizing over the name. | ||
| 25 | * | ||
| 26 | * This is a system for creating streams that contain other streams in | ||
| 27 | * a flexible block-allocated system. | ||
| 28 | */ | ||
| 29 | class Nids | ||
| 30 | { | ||
| 31 | friend class NidsStream; | ||
| 32 | public: | ||
| 33 | Nids( Bu::Stream &sStore ); | ||
| 34 | virtual ~Nids(); | ||
| 35 | |||
| 36 | /** | ||
| 37 | * Initialize this object based on the data already in the assosiated | ||
| 38 | * stream. This will be called automatically for you if you forget, | ||
| 39 | * but if you want to pre-initialize for some reason, just call this | ||
| 40 | * once before you actually start doing anything with your Nids. | ||
| 41 | */ | ||
| 42 | void initialize(); | ||
| 43 | |||
| 44 | /** | ||
| 45 | * Create a new Nids system in the assosiated stream. This should be | ||
| 46 | * used carefully, it will destroy all data already within the stream. | ||
| 47 | * More options will probably be added soon. | ||
| 48 | */ | ||
| 49 | void initialize( int iBlockSize, int iPreAllocate=1 ); | ||
| 50 | |||
| 51 | /** | ||
| 52 | * Create a new stream within the Nids system. The ID of the new stream | ||
| 53 | * is returned. | ||
| 54 | */ | ||
| 55 | int createStream( int iPreAllocate=1 ); | ||
| 56 | |||
| 57 | /** | ||
| 58 | * Delete a stream that's already within the Nids. | ||
| 59 | */ | ||
| 60 | void deleteStream( int iID ); | ||
| 61 | |||
| 62 | /** | ||
| 63 | * Return a new Stream object assosiated with the given stream ID. | ||
| 64 | */ | ||
| 65 | NidsStream openStream( int iID ); | ||
| 66 | |||
| 67 | int getBlockSize(); | ||
| 68 | int getNumBlocks(); | ||
| 69 | int getNumUsedBlocks(); | ||
| 70 | int getBlockStart(); | ||
| 71 | int getBlockOverhead(); | ||
| 72 | |||
| 73 | /** | ||
| 74 | * Syncronize the header data, etc. with the storage stream. It's not | ||
| 75 | * a bad idea to call this periodically. | ||
| 76 | */ | ||
| 77 | void sync(); | ||
| 78 | |||
| 79 | private: | ||
| 80 | typedef struct Block | ||
| 81 | { | ||
| 82 | uint32_t uFirstBlock; | ||
| 83 | uint32_t uNextBlock; | ||
| 84 | // uint32_t uPrevBlock; | ||
| 85 | uint32_t uBytesUsed; | ||
| 86 | // uint32_t uReserved; | ||
| 87 | unsigned char pData[0]; | ||
| 88 | } Block; | ||
| 89 | |||
| 90 | enum | ||
| 91 | { | ||
| 92 | blockUnused = 0xFFFFFFFFUL | ||
| 93 | }; | ||
| 94 | |||
| 95 | void initBlock( uint32_t uPos, uint32_t uFirstBlock, | ||
| 96 | /*uint32_t uPrevBlock,*/ bool bNew=false ); | ||
| 97 | uint32_t createBlock( uint32_t uFirstBlock, /*uint32_t uPrevBlock,*/ | ||
| 98 | int iPreAllocate=1 ); | ||
| 99 | void getBlock( uint32_t uIndex, Block *pBlock ); | ||
| 100 | void setBlock( uint32_t uIndex, Block *pBlock ); | ||
| 101 | void updateStreamSize( uint32_t uIndex, uint32_t uSize ); | ||
| 102 | uint32_t getNextBlock( uint32_t uIndex, Block *pBlock, | ||
| 103 | bool bCreate=true); | ||
| 104 | |||
| 105 | void updateHeader(); | ||
| 106 | |||
| 107 | // Block allocation routines | ||
| 108 | Block *newBlock(); | ||
| 109 | void deleteBlock( Block *pBlock ); | ||
| 110 | |||
| 111 | private: | ||
| 112 | Bu::Stream &sStore; | ||
| 113 | int iBlockSize; | ||
| 114 | int iBlocks; | ||
| 115 | int iBlockStart; | ||
| 116 | int iUsed; | ||
| 117 | Bu::BitString bsBlockUsed; | ||
| 118 | }; | ||
| 119 | }; | ||
| 120 | |||
| 121 | #endif | ||
