ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/Tree-M/object.h
Revision: 1.4
Committed: Fri Jul 27 12:48:23 2001 UTC (22 years, 9 months ago) by root
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +2 -2 lines
Log Message:
*** empty log message ***

File Contents

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