Fixes macOS warnings after adding final keyword to simulation classes in rP26537.
[0ad.git] / source / simulation2 / system / Component.h
bloba3d242a97fdc4d3d736b327afec7a0c950ba22c3
1 /* Copyright (C) 2022 Wildfire Games.
2 * This file is part of 0 A.D.
4 * 0 A.D. is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
9 * 0 A.D. is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
18 #ifndef INCLUDED_COMPONENT
19 #define INCLUDED_COMPONENT
21 // These headers are included because they are required in component implementation,
22 // so including them here transitively makes sense.
23 #include "simulation2/system/CmpPtr.h"
24 #include "simulation2/system/Components.h"
25 #include "simulation2/system/ComponentManager.h"
26 #include "simulation2/system/IComponent.h"
27 #include "simulation2/system/ParamNode.h"
28 #include "simulation2/system/SimContext.h"
29 #include "simulation2/serialization/ISerializer.h"
30 #include "simulation2/serialization/IDeserializer.h"
32 #define REGISTER_COMPONENT_TYPE(cname) \
33 void RegisterComponentType_##cname(CComponentManager& mgr) \
34 { \
35 IComponent::RegisterComponentType(mgr, CCmp##cname::GetInterfaceId(), CID_##cname, CCmp##cname::Allocate, CCmp##cname::Deallocate, #cname, CCmp##cname::GetSchema()); \
36 CCmp##cname::ClassInit(mgr); \
39 #define DEFAULT_COMPONENT_ALLOCATOR(cname) \
40 static IComponent* Allocate(const ScriptInterface&, JS::HandleValue) { return new CCmp##cname(); } \
41 static void Deallocate(IComponent* cmp) { delete static_cast<CCmp##cname*> (cmp); } \
42 int GetComponentTypeId() const override \
43 { \
44 return CID_##cname; \
47 #define DEFAULT_MOCK_COMPONENT() \
48 int GetComponentTypeId() const override \
49 { \
50 return -1; \
51 } \
52 void Init(const CParamNode& UNUSED(paramNode)) override \
53 { \
54 } \
55 void Deinit() override \
56 { \
57 } \
58 void Serialize(ISerializer& UNUSED(serialize)) override \
59 { \
60 } \
61 void Deserialize(const CParamNode& UNUSED(paramNode), IDeserializer& UNUSED(deserialize)) override \
62 { \
63 } \
65 #endif // INCLUDED_COMPONENT