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(
77 MakeNewProjectScopedContainersForBehaviorEventsFunction(
87 MakeNewProjectScopedContainersForObjectEventsFunction(
97 MakeNewProjectScopedContainersForEventsBasedObject(
104 MakeNewProjectScopedContainersWithLocalVariables(
110 propertiesContainersList.
Add(container);
117 parametersVectorsList.push_back(¶meters);
122 template <
class ReturnType>
123 ReturnType MatchIdentifierWithName(
125 std::function<ReturnType()> objectCallback,
126 std::function<ReturnType()> variableCallback,
127 std::function<ReturnType()> propertyCallback,
128 std::function<ReturnType()> parameterCallback,
129 std::function<ReturnType()> notFoundCallback)
const {
131 return objectCallback();
132 else if (variablesContainersList.
Has(name)) {
133 const auto &variablesContainer =
135 const auto sourceType = variablesContainer.GetSourceType();
136 if (sourceType == gd::VariablesContainer::SourceType::Properties) {
137 return propertyCallback();
138 }
else if (sourceType == gd::VariablesContainer::SourceType::Parameters) {
139 return parameterCallback();
141 return variableCallback();
142 }
else if (ParameterMetadataTools::Has(parametersVectorsList, name))
143 return parameterCallback();
144 else if (propertiesContainersList.
Has(name))
145 return propertyCallback();
147 return notFoundCallback();
150 void ForEachIdentifierMatchingSearch(
160 parameterCallback)
const {
161 std::set<gd::String> namesAlreadySeen;
167 if (namesAlreadySeen.count(name) == 0) {
168 namesAlreadySeen.insert(name);
169 objectCallback(name, objectConfiguration);
174 if (namesAlreadySeen.count(name) == 0) {
175 namesAlreadySeen.insert(name);
176 variableCallback(name, variable);
179 gd::ParameterMetadataTools::ForEachParameterMatchingSearch(
180 parametersVectorsList,
183 if (namesAlreadySeen.count(parameter.
GetName()) == 0) {
184 namesAlreadySeen.insert(parameter.GetName());
185 parameterCallback(parameter);
190 if (namesAlreadySeen.count(property.
GetName()) == 0) {
191 namesAlreadySeen.insert(property.GetName());
192 propertyCallback(property);
198 return objectsContainersList;
202 return variablesContainersList;
210 return variablesContainersList;
219 return legacyGlobalVariables;
228 return legacySceneVariables;
232 return propertiesContainersList;
235 const std::vector<const ParameterMetadataContainer *> &GetParametersVectorsList()
const {
236 return parametersVectorsList;
242 : legacyGlobalVariables(nullptr), legacySceneVariables(nullptr){};
250 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:31
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:39
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:50
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:209
const gd::VariablesContainer * GetLegacyGlobalVariables() const
Return the global variables of the current scene or the current extension. It allows legacy "globalva...
Definition: ProjectScopedContainers.h:218
ProjectScopedContainers()
Definition: ProjectScopedContainers.h:241
const gd::VariablesContainer * GetLegacySceneVariables() const
Return the scene variables of the current scene or the current extension. It allows legacy "scenevar"...
Definition: ProjectScopedContainers.h:227
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:29
const VariablesContainer & GetVariablesContainerFromVariableOrPropertyOrParameterName(const gd::String &variableName) const
Definition: VariablesContainersList.cpp:150
bool Has(const gd::String &name) const
Return true if the specified variable is in one of the containers.
Definition: VariablesContainersList.cpp:131
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:217
Definition: CommonTools.h:24