221Component type instances go through one of two lifecycles:
222
223@code
224CCmpExample();
225Init(paramNode);
226// any sequence of HandleMessage and Serialize and interface methods
227Deinit();
228~CCmpExample();
229@endcode
230
231@code
232CCmpExample();
233Deserialize(paramNode, deserialize);
234// any sequence of HandleMessage and Serialize and interface methods
235Deinit();
236~CCmpExample();
237@endcode
238
239The order of <code>Init</code>/<code>Deserialize</code>/<code>Deinit</code> between entities is mostly undefined,
240so they must not rely on other entities or components already existing; @em except that the SYSTEM_ENTITY is
241created before anything else and therefore may be used, and that the components for a single entity will be
242processed in the order determined by TypeList.h.
243
244In a typical component:
245
246- The constructor should do very little, other than perhaps initialising some member variables -
247 usually the default constructor is fine so there's no need to write one.
248- @c Init should parse the @c paramNode (the data from the entity template) and store any needed data in member variables.
249- @c Deserialize should often explicitly call @c Init first (to load the original template data), and then read any instance-specific data from the deserializer.
250- @c Deinit should clean up any resources allocated by @c Init / @c Deserialize.
251- The destructor should clean up any resources allocated by the constructor - usually there's no need to write one.
252
253
254@subsection schema Component XML schemas
255
256The @c paramNode passed to @c Init is constructed from XML entity template definition files.
257Components should define a schema, which is used for several purposes:
258
259- Documentation of the XML structure expected by the component.
260- Automatic error checking that the XML matches the expectation, so the component doesn't have to do error checking itself.
261- (Hopefully at some point in the future) Automatic generation of editing tool UI.
262
263@c GetSchema must return a Relax NG fragment, which will be used to construct a single global schema file.
264(You can run the game with the @c -dumpSchema command-line argument to see the schema).
265The <a href="http://relaxng.org/tutorial-20011203.html">official tutorial</a> describes most of the details
266of the RNG language.
267
268In simple cases, you would write something like: