Tiberian Technologies Scripts Reference Revision: 9000
Loading...
Searching...
No Matches
SimpleDefinitionFactoryClass.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_SIMPLEDEFINITIONFACTORYCLASS_H
13#define TT_INCLUDE_SIMPLEDEFINITIONFACTORYCLASS_H
14#include "DefinitionFactoryClass.h"
15#include "DefinitionFactoryMgrClass.h"
16template <class T, uint32 I, const char *N>
17class SimpleDefinitionFactoryClass : public DefinitionFactoryClass
18{
19public:
20 bool IsDisplayed;
21 SimpleDefinitionFactoryClass(bool is_displayed = true) : IsDisplayed(is_displayed)
22 {
23 }
24 ~SimpleDefinitionFactoryClass()
25 {
26 }
27 DefinitionClass *Create() const
28 {
29 return new T;
30 }
31 const char *Get_Name() const
32 {
33 return N;
34 }
35 uint32 Get_Class_ID() const
36 {
37 return I;
38 }
39 bool Is_Displayed() const
40 {
41 return IsDisplayed;
42 }
43};
44#define DECLARE_DEFINITION_FACTORY(definition,classid,string) \
45 char definition##name[sizeof(string)] = string; \
46 SimpleDefinitionFactoryClass<definition,classid,(const char *)definition##name>
47#endif