-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCGMachineServiceSpeed.cpp
148 lines (121 loc) · 4.41 KB
/
CGMachineServiceSpeed.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
/****************************************************************************
* Modul: $RCSfile: CGMachineServiceSpeed.cpp,v $
*
* $Author: md $
* $Date: 1998/01/14 10:59:58 $
* $Revision: 1.2 $
*
* Aufgabe: Dieses Modul enthaelt die Funktionen, mit denen der C++-Code aus
* der Datenstruktur generiert wird
* Funktionen: Write(): Oberfunktion der Codegenerierung
****************************************************************************/
#ifdef USE_PRAGMA
#pragma interface
#endif
/****************************************************************************
* Konstanten
****************************************************************************/
/****************************************************************************
* Include-Anweisungen
****************************************************************************/
#include <DS/DSString.h>
#include <DS/DSMachine.h>
#include <DS/DSExpression.h>
#include "CGFile.h"
#include "CGMachineServiceSpeed.h"
#ifdef DEBUG
#include <dmalloc.h>
#endif
/****************************************************************************
* Konstruktoren
****************************************************************************/
CGMachineServiceSpeed::CGMachineServiceSpeed(DSObject *father,
DSMachineServiceRef service,
DSExpression *spd) :
DSMachineServiceSpeed(father, service, spd)
{
}
/****************************************************************************
* Destruktor
****************************************************************************/
CGMachineServiceSpeed::~CGMachineServiceSpeed(void)
{
}
/****************************************************************************
* Virtueller Konstruktor
****************************************************************************/
DSObject *CGMachineServiceSpeed::New(DSObject *father) const
{
return new CGMachineServiceSpeed(father);
}
/****************************************************************************
* Write(): Oberfunktion der Codegenerierung fuer Set
* -> writer
* -> what
* Ergebnis: DS_OK oder DS_ERROR
* Seiteneffekte: Anlegen und Fuellen der .h und .cc-Files
****************************************************************************/
DSResult CGMachineServiceSpeed::Write(DSWriter *writer, DSCardinal what) const
{
DSResult result;
(void)what;
result = WriteImplementation((CGWriter *)writer);
if (result != DS_OK) return result;
return DS_OK;
}
/****************************************************************************
* WriteImplementation(): Oberfunktion der Codegenerierung
* -> writer
* -> what
* Ergebnis: DS_OK, falls alles geklappt hat, sonst DS_ERROR
* Seiteneffekte: Fuellen der Files
****************************************************************************/
DSResult CGMachineServiceSpeed::WriteImplementation(CGWriter *writer) const
{
DSResult result, status;
DSMachine *machine;
CGFile *out;
CGPos pos;
DSString str;
DSCardinal counter = 0;
DSMachineServiceRefList *machine_service_list;
DSMachineServiceRef service_global;
DSMachineServiceRef service_local;
out = writer->CGGetFilePointer();
assert(out);
pos = writer->CGGetIndentPos();
assert(GetParent()->GetType() == DS_MACHINE);
machine = (DSMachine *)GetParent();
machine_service_list = writer->CGGetServiceList();
assert(machine_service_list);
service_local = GetMachineServiceRef();
assert(service_local);
// Nachschauen, welchen Index dieser Dienst hat:
for (status = machine_service_list->MoveFirst();
status == DS_OK;
status = machine_service_list->MoveNext())
{
service_global = machine_service_list->GetCurrentData();
assert(service_global);
if (service_local == service_global) // Dienst gefunden?
{
break;
}
counter++;
}
assert(status == DS_OK);
InsertString(*out, PREFIX_MACHINE_SPEED, pos, CG_NO_EOL);
InsertString(*out, machine->GetName(), 0, CG_NO_EOL);
InsertString(*out, "[", 0, CG_NO_EOL);
str.Format("%d", counter);
InsertString(*out, str, 0, CG_NO_EOL);
InsertString(*out, "] = ", 0, CG_NO_EOL);
writer->CGSetIndentPos(0);
if ((result = GetSpeed()->Write(writer)) != DS_OK)
{
return result;
}
writer->CGSetIndentPos(pos);
InsertString(*out, ";", 0, CG_WITH_EOL);
return DS_OK;
}