diff options
| author | Mike Buland <eichlan@xagasoft.com> | 2010-05-26 05:35:02 +0000 |
|---|---|---|
| committer | Mike Buland <eichlan@xagasoft.com> | 2010-05-26 05:35:02 +0000 |
| commit | b1522d279d22725a731cb8db93ec2d077028374c (patch) | |
| tree | 9ad5f2471fdac3a9bbaddaf513ede562d87b8438 /src/myriad.h | |
| parent | 24ab24777d7cd72b7ff35a9d02cb43e26f006b0d (diff) | |
| download | libbu++-b1522d279d22725a731cb8db93ec2d077028374c.tar.gz libbu++-b1522d279d22725a731cb8db93ec2d077028374c.tar.bz2 libbu++-b1522d279d22725a731cb8db93ec2d077028374c.tar.xz libbu++-b1522d279d22725a731cb8db93ec2d077028374c.zip | |
More tweaks and informational functions.
Diffstat (limited to 'src/myriad.h')
| -rw-r--r-- | src/myriad.h | 58 |
1 files changed, 46 insertions, 12 deletions
diff --git a/src/myriad.h b/src/myriad.h index b5cd18c..53a42b8 100644 --- a/src/myriad.h +++ b/src/myriad.h | |||
| @@ -26,16 +26,22 @@ namespace Bu | |||
| 26 | invalidFormat, | 26 | invalidFormat, |
| 27 | badVersion, | 27 | badVersion, |
| 28 | invalidWordSize, | 28 | invalidWordSize, |
| 29 | noSuchStream | 29 | noSuchStream, |
| 30 | streamExists, | ||
| 31 | invalidStreamId, | ||
| 32 | protectedStream | ||
| 30 | }; | 33 | }; |
| 31 | subExceptionDeclEnd() | 34 | subExceptionDeclEnd() |
| 32 | 35 | ||
| 33 | /** | 36 | /** |
| 34 | * Numerically Indexed Data Streams. This is a working name so I can | 37 | * Myriad block-allocated stream multiplexing system. This is a system for |
| 35 | * actually get some code written instead of agonizing over the name. | 38 | * creating streams that contain other streams in a flexible and lightweight |
| 36 | * | 39 | * manner. Basically, you can create a file (or any other stream) that can |
| 37 | * This is a system for creating streams that contain other streams in | 40 | * store any number of flexible, growing streams. The streams within the |
| 38 | * a flexible block-allocated system. | 41 | * Myriad stream are automatically numbered, not named. This works more |
| 42 | * or less like a filesystem, but without the extra layer for managing | ||
| 43 | * file and directory links. This would actually be very easy to add | ||
| 44 | * on top of Myriad, but is not required. | ||
| 39 | * | 45 | * |
| 40 | * Header format is as follows: | 46 | * Header format is as follows: |
| 41 | * | 47 | * |
| @@ -78,23 +84,43 @@ namespace Bu | |||
| 78 | { | 84 | { |
| 79 | friend class MyriadStream; | 85 | friend class MyriadStream; |
| 80 | public: | 86 | public: |
| 87 | /** | ||
| 88 | * Create a Myriad object that uses the given stream to store data. | ||
| 89 | * This stream must be random access. The block size and preallocate | ||
| 90 | * values passed in are values that will be used if the given stream | ||
| 91 | * is empty. In that case the stream will be "formatted" for myriad | ||
| 92 | * with the specified block size. If there is already a viable Myriad | ||
| 93 | * format present in the stream, then the blocksize and preallocate | ||
| 94 | * values will be ignored and the values from the stream will be used | ||
| 95 | * instead. If the stream doesn't appear to be Myriad formatted an | ||
| 96 | * exception will be thrown. | ||
| 97 | */ | ||
| 81 | Myriad( Bu::Stream &sStore, int iBlockSize=512, int iPreallocate=8 ); | 98 | Myriad( Bu::Stream &sStore, int iBlockSize=512, int iPreallocate=8 ); |
| 82 | virtual ~Myriad(); | 99 | virtual ~Myriad(); |
| 83 | 100 | ||
| 84 | /** | 101 | /** |
| 85 | * Create a new Myriad system in the assosiated stream. This should be | 102 | * Destroy whatever data may be in the base stream and create a new |
| 86 | * used carefully, it will destroy all data already within the stream. | 103 | * Myriad system there with the given blocksize. Use this with care, |
| 87 | * More options will probably be added soon. | 104 | * it will destroy anything that was already in the stream, and |
| 105 | * generally, should not ever have to be used. | ||
| 88 | */ | 106 | */ |
| 89 | void initialize( int iBlockSize, int iPreAllocate=1 ); | 107 | void initialize( int iBlockSize, int iPreAllocate=1 ); |
| 90 | 108 | ||
| 91 | /** | 109 | /** |
| 92 | * Create a new stream within the Myriad system. The ID of the new stream | 110 | * Create a new stream within the Myriad system. The ID of the new |
| 93 | * is returned. | 111 | * stream is returned. |
| 94 | */ | 112 | */ |
| 95 | int createStream( int iPreAllocate=1 ); | 113 | int createStream( int iPreAllocate=1 ); |
| 96 | 114 | ||
| 97 | /** | 115 | /** |
| 116 | * Create a new stream within the Myriad system with a given id. The | ||
| 117 | * id that you provide will be the new id of the stream unless it's | ||
| 118 | * already used, in which case an error is thrown. This is primarilly | ||
| 119 | * useful when copying an old Myriad file into a new one. | ||
| 120 | */ | ||
| 121 | int createStreamWithId( int iId, int iPreAllocate=1 ); | ||
| 122 | |||
| 123 | /** | ||
| 98 | * Delete a stream that's already within the Myriad. | 124 | * Delete a stream that's already within the Myriad. |
| 99 | */ | 125 | */ |
| 100 | void deleteStream( int iId ); | 126 | void deleteStream( int iId ); |
| @@ -104,10 +130,13 @@ namespace Bu | |||
| 104 | */ | 130 | */ |
| 105 | MyriadStream openStream( int iId ); | 131 | MyriadStream openStream( int iId ); |
| 106 | 132 | ||
| 133 | Bu::Array<int> getStreamIds(); | ||
| 134 | int getStreamSize( int iId ); | ||
| 135 | |||
| 136 | int getNumStreams(); | ||
| 107 | int getBlockSize(); | 137 | int getBlockSize(); |
| 108 | int getNumBlocks(); | 138 | int getNumBlocks(); |
| 109 | int getNumUsedBlocks(); | 139 | int getNumUsedBlocks(); |
| 110 | int getBlockOverhead(); | ||
| 111 | 140 | ||
| 112 | /** | 141 | /** |
| 113 | * Syncronize the header data, etc. with the storage stream. It's not | 142 | * Syncronize the header data, etc. with the storage stream. It's not |
| @@ -115,6 +144,11 @@ namespace Bu | |||
| 115 | */ | 144 | */ |
| 116 | void sync(); | 145 | void sync(); |
| 117 | 146 | ||
| 147 | /** | ||
| 148 | * Read the first few bytes from the given stream and return true/false | ||
| 149 | * depending on weather or not it's a Myriad stream. This will throw | ||
| 150 | * an exception if the stream is empty, or is not random access. | ||
| 151 | */ | ||
| 118 | static bool isMyriad( Bu::Stream &sStore ); | 152 | static bool isMyriad( Bu::Stream &sStore ); |
| 119 | 153 | ||
| 120 | private: | 154 | private: |
