-
Notifications
You must be signed in to change notification settings - Fork 0
/
DSInputSignal.cpp
174 lines (144 loc) · 4.81 KB
/
DSInputSignal.cpp
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/****************************************************************************
* Modul: $RCSfile: DSInputSignal.cpp,v $
*
* $Author: md $
* $Date: 1998/01/13 12:48:22 $
* $Revision: 1.3 $
*
* Aufgabe: Dieser Modul ermoeglicht die Abspeicherung bzw. Ruecklieferung
* der Variablen in Verbindung mit einem INPUT-Befehl
*
* Funktionen: GetSignalRef(): Gibt einen Zeiger auf ein Signal zurueck
* SetSignalRef(): Speichert Signaladdresse
****************************************************************************/
#ifdef USE_PRAGMA
#pragma interface
#endif
/****************************************************************************
* Konstanten
****************************************************************************/
/****************************************************************************
* Include-Anweisungen
****************************************************************************/
#include "DSInputSignal.h"
#include "DSInput.h" // wegen parent
#include "DSSignal.h"
#include "DSVariableAccess.h"
#ifdef DEBUG
#include <dmalloc.h>
#endif
/****************************************************************************
* Externe Variablen
****************************************************************************/
/****************************************************************************
* Globale Variablen
****************************************************************************/
/****************************************************************************
* Konstruktoren
****************************************************************************/
DSInputSignal::DSInputSignal(DSObject *father,
DSSignalRef sig_ref,
DSVariableAccessList *access_list) :
DSObject(DS_INPUTSIGNAL, father),
DSVariableAccessComponent(NULL, access_list),
signal_ref(sig_ref)
{
DSVariableAccessComponent::SetComponentParent(this);
if (father)
{
switch(father->GetType())
{
case DS_INPUT:
((DSInput*)father)->InsertInputSignal(this);
break;
default:
assert(DS_FALSE);
break;
}
}
}
/****************************************************************************
* Destruktor
****************************************************************************/
DSInputSignal::~DSInputSignal(void)
{
}
/****************************************************************************
* Virtueller Konstruktor
****************************************************************************/
DSObject *DSInputSignal::New(DSObject *father) const
{
return new DSInputSignal(father);
}
/****************************************************************************
* GetSignalRef(): Liefert den Zeiger auf das Signal zurueck
* Ergebnis: Zeiger auf ein Signal
* Seiteneffekte: keine
****************************************************************************/
DSSignalRef DSInputSignal::GetSignalRef(void) const
{
return signal_ref;
}
/****************************************************************************
* SetSignalRef(): Speichert den uebergebenen Zeiger
* -> sig_ref: Zeiger auf einen DSString
* Ergebnis: TRUE
* Seiteneffekte: keine
****************************************************************************/
DSResult DSInputSignal::SetSignalRef(DSSignalRef sig_ref)
{
signal_ref = sig_ref;
return DS_OK;
}
DSObject *DSInputSignal::Clone(DSObject *father, DSObject *fill_this) const
{
DSInputSignal *new_input_signal;
if (fill_this == NULL)
{
new_input_signal = (DSInputSignal *)New(father);
assert(new_input_signal);
}
else
{
assert(fill_this->GetType() == DS_INPUTSIGNAL);
new_input_signal = (DSInputSignal *)fill_this;
}
if (GetVariableAccessList())
{
new_input_signal->SetVariableAccessList(GetVariableAccessList()->Clone((DSObject *)new_input_signal));
}
new_input_signal->SetSignalRef(GetSignalRef());
return new_input_signal;
}
DSResult DSInputSignal::Write(DSWriter *writer, DSCardinal what) const
{
assert(writer);
if (signal_ref) signal_ref->Write(writer, what);
Run(writer, DS_VARIABLEACCESS, what);
return DS_OK;
}
DSResult DSInputSignal::Run(DSWriter *writer, DSType object_type,
DSCardinal what) const
{
DSResult result;
DSVariableAccess *variable_access;
switch(object_type)
{
case DS_VARIABLEACCESS:
for (variable_access = GetFirstVariableAccess();
variable_access;
variable_access = GetNextVariableAccess())
{
result = variable_access->Write(writer, what);
if (result != DS_OK)
{
return DS_ERROR;
}
}
break;
default:
assert(DS_FALSE);
break;
}
return DS_OK;
}