4 #include "GDCore/Extensions/Metadata/ParameterMetadataTools.h"
5 #include "ObjectsContainersList.h"
6 #include "PropertiesContainersList.h"
7 #include "VariablesContainersList.h"
11 class ObjectsContainer;
12 class ObjectsContainersList;
13 class VariablesContainersList;
14 class PropertiesContainersList;
15 class NamedPropertyDescriptor;
36 : objectsContainersList(objectsContainersList_),
37 variablesContainersList(variablesContainersList_),
38 propertiesContainersList(propertiesContainersList_){};
42 MakeNewProjectScopedContainersForProjectAndLayout(
const gd::Project &project,
45 ObjectsContainersList::MakeNewObjectsContainersListForProjectAndLayout(
48 MakeNewVariablesContainersListForProjectAndLayout(project, layout),
49 PropertiesContainersList::MakeNewEmptyPropertiesContainersList());
51 return projectScopedContainers;
58 ObjectsContainersList::MakeNewObjectsContainersListForContainers(
59 globalObjectsContainers, objectsContainers),
60 VariablesContainersList::MakeNewEmptyVariablesContainersList(),
61 PropertiesContainersList::MakeNewEmptyPropertiesContainersList());
63 return projectScopedContainers;
68 propertiesContainersList.
Add(container);
74 const std::vector<gd::ParameterMetadata> ¶meters) {
75 parametersVectorsList.push_back(¶meters);
80 template <
class ReturnType>
81 ReturnType MatchIdentifierWithName(
83 std::function<ReturnType()> objectCallback,
84 std::function<ReturnType()> variableCallback,
85 std::function<ReturnType()> propertyCallback,
86 std::function<ReturnType()> parameterCallback,
87 std::function<ReturnType()> notFoundCallback)
const {
89 return objectCallback();
90 else if (variablesContainersList.
Has(name))
91 return variableCallback();
92 else if (ParameterMetadataTools::Has(parametersVectorsList, name))
93 return parameterCallback();
94 else if (propertiesContainersList.
Has(name))
95 return propertyCallback();
97 return notFoundCallback();
100 void ForEachIdentifierMatchingSearch(
110 parameterCallback)
const {
111 std::set<gd::String> namesAlreadySeen;
117 if (namesAlreadySeen.count(name) == 0) {
118 namesAlreadySeen.insert(name);
119 objectCallback(name, objectConfiguration);
124 if (namesAlreadySeen.count(name) == 0) {
125 namesAlreadySeen.insert(name);
126 variableCallback(name, variable);
129 gd::ParameterMetadataTools::ForEachParameterMatchingSearch(
130 parametersVectorsList,
133 if (namesAlreadySeen.count(parameter.
GetName()) == 0) {
134 namesAlreadySeen.insert(parameter.GetName());
135 parameterCallback(parameter);
140 if (namesAlreadySeen.count(property.
GetName()) == 0) {
141 namesAlreadySeen.insert(property.GetName());
142 propertyCallback(property);
148 return objectsContainersList;
152 return variablesContainersList;
156 return propertiesContainersList;
159 const std::vector<const std::vector<gd::ParameterMetadata> *> &GetParametersVectorsList()
const {
160 return parametersVectorsList;
171 std::vector<const std::vector<gd::ParameterMetadata> *> parametersVectorsList;
Represent a layout ( also called a scene ) of a project.
Definition: Layout.h:39
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:36
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:301
bool HasObjectOrGroupNamed(const gd::String &name) const
Check if the specified object or group exists.
Definition: ObjectsContainersList.cpp:34
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:30
ProjectScopedContainers()
Definition: ProjectScopedContainers.h:165
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:31
Defines a variable which can be used by an object, a layout or a project.
Definition: Variable.h:29
A list of variables containers, useful for accessing variables in a scoped way.
Definition: VariablesContainersList.h:25
bool Has(const gd::String &name) const
Return true if the specified variable is in one of the containers.
Definition: VariablesContainersList.cpp:28
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:55
Definition: CommonTools.h:24