GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
MetadataProvider.h
1 /*
2  * GDevelop Core
3  * Copyright 2008-2016 Florian Rival ([email protected]). All rights
4  * reserved. This project is released under the MIT License.
5  */
6 #ifndef METADATAPROVIDER_H
7 #define METADATAPROVIDER_H
8 #include "GDCore/Extensions/Metadata/InstructionMetadata.h"
9 #include "GDCore/String.h"
10 namespace gd {
11 class BehaviorMetadata;
12 class ObjectMetadata;
13 class EffectMetadata;
14 class ExpressionMetadata;
15 class ExpressionMetadata;
16 class Platform;
17 class PlatformExtension;
18 class ObjectsContainersList;
19 struct FunctionCallNode;
20 struct ExpressionNode;
21 } // namespace gd
22 
23 namespace gd {
24 
29 template <class T>
31  public:
33  const T& metadata_)
34  : extension(&extension_), metadata(&metadata_){};
35 
41  ExtensionAndMetadata() : extension(nullptr), metadata(nullptr){};
42 
46  const gd::PlatformExtension& GetExtension() { return *extension; };
47 
51  const T& GetMetadata() { return *metadata; };
52 
53  private:
54  const gd::PlatformExtension* extension;
55  const T* metadata;
56 };
57 
64 class GD_CORE_API MetadataProvider {
65  public:
69  static ExtensionAndMetadata<BehaviorMetadata> GetExtensionAndBehaviorMetadata(
70  const gd::Platform& platform, gd::String behaviorType);
71 
75  static ExtensionAndMetadata<ObjectMetadata> GetExtensionAndObjectMetadata(
76  const gd::Platform& platform, gd::String type);
77 
81  static ExtensionAndMetadata<EffectMetadata> GetExtensionAndEffectMetadata(
82  const gd::Platform& platform, gd::String type);
83 
89  GetExtensionAndActionMetadata(const gd::Platform& platform,
90  gd::String actionType);
91 
97  GetExtensionAndConditionMetadata(const gd::Platform& platform,
98  gd::String conditionType);
99 
105  GetExtensionAndExpressionMetadata(const gd::Platform& platform,
106  gd::String exprType);
107 
113  GetExtensionAndObjectExpressionMetadata(const gd::Platform& platform,
114  gd::String objectType,
115  gd::String exprType);
116 
122  GetExtensionAndBehaviorExpressionMetadata(const gd::Platform& platform,
123  gd::String autoType,
124  gd::String exprType);
125 
131  GetExtensionAndStrExpressionMetadata(const gd::Platform& platform,
132  gd::String exprType);
133 
139  GetExtensionAndObjectStrExpressionMetadata(const gd::Platform& platform,
140  gd::String objectType,
141  gd::String exprType);
142 
148  GetExtensionAndBehaviorStrExpressionMetadata(const gd::Platform& platform,
149  gd::String autoType,
150  gd::String exprType);
151 
155  static const BehaviorMetadata& GetBehaviorMetadata(
156  const gd::Platform& platform, gd::String behaviorType);
157 
161  static const ObjectMetadata& GetObjectMetadata(const gd::Platform& platform,
162  gd::String type);
163 
167  static const EffectMetadata& GetEffectMetadata(const gd::Platform& platform,
168  gd::String type);
169 
174  static const gd::InstructionMetadata& GetActionMetadata(
175  const gd::Platform& platform, gd::String actionType);
176 
181  static const gd::InstructionMetadata& GetConditionMetadata(
182  const gd::Platform& platform, gd::String conditionType);
183 
188  static const gd::ExpressionMetadata& GetExpressionMetadata(
189  const gd::Platform& platform, gd::String exprType);
190 
195  static const gd::ExpressionMetadata& GetObjectExpressionMetadata(
196  const gd::Platform& platform, gd::String objectType, gd::String exprType);
197 
202  static const gd::ExpressionMetadata& GetBehaviorExpressionMetadata(
203  const gd::Platform& platform, gd::String autoType, gd::String exprType);
204 
209  static const gd::ExpressionMetadata& GetStrExpressionMetadata(
210  const gd::Platform& platform, gd::String exprType);
211 
216  static const gd::ExpressionMetadata& GetObjectStrExpressionMetadata(
217  const gd::Platform& platform, gd::String objectType, gd::String exprType);
218 
223  static const gd::ExpressionMetadata& GetBehaviorStrExpressionMetadata(
224  const gd::Platform& platform, gd::String autoType, gd::String exprType);
225 
230  static const gd::ExpressionMetadata& GetAnyExpressionMetadata(
231  const gd::Platform& platform, gd::String exprType);
232 
237  static const gd::ExpressionMetadata& GetObjectAnyExpressionMetadata(
238  const gd::Platform& platform, gd::String objectType, gd::String exprType);
239 
240  static const gd::ExpressionMetadata& GetFunctionCallMetadata(
241  const gd::Platform& platform,
242  const gd::ObjectsContainersList &objectsContainersList,
243  FunctionCallNode& node);
244 
245  static const gd::ParameterMetadata* GetFunctionCallParameterMetadata(
246  const gd::Platform& platform,
247  const gd::ObjectsContainersList &objectsContainersList,
248  FunctionCallNode& functionCall,
249  ExpressionNode& parameter);
250 
251  static const gd::ParameterMetadata* GetFunctionCallParameterMetadata(
252  const gd::Platform& platform,
253  const gd::ObjectsContainersList &objectsContainersList,
254  FunctionCallNode& functionCall,
255  int parameterIndex);
256 
261  static const gd::ExpressionMetadata& GetBehaviorAnyExpressionMetadata(
262  const gd::Platform& platform, gd::String autoType, gd::String exprType);
263 
264  static bool IsBadExpressionMetadata(const gd::ExpressionMetadata& metadata) {
265  return &metadata == &badExpressionMetadata;
266  }
267 
268  static bool IsBadInstructionMetadata(const gd::InstructionMetadata& metadata) {
269  return &metadata == &badInstructionMetadata;
270  }
271 
272  static bool IsBadBehaviorMetadata(const gd::BehaviorMetadata& metadata) {
273  return &metadata == &badBehaviorMetadata;
274  }
275 
276  static bool IsBadObjectMetadata(const gd::ObjectMetadata& metadata) {
277  return &metadata == &badObjectInfo;
278  }
279 
280  virtual ~MetadataProvider();
281 
282  private:
284 
285  static PlatformExtension badExtension;
286  static BehaviorMetadata badBehaviorMetadata;
287  static ObjectMetadata badObjectInfo;
288  static EffectMetadata badEffectMetadata;
289  static gd::InstructionMetadata badInstructionMetadata;
290  static gd::ExpressionMetadata badExpressionMetadata;
291  int useless; // Useless member to avoid emscripten "must have a positive
292  // integer typeid pointer" runtime error.
293 };
294 
295 } // namespace gd
296 
297 #endif // METADATAPROVIDER_H
Contains user-friendly information about a behavior type.
Definition: BehaviorMetadata.h:31
Contains user-friendly information about an effect.
Definition: EffectMetadata.h:23
Describe user-friendly information about an expression, its parameters and the function name as well ...
Definition: ExpressionMetadata.h:47
A container for metadata about an object/behavior/instruction/expression and its associated extension...
Definition: MetadataProvider.h:30
const gd::PlatformExtension & GetExtension()
Get the associated extension.
Definition: MetadataProvider.h:46
const T & GetMetadata()
Get the metadata.
Definition: MetadataProvider.h:51
Describe user-friendly information about an instruction (action or condition), its parameters and the...
Definition: InstructionMetadata.h:38
Allow to easily get metadata for instructions (i.e actions and conditions), expressions,...
Definition: MetadataProvider.h:64
Contains user-friendly information about an object type, and a function to create a new gd::Object of...
Definition: ObjectMetadata.h:37
A list of objects containers, useful for accessing objects in a scoped way, along with methods to acc...
Definition: ObjectsContainersList.h:29
Describe a parameter of an instruction (action, condition) or of an expression: type,...
Definition: ParameterMetadata.h:27
Base class for implementing platform's extensions.
Definition: PlatformExtension.h:84
Base class for implementing a platform.
Definition: Platform.h:42
String represents an UTF8 encoded string.
Definition: String.h:31
Definition: CommonTools.h:24
The base node, from which all nodes in the tree of an expression inherits from.
Definition: ExpressionParser2Node.h:93
A function call node (either free function, object function or object behavior function)....
Definition: ExpressionParser2Node.h:364