aboutsummaryrefslogtreecommitdiff
path: root/engines/titanic/core/saveable_object.h
diff options
context:
space:
mode:
authorPaul Gilbert2016-03-06 19:12:49 -0500
committerPaul Gilbert2016-03-06 19:12:49 -0500
commit7375394b810f3503f168d5770555aa1932d7892d (patch)
tree420e42cc4b5bc3b9a445e7a397fa26765bc62191 /engines/titanic/core/saveable_object.h
parentf423d4d41a0d94067162acf868bc7eba99cd3e17 (diff)
downloadscummvm-rg350-7375394b810f3503f168d5770555aa1932d7892d.tar.gz
scummvm-rg350-7375394b810f3503f168d5770555aa1932d7892d.tar.bz2
scummvm-rg350-7375394b810f3503f168d5770555aa1932d7892d.zip
TITANIC: Converting saveable objects hierarchy to have type data
This is necessary for at least message sending, and probably other areas, that needs to be able to pass class filtering for message targets. And I could figure out a clean way to use the built-in RTTI
Diffstat (limited to 'engines/titanic/core/saveable_object.h')
-rw-r--r--engines/titanic/core/saveable_object.h33
1 files changed, 27 insertions, 6 deletions
diff --git a/engines/titanic/core/saveable_object.h b/engines/titanic/core/saveable_object.h
index ed26163557..8368c71d3f 100644
--- a/engines/titanic/core/saveable_object.h
+++ b/engines/titanic/core/saveable_object.h
@@ -30,9 +30,34 @@
namespace Titanic {
+class CSaveableObject;
+
+class ClassDef {
+public:
+ const char *_className;
+ ClassDef *_parent;
+public:
+ ClassDef(const char *className, ClassDef *parent) :
+ _className(className), _parent(parent) {}
+ virtual CSaveableObject *create();
+};
+
+template<typename T>
+class TypeTemplate : public ClassDef {
+public:
+ TypeTemplate(const char *className, ClassDef *parent) :
+ ClassDef(className, parent) {}
+ virtual CSaveableObject *create() { return new T(); }
+};
+
+#define CLASSDEF \
+ static ClassDef *_type; \
+ virtual ClassDef *getType() const { return _type; }
+
class CSaveableObject {
typedef CSaveableObject *(*CreateFunction)();
private:
+ static Common::List<ClassDef *> *_classDefs;
static Common::HashMap<Common::String, CreateFunction> *_classList;
public:
/**
@@ -50,13 +75,9 @@ public:
*/
static CSaveableObject *createInstance(const Common::String &name);
public:
+ CLASSDEF
virtual ~CSaveableObject() {}
-
- /**
- * Return the class name
- */
- virtual const char *getClassName() const { return "CSaveableObject"; }
-
+
/**
* Save the data for the class to file
*/