blob: 70e1c309082d50a144f6d4992c66f410ff488f07 (
plain)
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
93
94
95
96
97
98
99
100
101
102
103
104
105
|
#ifndef COMMLAYERINNER_H_
#define COMMLAYERINNER_H_
#include <iostream>
#include "Observer.h"
class CDebugCommLayer
{
private:
CObserver *m_pObserver;
public:
CDebugCommLayer(CObserver *pObs) :
m_pObserver(pObs)
{}
void Message(const std::string& pMsg)
{
if(m_pObserver)
{
m_pObserver->Debug(pMsg);
}
}
};
class CWarningCommLayer
{
private:
CObserver *m_pObserver;
public:
CWarningCommLayer(CObserver *pObs) :
m_pObserver(pObs)
{}
void Message(const std::string& pMsg)
{
if(m_pObserver)
{
m_pObserver->Warning(pMsg);
}
}
};
class CStatusCommLayer
{
private:
CObserver *m_pObserver;
public:
CStatusCommLayer(CObserver *pObs) :
m_pObserver(pObs)
{}
void Message(const std::string& pMsg)
{
if(m_pObserver)
{
m_pObserver->Status(pMsg);
}
}
};
class CCommLayerInner
{
private:
CDebugCommLayer* m_pDebugCommLayer;
CWarningCommLayer* m_pWarningCommLayer;
CStatusCommLayer* m_pStatusCommLayer;
public:
CDebugCommLayer* GetDebugCommLayer()
{
return m_pDebugCommLayer;
}
CWarningCommLayer* GetWarningCommLayer()
{
return m_pWarningCommLayer;
}
CStatusCommLayer* GetStatusCommLayer()
{
return m_pStatusCommLayer;
}
CCommLayerInner(CObserver *pObs, const bool& pDebug, const bool pWarning)
{
m_pDebugCommLayer = NULL;
m_pWarningCommLayer = NULL;
if (pDebug)
{
m_pDebugCommLayer = new CDebugCommLayer(pObs);
}
if (pWarning)
{
m_pWarningCommLayer = new CWarningCommLayer(pObs);
}
m_pStatusCommLayer = new CStatusCommLayer(pObs);
}
~CCommLayerInner()
{
if (m_pDebugCommLayer)
{
delete m_pDebugCommLayer;
}
if (m_pWarningCommLayer)
{
delete m_pWarningCommLayer;
}
delete m_pStatusCommLayer;
}
};
#endif /* COMMLAYERINNER_H_ */
|