Game Develop Core: InstructionMetadata.h Source File

| Game Develop Core Core library for developing platforms and tools compatible with Game Develop.

- Main Page
- Modules
- Classes

- File List
- File Members

All Classes Files Functions Variables Typedefs Enumerations Macros Groups Pages
InstructionMetadata.h
Go to the documentation of this file.
1
6 #ifndef INSTRUCTIONMETADATA_H
7 #define INSTRUCTIONMETADATA_H
8 #if defined(GD_IDE_ONLY)
9 #include <string>
10 #include "GDCore/Events/Instruction.h"
11 #include <boost/shared_ptr.hpp>
12 #if !defined(GD_NO_WX_GUI)
13 #include <wx/bitmap.h>
14 #endif
15 class wxBitmap;
16 namespace gd { class Project; }
17 namespace gd { class Layout; }
18 namespace gd { class EventsCodeGenerator; }
19 namespace gd { class EventsCodeGenerationContext; }
20
21 namespace gd
22 {
23
29 class GD_CORE_API ParameterMetadata
30 {
31 public:
32
33 ParameterMetadata();
34 virtual ~ParameterMetadata() {};
35
36 std::string type;
37 std::string supplementaryInformation;
38 bool optional;
39
40 std::string description;
41 bool codeOnly;
42 std::string defaultValue;
43
47 static bool IsObject(const std::string & type) { return type == "object" || type == "objectPtr" || type == "objectList" || type == "objectListWithoutPicking"; }
48 };
49
55 class GD_CORE_API InstructionMetadata
56 {
57 public:
58
59 InstructionMetadata(const std::string & extensionNamespace,
60 const std::string & name,
61 const std::string & fullname,
62 const std::string & description,
63 const std::string & sentence,
64 const std::string & group,
65 const std::string & icon,
66 const std::string & smallicon);
67 virtual ~InstructionMetadata() {};
68
69 const std::string & GetFullName() const { return fullname; }
70 const std::string & GetDescription() const { return description; }
71 const std::string & GetSentence() const { return sentence; }
72 const std::string & GetGroup() const { return group; }
73 #if !defined(GD_NO_WX_GUI)
74 const wxBitmap & GetBitmapIcon() const { return icon; }
75 const wxBitmap & GetSmallBitmapIcon() const { return smallicon; }
76 #endif
77 bool CanHaveSubInstructions() const { return canHaveSubInstructions; }
78
82 InstructionMetadata & SetCanHaveSubInstructions()
83 {
84 canHaveSubInstructions = true;
85 return *this;
86 }
87
93 InstructionMetadata & SetHidden()
94 {
95 hidden = true;
96 return *this;
97 }
98
102 InstructionMetadata & SetGroup(const std::string & str)
103 {
104 group = str;
105 return *this;
106 }
107
111 bool IsHidden() const { return hidden; }
112
121 InstructionMetadata & AddParameter(const std::string & type, const std::string & description, const std::string & optionalObjectType = "", bool parameterIsOptional = false);
122
128 InstructionMetadata & AddCodeOnlyParameter(const std::string & type, const std::string & supplementaryInformation);
129
135 InstructionMetadata & SetDefaultValue(std::string defaultValue_)
136 {
137 if ( !parameters.empty() ) parameters.back().defaultValue = defaultValue_;
138 return *this;
139 };
140
144 class ExtraInformation
145 {
146 public:
147 enum AccessType {Reference, MutatorAndOrAccessor};
148 ExtraInformation() : accessType(Reference) {};
149 virtual ~ExtraInformation() {};
150
154 ExtraInformation & SetFunctionName(const std::string & cppCallingName_)
155 {
156 functionCallName = cppCallingName_;
157 return *this;
158 }
159
163 ExtraInformation & SetManipulatedType(const std::string & type_)
164 {
165 type = type_;
166 return *this;
167 }
168
192 ExtraInformation & SetAssociatedGetter(const std::string & getter)
193 {
194 optionalAssociatedInstruction = getter;
195 accessType = MutatorAndOrAccessor;
196 return *this;
197 }
198
202 ExtraInformation & SetIncludeFile(const std::string & optionalIncludeFile_)
203 {
204 optionalIncludeFile = optionalIncludeFile_;
205 return *this;
206 }
207
210 class CustomCodeGenerator
211 {
212 public:
213 virtual std::string GenerateCode(Instruction & instruction, gd::EventsCodeGenerator & codeGenerator_, gd::EventsCodeGenerationContext & context) {return "";};
214 };
215
216 ExtraInformation & SetCustomCodeGenerator(boost::shared_ptr<CustomCodeGenerator> codeGenerator)
217 {
218 optionalCustomCodeGenerator = codeGenerator;
219 return *this;
220 }
221
222 std::string functionCallName;
223 std::string type;
224 AccessType accessType;
225 std::string optionalAssociatedInstruction;
226 std::string optionalIncludeFile;
227 boost::shared_ptr<CustomCodeGenerator> optionalCustomCodeGenerator;
228 };
229 ExtraInformation codeExtraInformation;
230
235 InstructionMetadata();
236
237 std::vector < ParameterMetadata > parameters;
238 private:
239
240 std::string fullname;
241 std::string description;
242 std::string sentence;
243 std::string group;
244 #if !defined(GD_NO_WX_GUI)
245 wxBitmap icon;
246 wxBitmap smallicon;
247 #endif
248 bool canHaveSubInstructions;
249 std::string extensionNamespace;
250 bool hidden;
251 };
252
253 }
254
255 #endif
256 #endif // INSTRUCTIONMETADATA_H
257
258