comparison Applications/Samples/StoneSampleCommands_generated.ts @ 527:b1377625e4ba bgo-commands-codegen

Removed ICommand and friends + fixed warnings + added missing header files in solution (in CMakeLists.txt file)
author Benjamin Golinvaux <bgo@osimis.io>
date Sun, 17 Mar 2019 20:14:20 +0100
parents
children 79bb0a02d1cc
comparison
equal deleted inserted replaced
522:700aa66f2f29 527:b1377625e4ba
1 /*
2 1 2 3 4 5 6 7
3 12345678901234567890123456789012345678901234567890123456789012345678901234567890
4
5 Generated on 2019-03-15 10:00:48.763392 by stonegentool
6
7 */
8
9 function StoneCheckSerializedValueType(value: any, typeStr: string)
10 {
11 StoneCheckSerializedValueTypeGeneric(value);
12
13 if (value['type'] != typeStr)
14 {
15 throw new Error(
16 `Cannot deserialize type ${value['type']} into ${typeStr}`);
17 }
18 }
19
20 function isString(val: any) :boolean
21 {
22 return ((typeof val === 'string') || (val instanceof String));
23 }
24
25 function StoneCheckSerializedValueTypeGeneric(value: any)
26 {
27 // console.//log("+-------------------------------------------------+");
28 // console.//log("| StoneCheckSerializedValueTypeGeneric |");
29 // console.//log("+-------------------------------------------------+");
30 // console.//log("value = ");
31 // console.//log(value);
32 if ( (!('type' in value)) || (!isString(value.type)) )
33 {
34 throw new Error(
35 "Cannot deserialize value ('type' key invalid)");
36 }
37 }
38
39 // end of generic methods
40
41 export enum Tool {
42 LineMeasure = "LineMeasure",
43 CircleMeasure = "CircleMeasure",
44 Crop = "Crop",
45 Windowing = "Windowing",
46 Zoom = "Zoom",
47 Pan = "Pan",
48 Move = "Move",
49 Rotate = "Rotate",
50 Resize = "Resize",
51 Mask = "Mask"
52 };
53
54 export function Tool_FromString(strValue:string) : Tool
55 {
56 if( strValue == "LineMeasure" )
57 {
58 return Tool.LineMeasure;
59 }
60 if( strValue == "CircleMeasure" )
61 {
62 return Tool.CircleMeasure;
63 }
64 if( strValue == "Crop" )
65 {
66 return Tool.Crop;
67 }
68 if( strValue == "Windowing" )
69 {
70 return Tool.Windowing;
71 }
72 if( strValue == "Zoom" )
73 {
74 return Tool.Zoom;
75 }
76 if( strValue == "Pan" )
77 {
78 return Tool.Pan;
79 }
80 if( strValue == "Move" )
81 {
82 return Tool.Move;
83 }
84 if( strValue == "Rotate" )
85 {
86 return Tool.Rotate;
87 }
88 if( strValue == "Resize" )
89 {
90 return Tool.Resize;
91 }
92 if( strValue == "Mask" )
93 {
94 return Tool.Mask;
95 }
96
97 let msg : string = `String ${strValue} cannot be converted to Tool. Possible values are: LineMeasure, CircleMeasure, Crop, Windowing, Zoom, Pan, Move, Rotate, Resize, Mask`;
98 throw new Error(msg);
99 }
100
101 export function Tool_ToString(value:Tool) : string
102 {
103 if( value == Tool.LineMeasure )
104 {
105 return "LineMeasure";
106 }
107 if( value == Tool.CircleMeasure )
108 {
109 return "CircleMeasure";
110 }
111 if( value == Tool.Crop )
112 {
113 return "Crop";
114 }
115 if( value == Tool.Windowing )
116 {
117 return "Windowing";
118 }
119 if( value == Tool.Zoom )
120 {
121 return "Zoom";
122 }
123 if( value == Tool.Pan )
124 {
125 return "Pan";
126 }
127 if( value == Tool.Move )
128 {
129 return "Move";
130 }
131 if( value == Tool.Rotate )
132 {
133 return "Rotate";
134 }
135 if( value == Tool.Resize )
136 {
137 return "Resize";
138 }
139 if( value == Tool.Mask )
140 {
141 return "Mask";
142 }
143
144 let msg : string = `Value ${value} cannot be converted to Tool. Possible values are: `;
145 {
146 let _LineMeasure_enumValue : string = Tool.LineMeasure; // enums are strings in stonecodegen, so this will work.
147 let msg_LineMeasure : string = `LineMeasure (${_LineMeasure_enumValue}), `;
148 msg = msg + msg_LineMeasure;
149 }
150 {
151 let _CircleMeasure_enumValue : string = Tool.CircleMeasure; // enums are strings in stonecodegen, so this will work.
152 let msg_CircleMeasure : string = `CircleMeasure (${_CircleMeasure_enumValue}), `;
153 msg = msg + msg_CircleMeasure;
154 }
155 {
156 let _Crop_enumValue : string = Tool.Crop; // enums are strings in stonecodegen, so this will work.
157 let msg_Crop : string = `Crop (${_Crop_enumValue}), `;
158 msg = msg + msg_Crop;
159 }
160 {
161 let _Windowing_enumValue : string = Tool.Windowing; // enums are strings in stonecodegen, so this will work.
162 let msg_Windowing : string = `Windowing (${_Windowing_enumValue}), `;
163 msg = msg + msg_Windowing;
164 }
165 {
166 let _Zoom_enumValue : string = Tool.Zoom; // enums are strings in stonecodegen, so this will work.
167 let msg_Zoom : string = `Zoom (${_Zoom_enumValue}), `;
168 msg = msg + msg_Zoom;
169 }
170 {
171 let _Pan_enumValue : string = Tool.Pan; // enums are strings in stonecodegen, so this will work.
172 let msg_Pan : string = `Pan (${_Pan_enumValue}), `;
173 msg = msg + msg_Pan;
174 }
175 {
176 let _Move_enumValue : string = Tool.Move; // enums are strings in stonecodegen, so this will work.
177 let msg_Move : string = `Move (${_Move_enumValue}), `;
178 msg = msg + msg_Move;
179 }
180 {
181 let _Rotate_enumValue : string = Tool.Rotate; // enums are strings in stonecodegen, so this will work.
182 let msg_Rotate : string = `Rotate (${_Rotate_enumValue}), `;
183 msg = msg + msg_Rotate;
184 }
185 {
186 let _Resize_enumValue : string = Tool.Resize; // enums are strings in stonecodegen, so this will work.
187 let msg_Resize : string = `Resize (${_Resize_enumValue}), `;
188 msg = msg + msg_Resize;
189 }
190 {
191 let _Mask_enumValue : string = Tool.Mask; // enums are strings in stonecodegen, so this will work.
192 let msg_Mask : string = `Mask (${_Mask_enumValue})`;
193 msg = msg + msg_Mask;
194 }
195 throw new Error(msg);
196 }
197
198 export enum ActionType {
199 UndoCrop = "UndoCrop",
200 Rotate = "Rotate",
201 Invert = "Invert"
202 };
203
204 export function ActionType_FromString(strValue:string) : ActionType
205 {
206 if( strValue == "UndoCrop" )
207 {
208 return ActionType.UndoCrop;
209 }
210 if( strValue == "Rotate" )
211 {
212 return ActionType.Rotate;
213 }
214 if( strValue == "Invert" )
215 {
216 return ActionType.Invert;
217 }
218
219 let msg : string = `String ${strValue} cannot be converted to ActionType. Possible values are: UndoCrop, Rotate, Invert`;
220 throw new Error(msg);
221 }
222
223 export function ActionType_ToString(value:ActionType) : string
224 {
225 if( value == ActionType.UndoCrop )
226 {
227 return "UndoCrop";
228 }
229 if( value == ActionType.Rotate )
230 {
231 return "Rotate";
232 }
233 if( value == ActionType.Invert )
234 {
235 return "Invert";
236 }
237
238 let msg : string = `Value ${value} cannot be converted to ActionType. Possible values are: `;
239 {
240 let _UndoCrop_enumValue : string = ActionType.UndoCrop; // enums are strings in stonecodegen, so this will work.
241 let msg_UndoCrop : string = `UndoCrop (${_UndoCrop_enumValue}), `;
242 msg = msg + msg_UndoCrop;
243 }
244 {
245 let _Rotate_enumValue : string = ActionType.Rotate; // enums are strings in stonecodegen, so this will work.
246 let msg_Rotate : string = `Rotate (${_Rotate_enumValue}), `;
247 msg = msg + msg_Rotate;
248 }
249 {
250 let _Invert_enumValue : string = ActionType.Invert; // enums are strings in stonecodegen, so this will work.
251 let msg_Invert : string = `Invert (${_Invert_enumValue})`;
252 msg = msg + msg_Invert;
253 }
254 throw new Error(msg);
255 }
256
257
258
259 export class SelectTool {
260 tool:Tool;
261
262 constructor() {
263 }
264
265 public StoneSerialize(): string {
266 let container: object = {};
267 container['type'] = 'StoneSampleCommands.SelectTool';
268 container['value'] = this;
269 return JSON.stringify(container);
270 }
271
272 public static StoneDeserialize(valueStr: string) : SelectTool
273 {
274 let value: any = JSON.parse(valueStr);
275 StoneCheckSerializedValueType(value, 'StoneSampleCommands.SelectTool');
276 let result: SelectTool = value['value'] as SelectTool;
277 return result;
278 }
279 }
280 export class Action {
281 type:ActionType;
282
283 constructor() {
284 }
285
286 public StoneSerialize(): string {
287 let container: object = {};
288 container['type'] = 'StoneSampleCommands.Action';
289 container['value'] = this;
290 return JSON.stringify(container);
291 }
292
293 public static StoneDeserialize(valueStr: string) : Action
294 {
295 let value: any = JSON.parse(valueStr);
296 StoneCheckSerializedValueType(value, 'StoneSampleCommands.Action');
297 let result: Action = value['value'] as Action;
298 return result;
299 }
300 }
301
302 export interface IHandler {
303 };
304
305 /** Service function for StoneDispatchToHandler */
306 export function StoneDispatchJsonToHandler(
307 jsonValue: any, handler: IHandler): boolean
308 {
309 StoneCheckSerializedValueTypeGeneric(jsonValue);
310 let type: string = jsonValue["type"];
311 if (type == "")
312 {
313 // this should never ever happen
314 throw new Error("Caught empty type while dispatching");
315 }
316 else
317 {
318 return false;
319 }
320 }
321
322 /** Takes a serialized type and passes this to the handler */
323 export function StoneDispatchToHandler(
324 strValue: string, handler: IHandler): boolean
325 {
326 // console.//log("+------------------------------------------------+");
327 // console.//log("| StoneDispatchToHandler |");
328 // console.//log("+------------------------------------------------+");
329 // console.//log("strValue = ");
330 // console.//log(strValue);
331 let jsonValue: any = JSON.parse(strValue)
332 return StoneDispatchJsonToHandler(jsonValue, handler);
333 }