ScummVM API documentation
base_object.h
1/* ScummVM - Graphic Adventure Engine
2 *
3 * ScummVM is the legal property of its developers, whose names
4 * are too numerous to list here. Please refer to the COPYRIGHT
5 * file distributed with this source distribution.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef ULTIMA_SHARED_CORE_BASE_OBJECT_H
23#define ULTIMA_SHARED_CORE_BASE_OBJECT_H
24
25#include "common/scummsys.h"
26#include "common/array.h"
27#include "common/hash-str.h"
28#include "common/list.h"
29#include "ultima/shared/core/file.h"
30
31namespace Ultima {
32namespace Shared {
33
34class BaseObject;
35
36class ClassDef;
37typedef ClassDef(*ClassDefFn)();
38
43class ClassDef {
44private:
45 ClassDefFn _parentFn;
46public:
47 const char *_className;
48public:
49 ClassDef(const char *className, const ClassDefFn parentFn) :
50 _className(className), _parentFn(parentFn) {
51 }
52
53 bool hasParent() const {
54 return _parentFn != nullptr;
55 }
56 ClassDef parent() const {
57 return (*_parentFn)();
58 }
59 bool operator==(const ClassDef &right) const {
60 return !strcmp(_className, right._className);
61 }
62};
63
64#define CLASSDEF \
65 static ::Ultima::Shared::ClassDef type(); \
66 ::Ultima::Shared::ClassDef getType() const override { return type(); }
67
72public:
73 static ::Ultima::Shared::ClassDef type();
74 virtual ::Ultima::Shared::ClassDef getType() const { return type(); }
75 virtual ~BaseObject() {
76 }
77
82 bool isInstanceOf(const ClassDef &classDef) const;
83};
84
85} // End of namespace Shared
86} // End of namespace Ultima
87
88#endif
Definition: base_object.h:71
bool isInstanceOf(const ClassDef &classDef) const
Definition: base_object.h:43