4 #include "GDCore/Extensions/Metadata/ParameterMetadataTools.h"
5 #include "ObjectsContainersList.h"
6 #include "PropertiesContainersList.h"
7 #include "VariablesContainersList.h"
8 #include "VariablesContainer.h"
12 class ObjectsContainer;
13 class NamedPropertyDescriptor;
14 class ParameterMetadataContainer;
16 class EventsFunctionsExtension;
18 class EventsBasedBehavior;
19 class EventsBasedObject;
42 : objectsContainersList(objectsContainersList_),
43 variablesContainersList(variablesContainersList_),
44 legacyGlobalVariables(legacyGlobalVariables_),
45 legacySceneVariables(legacySceneVariables_),
46 propertiesContainersList(propertiesContainersList_){};
50 MakeNewProjectScopedContainersForProjectAndLayout(
const gd::Project &project,
54 MakeNewProjectScopedContainersForProject(
const gd::Project &project);
64 MakeNewProjectScopedContainersForEventsFunctionsExtension(
69 MakeNewProjectScopedContainersForFreeEventsFunction(
76 MakeNewProjectScopedContainersForBehaviorEventsFunction(
84 MakeNewProjectScopedContainersForObjectEventsFunction(
92 MakeNewProjectScopedContainersForEventsBasedObject(
99 MakeNewProjectScopedContainersWithLocalVariables(
105 propertiesContainersList.
Add(container);
112 parametersVectorsList.push_back(¶meters);
117 template <
class ReturnType>
118 ReturnType MatchIdentifierWithName(
120 std::function<ReturnType()> objectCallback,
121 std::function<ReturnType()> variableCallback,
122 std::function<ReturnType()> propertyCallback,
123 std::function<ReturnType()> parameterCallback,
124 std::function<ReturnType()> notFoundCallback)
const {
126 return objectCallback();
127 else if (variablesContainersList.
Has(name))
128 return variableCallback();
129 else if (ParameterMetadataTools::Has(parametersVectorsList, name))
130 return parameterCallback();
131 else if (propertiesContainersList.
Has(name))
132 return propertyCallback();
134 return notFoundCallback();
137 void ForEachIdentifierMatchingSearch(
147 parameterCallback)
const {
148 std::set<gd::String> namesAlreadySeen;
154 if (namesAlreadySeen.count(name) == 0) {
155 namesAlreadySeen.insert(name);
156 objectCallback(name, objectConfiguration);
161 if (namesAlreadySeen.count(name) == 0) {
162 namesAlreadySeen.insert(name);
163 variableCallback(name, variable);
166 gd::ParameterMetadataTools::ForEachParameterMatchingSearch(
167 parametersVectorsList,
170 if (namesAlreadySeen.count(parameter.
GetName()) == 0) {
171 namesAlreadySeen.insert(parameter.GetName());
172 parameterCallback(parameter);
177 if (namesAlreadySeen.count(property.
GetName()) == 0) {
178 namesAlreadySeen.insert(property.GetName());
179 propertyCallback(property);
185 return objectsContainersList;
189 return variablesContainersList;
197 return variablesContainersList;
206 return legacyGlobalVariables;
215 return legacySceneVariables;
219 return propertiesContainersList;
222 const std::vector<const ParameterMetadataContainer *> &GetParametersVectorsList()
const {
223 return parametersVectorsList;
229 : legacyGlobalVariables(nullptr), legacySceneVariables(nullptr){};
237 std::vector<const ParameterMetadataContainer *> parametersVectorsList;
Base class defining an event.
Definition: Event.h:43
Represents a behavior that is implemented with events.
Definition: EventsBasedBehavior.h:32
Represents an object that is implemented with events.
Definition: EventsBasedObject.h:30
Events that can be generated as a stand-alone function, and used as a condition, action or expression...
Definition: EventsFunction.h:38
Hold a list of Events Functions (gd::EventsFunction) and Events Based Behaviors.
Definition: EventsFunctionsExtension.h:38
Represent a layout ( also called a scene ) of a project.
Definition: Layout.h:40
Used to describe a property shown in a property grid.
Definition: NamedPropertyDescriptor.h:21
const gd::String & GetName() const
Get the name of the property.
Definition: NamedPropertyDescriptor.h:47
Base class used to represent an object configuration. For example, this can be the animations in a sp...
Definition: ObjectConfiguration.h:38
Used as a base class for classes that will own objects (see gd::Object).
Definition: ObjectsContainer.h:37
A list of objects containers, useful for accessing objects in a scoped way, along with methods to acc...
Definition: ObjectsContainersList.h:29
void ForEachNameMatchingSearch(const gd::String &search, std::function< void(const gd::String &name, const gd::ObjectConfiguration *objectConfiguration)> fn) const
Call the callback for each object or group name matching the search passed in parameter.
Definition: ObjectsContainersList.cpp:332
bool HasObjectOrGroupNamed(const gd::String &name) const
Check if the specified object or group exists.
Definition: ObjectsContainersList.cpp:56
Base class representing a project (game), including all resources, scenes, objects,...
Definition: Project.h:51
Holds references to variables, objects, properties and other containers.
Definition: ProjectScopedContainers.h:34
static ProjectScopedContainers MakeNewProjectScopedContainersFor(const gd::ObjectsContainer &globalObjectsContainers, const gd::ObjectsContainer &objectsContainers)
Definition: ProjectScopedContainers.cpp:43
gd::VariablesContainersList & GetVariablesContainersList()
Allow modification of the variables containers list. This is used by code generation which does push ...
Definition: ProjectScopedContainers.h:196
const gd::VariablesContainer * GetLegacyGlobalVariables() const
Return the global variables of the current scene or the current extension. It allows legacy "globalva...
Definition: ProjectScopedContainers.h:205
ProjectScopedContainers()
Definition: ProjectScopedContainers.h:228
const gd::VariablesContainer * GetLegacySceneVariables() const
Return the scene variables of the current scene or the current extension. It allows legacy "scenevar"...
Definition: ProjectScopedContainers.h:214
A container of properties, used for custom behaviors, custom objects, extensions.....
Definition: PropertiesContainer.h:17
A list of property containers, useful for accessing properties in a scoped way.
Definition: PropertiesContainersList.h:26
bool Has(const gd::String &name) const
Return true if the specified property is in one of the containers.
Definition: PropertiesContainersList.cpp:27
void Add(const gd::PropertiesContainer &propertiesContainer)
Add a new container of properties in the list. Add containers in order from the most global one to th...
Definition: PropertiesContainersList.h:38
void ForEachPropertyMatchingSearch(const gd::String &search, std::function< void(const gd::NamedPropertyDescriptor &property)> fn) const
Call the callback for each property having a name matching the specified search.
Definition: PropertiesContainersList.cpp:58
String represents an UTF8 encoded string.
Definition: String.h:33
Defines a variable which can be used by an object, a layout or a project.
Definition: Variable.h:29
Class defining a container for gd::Variable.
Definition: VariablesContainer.h:28
A list of variables containers, useful for accessing variables in a scoped way.
Definition: VariablesContainersList.h:26
bool Has(const gd::String &name) const
Return true if the specified variable is in one of the containers.
Definition: VariablesContainersList.cpp:58
void ForEachVariableMatchingSearch(const gd::String &search, std::function< void(const gd::String &name, const gd::Variable &variable)> fn) const
Call the callback for each variable having a name matching the specified search.
Definition: VariablesContainersList.cpp:116
Definition: CommonTools.h:24