1 /**
2 Class information repository.
3 
4 Copyright:
5 Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur.  
6 Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md)  
7 Copyright (c) 2017-2018 Godot-D contributors  
8 
9 License: $(LINK2 https://opensource.org/licenses/MIT, MIT License)
10 
11 
12 */
13 module godot.classdb;
14 import std.meta : AliasSeq, staticIndexOf;
15 import std.traits : Unqual;
16 import godot.d.meta;
17 import godot.core;
18 import godot.c;
19 import godot.d.bind;
20 import godot.d.reference;
21 import godot.object;
22 /**
23 Class information repository.
24 
25 Provides access to metadata stored for every available class.
26 */
27 @GodotBaseClass struct ClassDBSingleton
28 {
29 	enum string _GODOT_internal_name = "_ClassDB";
30 public:
31 @nogc nothrow:
32 	union { godot_object _godot_object; GodotObject _GODOT_base; }
33 	alias _GODOT_base this;
34 	alias BaseClasses = AliasSeq!(typeof(_GODOT_base), typeof(_GODOT_base).BaseClasses);
35 	package(godot) __gshared bool _classBindingInitialized = false;
36 	package(godot) static struct _classBinding
37 	{
38 		__gshared:
39 		godot_object _singleton;
40 		immutable char* _singletonName = "ClassDB";
41 		@GodotName("get_class_list") GodotMethod!(PoolStringArray) getClassList;
42 		@GodotName("get_inheriters_from_class") GodotMethod!(PoolStringArray, String) getInheritersFromClass;
43 		@GodotName("get_parent_class") GodotMethod!(String, String) getParentClass;
44 		@GodotName("class_exists") GodotMethod!(bool, String) classExists;
45 		@GodotName("is_parent_class") GodotMethod!(bool, String, String) isParentClass;
46 		@GodotName("can_instance") GodotMethod!(bool, String) canInstance;
47 		@GodotName("instance") GodotMethod!(Variant, String) instance;
48 		@GodotName("class_has_signal") GodotMethod!(bool, String, String) classHasSignal;
49 		@GodotName("class_get_signal") GodotMethod!(Dictionary, String, String) classGetSignal;
50 		@GodotName("class_get_signal_list") GodotMethod!(Array, String, bool) classGetSignalList;
51 		@GodotName("class_get_property_list") GodotMethod!(Array, String, bool) classGetPropertyList;
52 		@GodotName("class_get_property") GodotMethod!(Variant, GodotObject, String) classGetProperty;
53 		@GodotName("class_set_property") GodotMethod!(GodotError, GodotObject, String, Variant) classSetProperty;
54 		@GodotName("class_has_method") GodotMethod!(bool, String, String, bool) classHasMethod;
55 		@GodotName("class_get_method_list") GodotMethod!(Array, String, bool) classGetMethodList;
56 		@GodotName("class_get_integer_constant_list") GodotMethod!(PoolStringArray, String, bool) classGetIntegerConstantList;
57 		@GodotName("class_has_integer_constant") GodotMethod!(bool, String, String) classHasIntegerConstant;
58 		@GodotName("class_get_integer_constant") GodotMethod!(long, String, String) classGetIntegerConstant;
59 		@GodotName("class_get_category") GodotMethod!(String, String) classGetCategory;
60 		@GodotName("is_class_enabled") GodotMethod!(bool, String) isClassEnabled;
61 	}
62 	bool opEquals(in ClassDBSingleton other) const { return _godot_object.ptr is other._godot_object.ptr; }
63 	ClassDBSingleton opAssign(T : typeof(null))(T n) { _godot_object.ptr = null; }
64 	bool opEquals(typeof(null) n) const { return _godot_object.ptr is null; }
65 	mixin baseCasts;
66 	static ClassDBSingleton _new()
67 	{
68 		static godot_class_constructor constructor;
69 		if(constructor is null) constructor = _godot_api.godot_get_class_constructor("_ClassDB");
70 		if(constructor is null) return typeof(this).init;
71 		return cast(ClassDBSingleton)(constructor());
72 	}
73 	@disable new(size_t s);
74 	/**
75 	Returns the names of all the classes available.
76 	*/
77 	PoolStringArray getClassList() const
78 	{
79 		checkClassBinding!(typeof(this))();
80 		return ptrcall!(PoolStringArray)(_classBinding.getClassList, _godot_object);
81 	}
82 	/**
83 	Returns the names of all the classes that directly or indirectly inherit from 'class'.
84 	*/
85 	PoolStringArray getInheritersFromClass(StringArg0)(in StringArg0 _class) const
86 	{
87 		checkClassBinding!(typeof(this))();
88 		return ptrcall!(PoolStringArray)(_classBinding.getInheritersFromClass, _godot_object, _class);
89 	}
90 	/**
91 	Returns the parent class of 'class'.
92 	*/
93 	String getParentClass(StringArg0)(in StringArg0 _class) const
94 	{
95 		checkClassBinding!(typeof(this))();
96 		return ptrcall!(String)(_classBinding.getParentClass, _godot_object, _class);
97 	}
98 	/**
99 	Returns whether the specified 'class' is available or not.
100 	*/
101 	bool classExists(StringArg0)(in StringArg0 _class) const
102 	{
103 		checkClassBinding!(typeof(this))();
104 		return ptrcall!(bool)(_classBinding.classExists, _godot_object, _class);
105 	}
106 	/**
107 	Returns whether 'inherits' is an ancestor of 'class' or not.
108 	*/
109 	bool isParentClass(StringArg0, StringArg1)(in StringArg0 _class, in StringArg1 inherits) const
110 	{
111 		checkClassBinding!(typeof(this))();
112 		return ptrcall!(bool)(_classBinding.isParentClass, _godot_object, _class, inherits);
113 	}
114 	/**
115 	Returns true if you can instance objects from the specified 'class', false in other case.
116 	*/
117 	bool canInstance(StringArg0)(in StringArg0 _class) const
118 	{
119 		checkClassBinding!(typeof(this))();
120 		return ptrcall!(bool)(_classBinding.canInstance, _godot_object, _class);
121 	}
122 	/**
123 	Creates an instance of 'class'.
124 	*/
125 	Variant instance(StringArg0)(in StringArg0 _class) const
126 	{
127 		checkClassBinding!(typeof(this))();
128 		return ptrcall!(Variant)(_classBinding.instance, _godot_object, _class);
129 	}
130 	/**
131 	Return whether 'class' or its ancestry has a signal called 'signal' or not.
132 	*/
133 	bool classHasSignal(StringArg0, StringArg1)(in StringArg0 _class, in StringArg1 signal) const
134 	{
135 		checkClassBinding!(typeof(this))();
136 		return ptrcall!(bool)(_classBinding.classHasSignal, _godot_object, _class, signal);
137 	}
138 	/**
139 	Returns the 'signal' data of 'class' or its ancestry. The returned value is a $(D Dictionary) with the following keys: args, default_args, flags, id, name, return: (class_name, hint, hint_string, name, type, usage).
140 	*/
141 	Dictionary classGetSignal(StringArg0, StringArg1)(in StringArg0 _class, in StringArg1 signal) const
142 	{
143 		checkClassBinding!(typeof(this))();
144 		return ptrcall!(Dictionary)(_classBinding.classGetSignal, _godot_object, _class, signal);
145 	}
146 	/**
147 	Returns an array with all the signals of 'class' or its ancestry if 'no_inheritance' is false. Every element of the array is a $(D Dictionary) as described in $(D classGetSignal).
148 	*/
149 	Array classGetSignalList(StringArg0)(in StringArg0 _class, in bool no_inheritance = false) const
150 	{
151 		checkClassBinding!(typeof(this))();
152 		return ptrcall!(Array)(_classBinding.classGetSignalList, _godot_object, _class, no_inheritance);
153 	}
154 	/**
155 	Returns an array with all the properties of 'class' or its ancestry if 'no_inheritance' is false.
156 	*/
157 	Array classGetPropertyList(StringArg0)(in StringArg0 _class, in bool no_inheritance = false) const
158 	{
159 		checkClassBinding!(typeof(this))();
160 		return ptrcall!(Array)(_classBinding.classGetPropertyList, _godot_object, _class, no_inheritance);
161 	}
162 	/**
163 	Returns the value of 'property' of 'class' or its ancestry.
164 	*/
165 	Variant classGetProperty(StringArg1)(GodotObject object, in StringArg1 property) const
166 	{
167 		checkClassBinding!(typeof(this))();
168 		return ptrcall!(Variant)(_classBinding.classGetProperty, _godot_object, object, property);
169 	}
170 	/**
171 	Sets 'property' value of 'class' to 'value'.
172 	*/
173 	GodotError classSetProperty(StringArg1, VariantArg2)(GodotObject object, in StringArg1 property, in VariantArg2 value) const
174 	{
175 		checkClassBinding!(typeof(this))();
176 		return ptrcall!(GodotError)(_classBinding.classSetProperty, _godot_object, object, property, value);
177 	}
178 	/**
179 	Return whether 'class' (or its ancestry if 'no_inheritance' is false) has a method called 'method' or not.
180 	*/
181 	bool classHasMethod(StringArg0, StringArg1)(in StringArg0 _class, in StringArg1 method, in bool no_inheritance = false) const
182 	{
183 		checkClassBinding!(typeof(this))();
184 		return ptrcall!(bool)(_classBinding.classHasMethod, _godot_object, _class, method, no_inheritance);
185 	}
186 	/**
187 	Returns an array with all the methods of 'class' or its ancestry if 'no_inheritance' is false. Every element of the array is a $(D Dictionary) with the following keys: args, default_args, flags, id, name, return: (class_name, hint, hint_string, name, type, usage).
188 	*/
189 	Array classGetMethodList(StringArg0)(in StringArg0 _class, in bool no_inheritance = false) const
190 	{
191 		checkClassBinding!(typeof(this))();
192 		return ptrcall!(Array)(_classBinding.classGetMethodList, _godot_object, _class, no_inheritance);
193 	}
194 	/**
195 	Returns an array with the names all the integer constants of 'class' or its ancestry.
196 	*/
197 	PoolStringArray classGetIntegerConstantList(StringArg0)(in StringArg0 _class, in bool no_inheritance = false) const
198 	{
199 		checkClassBinding!(typeof(this))();
200 		return ptrcall!(PoolStringArray)(_classBinding.classGetIntegerConstantList, _godot_object, _class, no_inheritance);
201 	}
202 	/**
203 	Return whether 'class' or its ancestry has an integer constant called 'name' or not.
204 	*/
205 	bool classHasIntegerConstant(StringArg0, StringArg1)(in StringArg0 _class, in StringArg1 name) const
206 	{
207 		checkClassBinding!(typeof(this))();
208 		return ptrcall!(bool)(_classBinding.classHasIntegerConstant, _godot_object, _class, name);
209 	}
210 	/**
211 	Returns the value of the integer constant 'name' of 'class' or its ancestry. Always returns 0 when the constant could not be found.
212 	*/
213 	long classGetIntegerConstant(StringArg0, StringArg1)(in StringArg0 _class, in StringArg1 name) const
214 	{
215 		checkClassBinding!(typeof(this))();
216 		return ptrcall!(long)(_classBinding.classGetIntegerConstant, _godot_object, _class, name);
217 	}
218 	/**
219 	Returns a category associated with the class for use in documentation and the Asset Library. Debug mode required.
220 	*/
221 	String classGetCategory(StringArg0)(in StringArg0 _class) const
222 	{
223 		checkClassBinding!(typeof(this))();
224 		return ptrcall!(String)(_classBinding.classGetCategory, _godot_object, _class);
225 	}
226 	/**
227 	Returns whether this class is enabled or not.
228 	*/
229 	bool isClassEnabled(StringArg0)(in StringArg0 _class) const
230 	{
231 		checkClassBinding!(typeof(this))();
232 		return ptrcall!(bool)(_classBinding.isClassEnabled, _godot_object, _class);
233 	}
234 }
235 /// Returns: the ClassDBSingleton
236 @property @nogc nothrow pragma(inline, true)
237 ClassDBSingleton ClassDB()
238 {
239 	checkClassBinding!ClassDBSingleton();
240 	return ClassDBSingleton(ClassDBSingleton._classBinding._singleton);
241 }