Fix include style
[bcusdk.git] / common / image.h
blobed8b9c12ee542c0aae1ab01a104db6f4aa1ca3d7
1 /*
2 BCU SDK bcu development enviroment
3 Copyright (C) 2005-2010 Martin Koegler <mkoegler@auto.tuwien.ac.at>
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #ifndef IMAGE_H
21 #define IMAGE_H
23 #include "types.h"
25 String HexDump (CArray data);
27 typedef enum
29 S_Invalid,
30 S_Unknown,
31 S_BCUType,
32 S_Code,
33 S_StringParameter,
34 S_IntParameter,
35 S_FloatParameter,
36 S_ListParameter,
37 S_GroupObject,
38 S_BCU1Size,
39 S_BCU2Size,
40 S_BCU2Start,
41 S_BCU2Key,
42 } STR_Type;
44 class STR_Stream
46 public:
47 virtual ~ STR_Stream ()
50 static STR_Stream *fromArray (const CArray & c);
51 virtual bool init (const CArray & str) = 0;
52 virtual CArray toArray () = 0;
53 virtual STR_Type getType () = 0;
54 virtual String decode () = 0;
57 class STR_Invalid:public STR_Stream
59 public:
60 CArray data;
62 STR_Invalid ();
63 bool init (const CArray & str);
64 CArray toArray ();
65 STR_Type getType ()
67 return S_Invalid;
69 String decode ();
72 class STR_Unknown:public STR_Stream
74 public:
75 uint16_t type;
76 CArray data;
78 STR_Unknown ();
79 bool init (const CArray & str);
80 CArray toArray ();
81 STR_Type getType ()
83 return S_Unknown;
85 String decode ();
88 class STR_BCUType:public STR_Stream
90 public:
91 uint16_t bcutype;
93 STR_BCUType ();
94 bool init (const CArray & str);
95 CArray toArray ();
96 STR_Type getType ()
98 return S_BCUType;
100 String decode ();
102 class STR_Code:public STR_Stream
104 public:
105 CArray code;
107 STR_Code ();
108 bool init (const CArray & str);
109 CArray toArray ();
110 STR_Type getType ()
112 return S_Code;
114 String decode ();
116 class STR_StringParameter:public STR_Stream
118 public:
119 uint16_t addr;
120 uint16_t length;
121 String name;
123 STR_StringParameter ();
124 bool init (const CArray & str);
125 CArray toArray ();
126 STR_Type getType ()
128 return S_StringParameter;
130 String decode ();
132 class STR_ListParameter:public STR_Stream
134 public:
135 uint16_t addr;
136 String name;
137 Array < String > elements;
139 STR_ListParameter ();
140 bool init (const CArray & str);
141 CArray toArray ();
142 STR_Type getType ()
144 return S_ListParameter;
146 String decode ();
148 class STR_IntParameter:public STR_Stream
150 public:
151 uint16_t addr;
152 int8_t type;
153 String name;
155 STR_IntParameter ();
156 bool init (const CArray & str);
157 CArray toArray ();
158 STR_Type getType ()
160 return S_IntParameter;
162 String decode ();
164 class STR_FloatParameter:public STR_Stream
166 public:
167 uint16_t addr;
168 String name;
170 STR_FloatParameter ();
171 bool init (const CArray & str);
172 CArray toArray ();
173 STR_Type getType ()
175 return S_FloatParameter;
177 String decode ();
179 class STR_GroupObject:public STR_Stream
181 public:
182 uchar no;
183 String name;
185 STR_GroupObject ();
186 bool init (const CArray & str);
187 CArray toArray ();
188 STR_Type getType ()
190 return S_GroupObject;
192 String decode ();
194 class STR_BCU1Size:public STR_Stream
196 public:
197 uint16_t textsize;
198 uint16_t stacksize;
199 uint16_t datasize;
200 uint16_t bsssize;
202 STR_BCU1Size ();
203 bool init (const CArray & str);
204 CArray toArray ();
205 STR_Type getType ()
207 return S_BCU1Size;
209 String decode ();
211 class STR_BCU2Size:public STR_Stream
213 public:
214 uint16_t textsize;
215 uint16_t stacksize;
216 uint16_t lo_datasize;
217 uint16_t lo_bsssize;
218 uint16_t hi_datasize;
219 uint16_t hi_bsssize;
221 STR_BCU2Size ();
222 bool init (const CArray & str);
223 CArray toArray ();
224 STR_Type getType ()
226 return S_BCU2Size;
228 String decode ();
230 class STR_BCU2Start:public STR_Stream
232 public:
233 uint16_t addrtab_start;
234 uint16_t addrtab_size;
235 uint16_t assoctab_start;
236 uint16_t assoctab_size;
237 uint16_t readonly_start;
238 uint16_t readonly_end;
239 uint16_t param_start;
240 uint16_t param_end;
242 uint16_t obj_ptr;
243 uint16_t obj_count;
244 uint16_t appcallback;
245 uint16_t groupobj_ptr;
246 uint16_t seg0;
247 uint16_t seg1;
248 uint16_t sphandler;
249 uint16_t initaddr;
250 uint16_t runaddr;
251 uint16_t saveaddr;
252 uint16_t eeprom_start;
253 uint16_t eeprom_end;
254 eibaddr_t poll_addr;
255 uint8_t poll_slot;
257 STR_BCU2Start ();
258 bool init (const CArray & str);
259 CArray toArray ();
260 STR_Type getType ()
262 return S_BCU2Start;
264 String decode ();
267 class STR_BCU2Key:public STR_Stream
269 public:
270 eibkey_type installkey;
271 Array < eibkey_type > keys;
273 STR_BCU2Key ();
274 bool init (const CArray & str);
275 CArray toArray ();
276 STR_Type getType ()
278 return S_BCU2Key;
280 String decode ();
283 class Image
285 public:
286 Array < STR_Stream * >str;
288 Image ();
289 virtual ~ Image ();
291 static Image *fromArray (CArray c);
292 CArray toArray ();
293 String decode ();
294 bool isValid ();
296 int findStreamNumber (STR_Type t);
297 STR_Stream *findStream (STR_Type t);
300 #endif