| 1 |
root |
1.1 |
#ifndef OBJECT_H |
| 2 |
|
|
#define OBJECT_H |
| 3 |
|
|
|
| 4 |
|
|
#include <cstdlib> |
| 5 |
|
|
#include <stdio.h> |
| 6 |
|
|
|
| 7 |
|
|
#include "PMT.h" |
| 8 |
|
|
|
| 9 |
|
|
inline double maxDist() { return ACC->maxDist; } |
| 10 |
|
|
inline int sizeofObject() { return ACC->ndims * ACC->elemsize; } |
| 11 |
|
|
|
| 12 |
|
|
class Object : public GiSTobject // the DB object class |
| 13 |
|
|
{ |
| 14 |
root |
1.3 |
velem *k; |
| 15 |
root |
1.2 |
|
| 16 |
root |
1.3 |
static double int2double(velem i) { |
| 17 |
root |
1.2 |
return i * ACC->max / ACC->steps + ACC->min; |
| 18 |
|
|
} |
| 19 |
root |
1.3 |
static velem double2int(double d) { |
| 20 |
|
|
return (velem)floor ((d - ACC->min) * ACC->steps / ACC->max); |
| 21 |
root |
1.2 |
} |
| 22 |
|
|
|
| 23 |
root |
1.1 |
public: |
| 24 |
|
|
Object() { |
| 25 |
root |
1.3 |
k = new velem [NDIMS]; |
| 26 |
|
|
|
| 27 |
root |
1.1 |
for (int i = NDIMS; i--; ) |
| 28 |
root |
1.3 |
k[i] = ACC->vzero; |
| 29 |
root |
1.1 |
} |
| 30 |
|
|
|
| 31 |
root |
1.2 |
Object(double *pkey); |
| 32 |
root |
1.1 |
|
| 33 |
root |
1.3 |
~Object() { |
| 34 |
|
|
delete [] k; |
| 35 |
root |
1.1 |
} |
| 36 |
|
|
|
| 37 |
root |
1.3 |
Object(const Object& obj) { |
| 38 |
|
|
k = new velem [NDIMS]; |
| 39 |
|
|
memcpy (k, obj.k, NDIMS * sizeof (velem)); |
| 40 |
root |
1.1 |
} |
| 41 |
|
|
|
| 42 |
|
|
Object& operator=(const Object& obj) { |
| 43 |
|
|
delete [] k; |
| 44 |
|
|
|
| 45 |
root |
1.3 |
k = new velem [NDIMS]; |
| 46 |
|
|
memcpy (k, obj.k, NDIMS * sizeof (velem)); |
| 47 |
root |
1.1 |
} |
| 48 |
|
|
|
| 49 |
root |
1.3 |
double area(double r) const { |
| 50 |
root |
1.1 |
return 0; |
| 51 |
|
|
} |
| 52 |
|
|
|
| 53 |
root |
1.3 |
double *data() const; |
| 54 |
root |
1.1 |
|
| 55 |
|
|
double distance(const Object& other) const; // distance method (needed) |
| 56 |
|
|
|
| 57 |
root |
1.3 |
int operator ==(const Object& obj) const |
| 58 |
root |
1.1 |
{ |
| 59 |
root |
1.3 |
return !memcmp (k, obj.k, NDIMS * sizeof (velem)); |
| 60 |
root |
1.1 |
} |
| 61 |
|
|
|
| 62 |
root |
1.3 |
int operator !=(const Object& obj) const |
| 63 |
|
|
{ |
| 64 |
|
|
return !(*this==obj); |
| 65 |
|
|
} |
| 66 |
root |
1.1 |
|
| 67 |
|
|
int CompressedLength() const { |
| 68 |
|
|
return sizeofObject(); |
| 69 |
|
|
} |
| 70 |
|
|
|
| 71 |
|
|
Object(char *key); |
| 72 |
|
|
void Compress(char *key); |
| 73 |
|
|
}; |
| 74 |
|
|
|
| 75 |
|
|
#endif |