Tiberian Technologies Scripts Reference Revision: 9000
Loading...
Searching...
No Matches
SimplePersistFactoryClass.h
1/* Renegade Scripts.dll
2 Copyright 2013 Tiberian Technologies
3
4 This file is part of the Renegade scripts.dll
5 The Renegade scripts.dll is free software; you can redistribute it and/or modify it under
6 the terms of the GNU General Public License as published by the Free
7 Software Foundation; either version 2, or (at your option) any later
8 version. See the file COPYING for more details.
9 In addition, an exemption is given to allow Run Time Dynamic Linking of this code with any closed source module that does not contain code covered by this licence.
10 Only the source code to the module(s) containing the licenced code has to be released.
11*/
12#ifndef TT_INCLUDE__SIMPLEPERSISTFACTORYCLASS_H
13#define TT_INCLUDE__SIMPLEPERSISTFACTORYCLASS_H
14
15#include "PersistFactoryClass.h"
16#include "SaveLoadSystemClass.h"
17
18template <class T, unsigned long I>
19class SimplePersistFactoryClass : public PersistFactoryClass
20{
21public:
22 virtual uint32 Chunk_ID () const
23 {
24 return I;
25 }
26 PersistClass* Load(ChunkLoadClass& xLoad) const
27 {
28 T *newobj = new T;
29 void *pointer;
30 xLoad.Open_Chunk();
31 xLoad.Read(&pointer,4);
32 xLoad.Close_Chunk();
33 xLoad.Open_Chunk();
34 newobj->Load(xLoad);
35 xLoad.Close_Chunk();
36 SaveLoadSystemClass::Register_Pointer(pointer,newobj);
37 return newobj;
38 }
39 void Save(ChunkSaveClass& xSave, PersistClass* persist) const
40 {
41 xSave.Begin_Chunk(0x100100);
42 xSave.Write(&persist,4);
43 xSave.End_Chunk();
44 xSave.Begin_Chunk(0x100101);
45 persist->Save(xSave);
46 xSave.End_Chunk();
47 }
48};
49
50
51#endif