-
Notifications
You must be signed in to change notification settings - Fork 0
/
DgDistance.h
87 lines (56 loc) · 2.34 KB
/
DgDistance.h
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
////////////////////////////////////////////////////////////////////////////////
//
// DgDistance.h: DgDistance class definitions
//
// Version 6.1 - Kevin Sahr, 5/23/13
//
////////////////////////////////////////////////////////////////////////////////
#ifndef DGDISTANCE_H
#define DGDISTANCE_H
#include <string>
#include <iostream>
#include <cstdint>
#include "DgRFBase.h"
using namespace std;
////////////////////////////////////////////////////////////////////////////////
class DgDistanceBase {
public:
virtual ~DgDistanceBase (void);
const DgRFBase& rf (void) const { return rf_; }
string asString (void) const { return rf().toString(*this); }
long double asDouble (void) const { return rf().toDouble(*this); }
std::uint64_t asInt (void) const { return rf().toInt(*this); }
protected:
DgDistanceBase (const DgRFBase& frame)
: rf_ (const_cast<DgRFBase&>(frame)) {}
DgDistanceBase (const DgDistanceBase& dist)
: rf_ (const_cast<DgRFBase&>(dist.rf())) {}
DgDistanceBase& operator= (const DgDistanceBase& dist)
{ rf_ = const_cast<DgRFBase&>(dist.rf());
return *this; }
private:
DgRFBase& rf_;
};
////////////////////////////////////////////////////////////////////////////////
inline ostream& operator<< (ostream& stream, const DgDistanceBase& dist)
{ return stream << dist.asString(); }
////////////////////////////////////////////////////////////////////////////////
template <class A> class DgDistance : public DgDistanceBase {
public:
DgDistance (const DgRFBase& frame)
: DgDistanceBase (frame) {}
DgDistance (const DgDistance<A>& dist)
: DgDistanceBase (dist.rf()), distance_ (dist.distance()) {}
DgDistance (const DgRFBase& frame, const A& distance)
: DgDistanceBase (frame), distance_ (distance) {}
void setDistance (const A& distance) { distance_ = distance; }
const A& distance (void) const { return distance_; }
DgDistance& operator= (const DgDistance<A>& dist)
{ DgDistanceBase::operator=(dist); distance_ = dist.distance();
return *this; }
private:
A distance_;
};
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
#endif