7 template <
typename T,
typename =
void>
11 SPH_ASSERT(mult == 1._f,
"Units not implemented for entries other than float or vector");
16 SPH_ASSERT(mult == 1._f,
"Units not implemented for entries other than float or vector");
22 class UnitAdapter<T,
std::enable_if_t<std::is_same<T, Float>::value || std::is_same<T, Vector>::value>> {
36 entries.
insert(key, std::move(entry));
41 template <
typename TValue,
typename =
void>
54 ref = adapter.
set(value.
get<TValue>(), mult);
59 return adapter.
get(ref, mult);
76 virtual std::string
getName()
const override {
81 template <
typename TValue>
106 virtual std::string
getName()
const override {
113 template <
typename TValue>
115 const std::string& key,
117 auto entry = makeAuto<Detail::ValueEntry<TValue>>(value, name);
119 entries.insert(key, std::move(entry));
126 template <
typename TEnum>
130 std::string scriptTooltip;
133 scriptTooltip =
"Script name: " + key.
value() +
" (" + typeName +
")";
138 std::string tooltip = desc.
value();
140 tooltip +=
"\n\n" + scriptTooltip;
144 return scriptTooltip;
148 template <
typename TValue,
typename TEnum,
typename TEnabler =
void>
165 settings.
set(
id, adapter.
set(value.
get<TValue>(), mult));
170 return adapter.
get(settings.template get<TValue>(
id), mult);
174 return Type(getTypeIndex<TValue, bool, int, Float, Vector, Interval, std::string, Path, EnumWrapper>);
177 virtual std::string
getName()
const override {
183 template <
typename TValue,
typename TEnum>
203 return settings.template get<EnumWrapper>(
id);
210 virtual std::string
getName()
const override {
216 template <
typename TEnum>
236 return Path(settings.template get<std::string>(
id));
243 virtual std::string
getName()
const override {
251 template <
typename TValue,
typename TEnum>
257 throw InvalidSetup(
"No settings entry with id " + std::to_string(
int(
id)));
259 auto entry = makeAuto<Detail::SettingsEntry<TValue, TEnum>>(settings, id, name);
261 entries.insert(key.
value(), std::move(entry));
266 template <
typename TEnum,
typename>
270 throw InvalidSetup(
"No entry with ID " + std::to_string(
int(
id)));
#define SPH_ASSERT(x,...)
double Float
Precision used withing the code. Use Float instead of float or double where precision is important.
#define INLINE
Macros for conditional compilation based on selected compiler.
#define NAMESPACE_SPH_END
constexpr int getTypeIndex
Object providing connection between component parameters and values exposed to the user.
Wrapper of pointer that deletes the resource from destructor.
virtual std::string getName() const override
Returns a descriptive name of the entry.
virtual Value get() const override
Returns the currently stored value.
SettingsEntry(Settings< TEnum > &settings, const TEnum id, const std::string &name)
virtual Type getType() const override
Returns the type of this entry.
virtual void setImpl(const Value &value) override
virtual void setImpl(const Value &value) override
SettingsEntry(Settings< TEnum > &settings, const TEnum id, const std::string &name)
virtual std::string getName() const override
Returns a descriptive name of the entry.
virtual Value get() const override
Returns the currently stored value.
virtual Type getType() const override
Returns the type of this entry.
virtual std::string getName() const override
Returns a descriptive name of the entry.
virtual Value get() const override
Returns the currently stored value.
SettingsEntry(Settings< TEnum > &settings, const TEnum id, const std::string &name)
virtual void setImpl(const Value &value) override
virtual Type getType() const override
Returns the type of this entry.
INLINE T set(const T &input, const Float mult) const
INLINE T get(const T &input, const Float mult) const
INLINE const T & set(const T &input, const Float mult) const
INLINE const T & get(const T &input, const Float mult) const
virtual Value get() const override
Returns the currently stored value.
virtual Type getType() const override
Returns the type of this entry.
virtual void setImpl(const Value &value) override
virtual std::string getName() const override
Returns a descriptive name of the entry.
ValueEntry(TValue &ref, const std::string &name)
virtual void setImpl(const Value &value) override
virtual std::string getName() const override
Returns a descriptive name of the entry.
virtual Value get() const override
Returns the currently stored value.
virtual Type getType() const override
Returns the type of this entry.
ValueEntry(TValue &ref, const std::string &name)
Helper object, allowing to add units, tooltips and additional properties into the entry created with ...
Object representing a 1D interval of real numbers.
Thrown when components of the run are mutually incompatible.
INLINE Type & value()
Returns the reference to the stored value.
Object representing a path on a filesystem.
std::string native() const
Returns the native version of the path.
Generic object containing various settings and parameters of the run.
static Optional< std::string > getEntryDesc(const TEnum idx)
Returns a description of the entry with given index.
static std::string typeToString(const int type)
Returns the string name for given type index.
static Optional< std::string > getEntryName(const TEnum idx)
Returns the human-readable name of the entry with given index.
Settings & set(const TEnum idx, TValue &&value, std::enable_if_t<!std::is_enum< std::decay_t< TValue >>::value, int >=0)
Saves a value into the settings.
static Optional< int > getEntryType(const TEnum idx)
Returns the type of the entry with given index.
INLINE TValue & insert(const TKey &key, const TValue &value)
Adds a new element into the map or sets new value of element with the same key.
Variant, an implementation of type-safe union, similar to std::variant or boost::variant.
INLINE T & get()
Returns the stored value.
void addEntry(const std::string &key, AutoPtr< IVirtualEntry > &&entry)
Manually adds a new entry into the settings.
EntryControl & connect(const std::string &name, const std::string &key, TValue &value)
Connects to given reference.
void set(const std::string &key, const IVirtualEntry::Value &value)
Modifies an existing entry in the settings.
std::string makeTooltip(const TEnum id)
Overload of std::swap for Sph::Array.