32 #ifndef __BASE_TIMEBUF_HH__ 33 #define __BASE_TIMEBUF_HH__ 54 assert (idx >= -past && idx <= future);
73 : buffer(buf), index(i)
81 : buffer(i.buffer), index(i.index)
119 return wire(
this, i);
132 return wire(
this, i);
141 : past(p), future(f), size(past + future + 1),
142 data(new char[size * sizeof(T)]), index(size), base(0)
144 assert(past >= 0 && future >= 0);
146 for (
unsigned i = 0;
i <
size;
i++) {
148 std::memset(ptr, 0,
sizeof(T));
163 for (
unsigned i = 0;
i <
size; ++
i)
164 (reinterpret_cast<T *>(index[
i]))->~T();
185 if (ptr >= (
int)size)
187 (
reinterpret_cast<T *
>(index[ptr]))->~T();
188 std::memset(index[ptr], 0,
sizeof(T));
200 int vector_index = idx +
base;
201 if (vector_index >= (
int)size) {
202 vector_index -=
size;
203 }
else if (vector_index < 0) {
204 vector_index +=
size;
215 return reinterpret_cast<T *
>(index[vector_index]);
222 return reinterpret_cast<T &
>(*index[vector_index]);
229 return reinterpret_cast<const T &
>(*index[vector_index]);
236 return wire(
this, idx);
241 return wire(
this, 0);
250 #endif // __BASE_TIMEBUF_HH__
int calculateVectorIndex(int idx) const
const wire & operator+=(int offset)
wire(TimeBuffer< T > *buf, int i)
std::vector< char * > index
void valid(int idx) const
const wire & operator=(const wire &i)
const wire & operator-=(int offset)
const wire & operator=(int idx)