/usr/include/stxxl/bits/mng/bid.h is in libstxxl-dev 1.3.1-5ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | /***************************************************************************
* include/stxxl/bits/mng/bid.h
*
* Part of the STXXL. See http://stxxl.sourceforge.net
*
* Copyright (C) 2002-2004 Roman Dementiev <dementiev@mpi-sb.mpg.de>
* Copyright (C) 2009, 2010 Andreas Beckmann <beckmann@cs.uni-frankfurt.de>
* Copyright (C) 2009 Johannes Singler <singler@ira.uka.de>
*
* Distributed under the Boost Software License, Version 1.0.
* (See accompanying file LICENSE_1_0.txt or copy at
* http://www.boost.org/LICENSE_1_0.txt)
**************************************************************************/
#ifndef STXXL_BID_HEADER
#define STXXL_BID_HEADER
#include <cstring>
#include <ostream>
#include <iomanip>
#include <stxxl/bits/io/file.h>
#include <stxxl/bits/common/utils.h>
#ifndef STXXL_VERBOSE_BLOCK_LIFE_CYCLE
#define STXXL_VERBOSE_BLOCK_LIFE_CYCLE STXXL_VERBOSE2
#endif
#define FMT_BID(_bid_) "[" << (_bid_).storage->get_allocator_id() << "]0x" << std::hex << std::setfill('0') << std::setw(8) << (_bid_).offset << "/0x" << std::setw(8) << (_bid_).size
__STXXL_BEGIN_NAMESPACE
//! \ingroup mnglayer
//! \{
//! \brief Block identifier class
//! Stores block identity, given by file and offset within the file
template <unsigned SIZE>
struct BID
{
enum
{
size = SIZE, //!< Block size
t_size = SIZE //!< Blocks size, given by the parameter
};
file * storage; //!< pointer to the file of the block
stxxl::int64 offset; //!< offset within the file of the block
BID() : storage(NULL), offset(0)
{ }
bool valid() const
{
return storage != NULL;
}
BID(file * s, stxxl::int64 o) : storage(s), offset(o)
{ }
BID(const BID & obj) : storage(obj.storage), offset(obj.offset)
{ }
template <unsigned BlockSize>
explicit BID(const BID<BlockSize> & obj) : storage(obj.storage), offset(obj.offset)
{ }
template <unsigned BlockSize>
BID & operator = (const BID<BlockSize> & obj)
{
storage = obj.storage;
offset = obj.offset;
return *this;
}
bool is_managed() const
{
return storage->get_allocator_id() != file::NO_ALLOCATOR;
}
};
//! \brief Specialization of block identifier class (BID) for variable size block size
//! Stores block identity, given by file, offset within the file, and size of the block
template <>
struct BID<0>
{
file * storage; //!< pointer to the file of the block
stxxl::int64 offset; //!< offset within the file of the block
unsigned size; //!< size of the block in bytes
enum
{
t_size = 0 //!< Blocks size, given by the parameter
};
BID() : storage(NULL), offset(0), size(0)
{ }
BID(file * f, stxxl::int64 o, unsigned s) : storage(f), offset(o), size(s)
{ }
bool valid() const
{
return storage;
}
};
template <unsigned blk_sz>
bool operator == (const BID<blk_sz> & a, const BID<blk_sz> & b)
{
return (a.storage == b.storage) && (a.offset == b.offset) && (a.size == b.size);
}
template <unsigned blk_sz>
bool operator != (const BID<blk_sz> & a, const BID<blk_sz> & b)
{
return (a.storage != b.storage) || (a.offset != b.offset) || (a.size != b.size);
}
template <unsigned blk_sz>
std::ostream & operator << (std::ostream & s, const BID<blk_sz> & bid)
{
// [0x12345678|0]0x00100000/0x00010000
// [file ptr|file id]offset/size
s << "[" << bid.storage << "|";
if (bid.storage)
s << bid.storage->get_allocator_id();
else
s << "?";
s << "]0x" << std::hex << std::setfill('0') << std::setw(8) << bid.offset << "/0x" << std::setw(8) << bid.size << std::dec;
return s;
}
#if 0
template <unsigned BLK_SIZE>
class BIDArray : public std::vector<BID<BLK_SIZE> >
{
public:
BIDArray(std::vector<BID<BLK_SIZE> >::size_type size = 0) : std::vector<BID<BLK_SIZE> >(size) { }
};
#endif
template <unsigned BLK_SIZE>
class BIDArray : private noncopyable
{
protected:
unsigned_type _size;
BID<BLK_SIZE> * array;
public:
typedef BID<BLK_SIZE> & reference;
typedef BID<BLK_SIZE> * iterator;
typedef const BID<BLK_SIZE> * const_iterator;
BIDArray() : _size(0), array(NULL)
{ }
iterator begin()
{
return array;
}
iterator end()
{
return array + _size;
}
BIDArray(unsigned_type size) : _size(size)
{
array = new BID<BLK_SIZE>[size];
}
unsigned_type size() const
{
return _size;
}
reference operator [] (int_type i)
{
return array[i];
}
void resize(unsigned_type newsize)
{
if (array)
{
STXXL_MSG("Warning: resizing nonempty BIDArray");
BID<BLK_SIZE> * tmp = array;
array = new BID<BLK_SIZE>[newsize];
memcpy((void *)array, (void *)tmp,
sizeof(BID<BLK_SIZE>) * (STXXL_MIN(_size, newsize)));
delete[] tmp;
_size = newsize;
}
else
{
array = new BID<BLK_SIZE>[newsize];
_size = newsize;
}
}
~BIDArray()
{
if (array)
delete[] array;
}
};
//! \}
__STXXL_END_NAMESPACE
#endif // !STXXL_BID_HEADER
// vim: et:ts=4:sw=4
|