GDevelop Core
Core library for developing platforms and tools compatible with GDevelop.
DependencyMetadata.h
1 /*
2  * GDevelop Core
3  * Copyright 2008-2016 Florian Rival ([email protected]). All rights
4  * reserved. This project is released under the MIT License.
5  */
6 #ifndef DEPENDENCYMETADATA_H
7 #define DEPENDENCYMETADATA_H
8 #include <map>
9 #include <set>
10 
11 #include "GDCore/Project/PropertyDescriptor.h"
12 #include "GDCore/String.h"
13 #include "GDCore/Tools/Log.h"
14 
15 namespace gd {
20 class GD_CORE_API DependencyMetadata {
21  public:
28  DependencyMetadata() : onlyIfSomeExtraSettingsNonEmpty(false){};
29 
34  name = name_;
35  return *this;
36  };
37 
50  DependencyMetadata& SetExportName(const gd::String& exportName_) {
51  exportName = exportName_;
52  return *this;
53  };
54 
60  version = version_;
61  return *this;
62  };
63 
69  DependencyMetadata& SetDependencyType(const gd::String& dependencyType_) {
70  dependencyType = dependencyType_;
71  if (dependencyType != "npm" && dependencyType != "cordova") {
72  gd::LogWarning("Invalid dependency type: " + dependencyType);
73  }
74  return *this;
75  };
76 
81  const gd::String& settingName,
82  const gd::PropertyDescriptor& settingValue) {
83  extraData[settingName] = settingValue;
84  return *this;
85  };
86 
92  onlyIfSomeExtraSettingsNonEmpty = true;
93  return *this;
94  };
95 
101  return onlyIfSomeExtraSettingsNonEmpty;
102  };
103 
109  const gd::String& otherDependency) {
110  onlyIfOtherDependencyIsExported = otherDependency;
111  return *this;
112  };
113 
119  return onlyIfOtherDependencyIsExported;
120  };
121 
122  const gd::String& GetName() const { return name; };
123  const gd::String& GetExportName() const { return exportName; };
124  const gd::String& GetVersion() const { return version; };
125  const gd::String& GetDependencyType() const {
126  if (dependencyType == "")
127  gd::LogWarning("Dependency has no type, it won't be exported.");
128  return dependencyType;
129  };
130 
131  const std::map<gd::String, gd::PropertyDescriptor>& GetAllExtraSettings()
132  const {
133  return extraData;
134  }
135 
136  void CopyFrom(const DependencyMetadata& dependencyMetadata) {
137  *this = dependencyMetadata;
138  }
139 
140  private:
141  gd::String name;
142  gd::String exportName;
144  gd::String version;
145  gd::String dependencyType;
146  std::map<gd::String, gd::PropertyDescriptor>
147  extraData;
149  bool onlyIfSomeExtraSettingsNonEmpty;
152  gd::String onlyIfOtherDependencyIsExported;
153 };
154 } // namespace gd
155 #endif // DEPENDENCYMETADATA_H
Contains information about a dependency (library, npm/cordova package, or other according to the expo...
Definition: DependencyMetadata.h:20
bool IsOnlyIfSomeExtraSettingsNonEmpty() const
Check if at least one of the extra settings must be set for the dependency to be included in the expo...
Definition: DependencyMetadata.h:100
DependencyMetadata & SetExtraSetting(const gd::String &settingName, const gd::PropertyDescriptor &settingValue)
Sets a dependency type specific setting.
Definition: DependencyMetadata.h:80
DependencyMetadata & SetVersion(const gd::String &version_)
Set the version of the dependency to install. Use an empty string to use the latest version.
Definition: DependencyMetadata.h:59
DependencyMetadata()
Definition: DependencyMetadata.h:28
const gd::String & GetOtherDependencyThatMustBeExported() const
Get the name of another dependency that must be exported to have this one also exported.
Definition: DependencyMetadata.h:118
DependencyMetadata & OnlyIfOtherDependencyIsExported(const gd::String &otherDependency)
Mark the dependency to be included in the export only if one other dependency is included in the expo...
Definition: DependencyMetadata.h:108
DependencyMetadata & SetName(const gd::String &name_)
Sets the name shown to users.
Definition: DependencyMetadata.h:33
DependencyMetadata & OnlyIfSomeExtraSettingsNonEmpty()
Mark the dependency to be included in the export only if at least one of the extra settings is set.
Definition: DependencyMetadata.h:91
DependencyMetadata & SetDependencyType(const gd::String &dependencyType_)
Sets the type of dependency (what will be used to install it)
Definition: DependencyMetadata.h:69
Used to describe a property shown in a property grid.
Definition: PropertyDescriptor.h:24
String represents an UTF8 encoded string.
Definition: String.h:31
Definition: CommonTools.h:24
void GD_CORE_API LogWarning(const gd::String &msg)
Standard function that should be used when emitting a warning to be displayed to the user.
Definition: Log.cpp:11