2 * Copyright (c) 2005, David McPaul
5 * Redistribution and use in source and binary forms, with or without modification,
6 * are permitted provided that the following conditions are met:
8 * * Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 * IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
18 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
19 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
21 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
22 * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
23 * OF THE POSSIBILITY OF SUCH DAMAGE.
26 #include "ChunkSuperIndex.h"
28 ChunkSuperIndex::ChunkSuperIndex()
32 ChunkSuperIndex::~ChunkSuperIndex()
34 theChunkIndexArray
.erase(theChunkIndexArray
.begin(),theChunkIndexArray
.end());
37 void ChunkSuperIndex::AddChunkIndex(uint32 stream
, uint32 chunkid
, off_t chunk_start
)
39 ChunkIndexPtr aChunkIndexPtr
;
40 aChunkIndexPtr
= new ChunkIndex
;
41 aChunkIndexPtr
->stream
= stream
;
42 aChunkIndexPtr
->chunkid
= chunkid
;
43 aChunkIndexPtr
->chunk_start
= chunk_start
;
45 theChunkIndexArray
[chunk_start
] = aChunkIndexPtr
;
48 uint32
ChunkSuperIndex::getChunkSize(uint32 stream
, uint32 chunkid
, off_t chunk_start
)
50 ChunkIndexPtr aChunkIndexPtr
= theChunkIndexArray
[chunk_start
];
53 // Find next chunkIndex
54 ChunkIndexPtr nextChunkIndex
;
56 nextChunkIndex
= theChunkIndexArray
.upper_bound(chunk_start
)->second
;
60 return (nextChunkIndex
->chunk_start
- aChunkIndexPtr
->chunk_start
);