-
Notifications
You must be signed in to change notification settings - Fork 0
/
DgConverterBase.h
92 lines (62 loc) · 2.87 KB
/
DgConverterBase.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
88
89
90
91
92
////////////////////////////////////////////////////////////////////////////////
//
// DgConverterBase.h: DgConverterBase class definitions
//
// Version 6.1 - Kevin Sahr, 5/23/13
//
////////////////////////////////////////////////////////////////////////////////
#ifndef DGCONVERTERBASE_H
#define DGCONVERTERBASE_H
#include <vector>
using namespace std;
#include "DgRFBase.h"
#include "DgLocation.h"
////////////////////////////////////////////////////////////////////////////////
class DgConverterBase {
public:
virtual ~DgConverterBase (void);
static bool isTraceOn (void) { return isTraceOn_; }
static bool setTraceOn (bool traceOnIn)
{ isTraceOn_ = traceOnIn; return isTraceOn(); }
//static void setTraceStream (ostream& stream = cout)
// { traceStream_ = &stream; }
//static ostream& traceStream (void) { return *traceStream_; }
virtual DgLocation* convert (DgLocation* loc) const; // convert in place
void forceConnectFrom (bool verify = true) const;
void forceConnectTo (bool verify = true) const;
const DgRFBase& fromFrame (void) const { return *fromFrame_; }
const DgRFBase& toFrame (void) const { return *toFrame_; }
bool userGenerated (void) const { return userGenerated_; }
protected:
DgConverterBase (const DgRFBase& fromFrame,
const DgRFBase& toFrame, bool userGenerated = true);
DgConverterBase (const DgConverterBase& con) { operator=(con); }
DgConverterBase& operator= (const DgConverterBase& con);
virtual DgAddressBase* createConvertedAddress
(const DgAddressBase& addIn) const = 0;
static bool isTraceOn_;
//static ostream* traceStream_;
DgRFBase* fromFrame_;
DgRFBase* toFrame_;
bool userGenerated_;
friend class DgRFBase;
friend class DgSeriesConverter;
};
////////////////////////////////////////////////////////////////////////////////
inline ostream& operator<< (ostream& stream, const DgConverterBase& con)
{ return stream << "{" << con.fromFrame().name()
<< "->" << con.toFrame().name() << "}"; }
////////////////////////////////////////////////////////////////////////////////
class DgIdentityConverter : public DgConverterBase {
public:
DgIdentityConverter (const DgRFBase& frame)
: DgConverterBase(frame, frame, false) {}
virtual DgLocation* convert (DgLocation* loc) const { return loc; }
protected:
virtual DgAddressBase* createConvertedAddress
(const DgAddressBase& addIn) const
{ return fromFrame().createAddress(addIn); }
};
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
#endif