Templates -- Meow  1.1.2
不能,也不應該先編譯成obj-file的templates
FeaturePoint.h
Go to the documentation of this file.
1 #ifndef gra_FeaturePoint_H__
2 #define gra_FeaturePoint_H__
3 
4 #include "../oo/ObjBase.h"
5 
6 #include "../math/Vector.h"
7 
8 #include <string>
9 #include <typeinfo>
10 #include <cstdlib>
11 #include <cstdio>
12 
13 namespace meow {
14 
20 template<class Scalar, class Description>
21 class FeaturePoint: public ObjBase {
22 private:
23  Vector<Scalar> pos_;
25 public:
30  }
31 
35  FeaturePoint(size_t pDim, size_t dDim):
36  pos_(pDim, Scalar(0)), des_(dDim, Description(0)) {
37  }
38 
43  pos_(fp.pos_), des_(fp.des_) {
44  }
45 
50  }
51 
56  pos_.copyFrom(fp.pos_);
57  des_.copyFrom(fp.des_);
58  return *this;
59  }
60 
65  pos_.referenceFrom(fp.pos_);
66  des_.referenceFrom(fp.des_);
67  return *this;
68  }
69 
73  Vector<Scalar> const& position() const {
74  return pos_;
75  }
76 
81  return des_;
82  }
83 
87  Vector<Scalar> const& position(Vector<Scalar> const& p) const {
88  pos_.copyFrom(p);
89  return position();
90  }
91 
96  des_.copyFrom(d);
97  return description();
98  }
99 
103  Scalar position(size_t index) const {
104  return pos_(index);
105  }
106 
110  Description description(size_t i) const {
111  return des_(i);
112  }
113 
117  Scalar position(size_t i, Scalar const& s) {
118  pos_.entry(i, s);
119  return position(i);
120  }
121 
125  Description description(size_t i, Description const& d) {
126  des_.entry(i, d);
127  return description(i);
128  }
129 
134  return pos_;
135  }
136 
141  return des_;
142  }
143 
148  return copyFrom(fp);
149  }
150 
154  Scalar const& operator()(size_t i) const {
155  return position(i);
156  }
157 
161  Description operator[](size_t i) const {
162  return description(i);
163  }
164 
165  bool write(FILE* f, bool bin, unsigned int fg) const {
166  return false;
167  }
168 
169  bool read (FILE* f, bool bin, unsigned int fg) {
170  return false;
171  }
172 
173  ObjBase* create() const {
174  return new FeaturePoint();
175  }
176 
177  ObjBase* copyFrom(ObjBase const& b) {
178  return &(copyFrom(*(FeaturePoint*)b));
179  }
180 
181  char const* ctype() const {
182  static char const* ptr = typeid(*this).name();
183  return ptr;
184  }
185 
186  std::string type() const {
187  return std::string(ctype());
188  }
189 };
190 
191 }
192 
193 #endif // gra_FeaturePoint_H__