GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
PropertiesContainersList.h
1 #pragma once
2 #include <functional>
3 #include <vector>
4 
5 #include "PropertiesContainer.h"
6 
7 namespace gd {
8 class String;
9 class Project;
10 class Layout;
11 class NamedPropertyDescriptor;
12 } // namespace gd
13 
14 namespace gd {
15 
26 class GD_CORE_API PropertiesContainersList {
27  public:
28  virtual ~PropertiesContainersList(){};
29 
30  static PropertiesContainersList MakeNewPropertiesContainersListFor(
31  const gd::PropertiesContainer& propertiesContainer);
32  static PropertiesContainersList MakeNewEmptyPropertiesContainersList();
33 
38  void Add(const gd::PropertiesContainer& propertiesContainer) {
39  propertiesContainers.push_back(&propertiesContainer);
40  };
41 
45  bool Has(const gd::String& name) const;
46 
51  std::pair<std::reference_wrapper<const gd::PropertiesContainer>,
52  std::reference_wrapper<const NamedPropertyDescriptor>>
53  Get(const gd::String& name) const;
54 
58  bool HasPropertiesContainer(const gd::PropertiesContainer& propertiesContainer) const;
59 
65  if (propertiesContainers.empty()) return nullptr;
66  return propertiesContainers.back();
67  }
68 
72  void ForEachPropertyMatchingSearch(const gd::String& search, std::function<void(const gd::NamedPropertyDescriptor& property)> fn) const;
73 
77 
78  private:
79  std::vector<const gd::PropertiesContainer*> propertiesContainers;
80  static NamedPropertyDescriptor badNamedPropertyDescriptor;
81  static PropertiesContainer badPropertiesContainer;
82 };
83 
84 } // namespace gd
Used to describe a property shown in a property grid.
Definition: NamedPropertyDescriptor.h:21
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
PropertiesContainersList()
Definition: PropertiesContainersList.h:76
const PropertiesContainer * GetBottomMostPropertiesContainer() const
Definition: PropertiesContainersList.h:64
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
String represents an UTF8 encoded string.
Definition: String.h:33
Definition: CommonTools.h:24