GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
ParameterMetadata.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 
7 #ifndef PARAMETER_METADATA_H
8 #define PARAMETER_METADATA_H
9 #include <map>
10 #include <memory>
11 
12 #include "GDCore/String.h"
13 #include "GDCore/Extensions/Metadata/ValueTypeMetadata.h"
14 
15 namespace gd {
16 class SerializerElement;
17 } // namespace gd
18 
19 namespace gd {
20 
27 class GD_CORE_API ParameterMetadata {
28  public:
30  virtual ~ParameterMetadata(){};
31 
35  gd::ValueTypeMetadata &GetValueTypeMetadata() { return valueTypeMetadata; }
36 
40  const gd::ValueTypeMetadata &GetValueTypeMetadata() const { return valueTypeMetadata; }
41 
46  valueTypeMetadata = valueTypeMetadata_;
47  return *this;
48  }
49 
55  const gd::String &GetType() const { return valueTypeMetadata.GetName(); }
56 
62  valueTypeMetadata.SetName(type_);
63  return *this;
64  }
65 
73  const gd::String &GetName() const { return name; }
74 
83  name = name_;
84  return *this;
85  }
86 
93  const gd::String &GetExtraInfo() const { return valueTypeMetadata.GetExtraInfo(); }
94 
101  ParameterMetadata &SetExtraInfo(const gd::String &supplementaryInformation_) {
102  valueTypeMetadata.SetExtraInfo(supplementaryInformation_);
103  return *this;
104  }
105 
110  bool IsOptional() const { return valueTypeMetadata.IsOptional(); }
111 
116  ParameterMetadata &SetOptional(bool optional_ = true) {
117  valueTypeMetadata.SetOptional(optional_);
118  return *this;
119  }
120 
124  const gd::String &GetDescription() const { return description; }
125 
130  description = description_;
131  return *this;
132  }
133 
138  bool IsCodeOnly() const { return codeOnly; }
139 
144  ParameterMetadata &SetCodeOnly(bool codeOnly_ = true) {
145  codeOnly = codeOnly_;
146  return *this;
147  }
148 
152  const gd::String &GetDefaultValue() const {
153  return valueTypeMetadata.GetDefaultValue();
154  }
155 
160  valueTypeMetadata.SetDefaultValue(defaultValue_);
161  return *this;
162  }
163 
167  const gd::String &GetLongDescription() const { return longDescription; }
168 
172  ParameterMetadata &SetLongDescription(const gd::String &longDescription_) {
173  longDescription = longDescription_;
174  return *this;
175  }
176 
177  // TODO Remove these deprecated functions.
178 
186  static bool IsObject(const gd::String &parameterType) {
187  return gd::ValueTypeMetadata::IsTypeObject(parameterType);
188  }
189 
196  static bool IsBehavior(const gd::String &parameterType) {
197  return gd::ValueTypeMetadata::IsTypeBehavior(parameterType);
198  }
199 
208  static bool IsExpression(const gd::String &type,
209  const gd::String &parameterType) {
210  return gd::ValueTypeMetadata::IsTypeExpression(type, parameterType);
211  }
212 
219  static const gd::String &GetExpressionValueType(const gd::String &parameterType) {
221  }
222 
226 
229  void SerializeTo(gd::SerializerElement &element) const;
230 
234  void UnserializeFrom(const gd::SerializerElement &element);
236 
237  // TODO: Deprecated public fields. Any direct usage should be moved to
238  // getter/setter.
239 
241  bool codeOnly;
243  private:
244  gd::ValueTypeMetadata valueTypeMetadata;
245  gd::String longDescription;
246  gd::String name;
248 };
249 
250 } // namespace gd
251 
252 #endif // PARAMETER_METADATA_H
Describe a parameter of an instruction (action, condition) or of an expression: type,...
Definition: ParameterMetadata.h:27
ParameterMetadata & SetName(const gd::String &name_)
Set the name of the parameter.
Definition: ParameterMetadata.h:82
ParameterMetadata & SetDefaultValue(const gd::String &defaultValue_)
Set the default value, if the parameter is optional.
Definition: ParameterMetadata.h:159
ParameterMetadata & SetLongDescription(const gd::String &longDescription_)
Set the user friendly, long description for the parameter.
Definition: ParameterMetadata.h:172
ParameterMetadata & SetExtraInfo(const gd::String &supplementaryInformation_)
Set an optional additional information, used for some parameters with special type (for example,...
Definition: ParameterMetadata.h:101
const gd::ValueTypeMetadata & GetValueTypeMetadata() const
Return the metadata of the parameter type.
Definition: ParameterMetadata.h:40
ParameterMetadata & SetType(const gd::String &type_)
Set the type of the parameter.
Definition: ParameterMetadata.h:61
const gd::String & GetName() const
Return the name of the parameter.
Definition: ParameterMetadata.h:73
static bool IsExpression(const gd::String &type, const gd::String &parameterType)
Return true if the type of the parameter is an expression of the given type.
Definition: ParameterMetadata.h:208
bool IsOptional() const
Return true if the parameter is optional.
Definition: ParameterMetadata.h:110
ParameterMetadata & SetDescription(const gd::String &description_)
Set the description of the parameter.
Definition: ParameterMetadata.h:129
gd::ValueTypeMetadata & GetValueTypeMetadata()
Return the metadata of the parameter type.
Definition: ParameterMetadata.h:35
static const gd::String & GetExpressionValueType(const gd::String &parameterType)
Return the expression type from the parameter type. Declinations of "number" and "string" types (like...
Definition: ParameterMetadata.h:219
ParameterMetadata & SetValueTypeMetadata(const gd::ValueTypeMetadata &valueTypeMetadata_)
Set the metadata of the parameter type.
Definition: ParameterMetadata.h:45
const gd::String & GetExtraInfo() const
Return an optional additional information, used for some parameters with special type (for example,...
Definition: ParameterMetadata.h:93
const gd::String & GetDescription() const
Return the description of the parameter.
Definition: ParameterMetadata.h:124
static bool IsObject(const gd::String &parameterType)
Return true if the type of the parameter is representing one object (or more, i.e: an object group).
Definition: ParameterMetadata.h:186
ParameterMetadata & SetOptional(bool optional_=true)
Set if the parameter is optional.
Definition: ParameterMetadata.h:116
gd::String description
Description shown in editor.
Definition: ParameterMetadata.h:240
bool codeOnly
Definition: ParameterMetadata.h:241
static bool IsBehavior(const gd::String &parameterType)
Return true if the type of the parameter is "behavior".
Definition: ParameterMetadata.h:196
const gd::String & GetLongDescription() const
Get the user friendly, long description for the parameter.
Definition: ParameterMetadata.h:167
bool IsCodeOnly() const
Return true if the parameter is only meant to be completed during compilation and must not be display...
Definition: ParameterMetadata.h:138
const gd::String & GetDefaultValue() const
Get the default value for the parameter.
Definition: ParameterMetadata.h:152
ParameterMetadata & SetCodeOnly(bool codeOnly_=true)
Set if the parameter is only meant to be completed during compilation and must not be displayed to th...
Definition: ParameterMetadata.h:144
const gd::String & GetType() const
Return the type of the parameter.
Definition: ParameterMetadata.h:55
A generic container that can represent a value ( containing a string, double, bool or int),...
Definition: SerializerElement.h:37
String represents an UTF8 encoded string.
Definition: String.h:31
Define a type for parameters of a function (action, condition or expression) or the returned value of...
Definition: ValueTypeMetadata.h:26
static bool IsTypeBehavior(const gd::String &parameterType)
Return true if the type is "behavior".
Definition: ValueTypeMetadata.h:173
static bool IsTypeExpression(const gd::String &type, const gd::String &parameterType)
Return true if the type is an expression of the given type.
Definition: ValueTypeMetadata.h:183
static const gd::String & GetExpressionPrimitiveValueType(const gd::String &parameterType)
Return the expression type from the parameter type. Declinations of "number" and "string" types (like...
Definition: ValueTypeMetadata.cpp:41
static bool IsTypeObject(const gd::String &parameterType)
Return true if the type is representing one object (or more, i.e: an object group).
Definition: ValueTypeMetadata.h:163
Definition: CommonTools.h:24