-
Notifications
You must be signed in to change notification settings - Fork 0
/
DSChannel2RouteConnection.cpp
186 lines (158 loc) · 4.8 KB
/
DSChannel2RouteConnection.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
175
176
177
178
179
180
181
182
183
184
185
186
/****************************************************************************
* Modul: $RCSfile: DSChannel2RouteConnection.cpp,v $
*
* $Author: hirche $
* $Date: 1997/08/29 13:33:16 $
* $Revision: 1.1 $
* Aufgabe: Dieser Modul stellt Datenstruktur fuer ein SDL-Connect bereit.
*
* Funktionen:
****************************************************************************/
#ifdef USE_PRAGMA
#pragma interface
#endif
/****************************************************************************
* Konstanten
****************************************************************************/
/****************************************************************************
* Include-Anweisungen
****************************************************************************/
#include "DSChannel2RouteConnection.h"
#include "DSBlock.h" // wegen parent
#include "DSChannel.h"
#include "DSSignalRoute.h"
#ifdef DEBUG
#include <dmalloc.h>
#endif
/****************************************************************************
* Externe Variablen
****************************************************************************/
/****************************************************************************
* Globale Variablen
****************************************************************************/
/****************************************************************************
* Konstruktoren
****************************************************************************/
DSChannel2RouteConnection::
DSChannel2RouteConnection(DSObject *father,
DSChannelRefList *channels,
DSSignalRouteRefList *routes):
DSObject(DS_CHANNEL2ROUTECONNECTION, father),
DSChannelRefComponent(channels),
DSSignalRouteRefComponent(routes)
{
if (father)
{
((DSBlock*)father)->InsertChannel2RouteConnection(this);
}
}
/****************************************************************************
* Destruktor
****************************************************************************/
DSChannel2RouteConnection::~DSChannel2RouteConnection(void)
{
}
/****************************************************************************
* Virtueller Konstruktor
****************************************************************************/
DSObject *DSChannel2RouteConnection::New(DSObject *father) const
{
return new DSChannel2RouteConnection(father);
}
DSBoolean DSChannel2RouteConnection::
IsChannelConnected(DSChannelRef search_channel) const
{
DSChannelRef channel;
for (channel = GetFirstChannelRef();
channel != NULL;
channel = GetNextChannelRef())
{
if (channel == search_channel)
{
return DS_TRUE;
}
}
return DS_FALSE;
}
DSBoolean DSChannel2RouteConnection::
IsSignalRouteConnected(DSSignalRouteRef search_route) const
{
DSSignalRouteRef route;
for (route = GetFirstSignalRouteRef();
route != NULL;
route = GetNextSignalRouteRef())
{
if (route == search_route)
{
return DS_TRUE;
}
}
return DS_FALSE;
}
DSObject *DSChannel2RouteConnection::Clone(DSObject *father, DSObject *fill_this) const
{
DSChannel2RouteConnection *new_c2r_connection;
if (fill_this == NULL)
{
new_c2r_connection = (DSChannel2RouteConnection *)New(father);
assert(new_c2r_connection);
}
else
{
assert(fill_this->GetType() == DS_CHANNEL2ROUTECONNECTION);
new_c2r_connection = (DSChannel2RouteConnection *)fill_this;
}
if (GetChannelRefList())
{
new_c2r_connection->SetChannelRefList((DSChannelRefList *)GetChannelRefList()->Clone((DSObject *)new_c2r_connection));
}
if (GetSignalRouteRefList())
{
new_c2r_connection->SetSignalRouteRefList((DSSignalRouteRefList *)GetSignalRouteRefList()->Clone((DSObject *)new_c2r_connection));
}
return new_c2r_connection;
}
DSResult DSChannel2RouteConnection::Write(DSWriter *writer, DSCardinal what) const
{
(void)what;
assert(writer);
return DS_OK;
}
DSResult DSChannel2RouteConnection::Run(DSWriter *writer, DSType object_type,
DSCardinal what) const
{
DSResult result;
DSSignalRouteRef signal_route;
DSChannelRef channel;
switch(object_type)
{
case DS_SIGNALROUTE:
for (signal_route = GetFirstSignalRouteRef();
signal_route;
signal_route = GetNextSignalRouteRef())
{
result = signal_route->Write(writer, what);
if (result != DS_OK)
{
return DS_ERROR;
}
}
break;
case DS_CHANNEL:
for (channel = GetFirstChannelRef();
channel;
channel = GetNextChannelRef())
{
result = channel->Write(writer, what);
if (result != DS_OK)
{
return DS_ERROR;
}
}
break;
default:
assert(DS_FALSE);
break;
}
return DS_OK;
}