ParamConstraint.h
Go to the documentation of this file.
#pragma once
#include "DataType.h"
#include <string>
#include <vector>
namespace Hazelnp
{
struct ParamConstraint
{
public:
ParamConstraint() = default;
static ParamConstraint Require(const std::string& key, const std::vector<std::string>& defaultValue = {}, bool required = true)
{
ParamConstraint pc;
pc.key = key;
pc.defaultValue = defaultValue;
pc.required = required;
return pc;
}
static ParamConstraint TypeSafety(const std::string& key, DATA_TYPE wantedType, bool constrainType = true)
{
ParamConstraint pc;
pc.key = key;
pc.constrainType = constrainType;
pc.wantedType = wantedType;
return pc;
}
ParamConstraint(const std::string& key, bool constrainType, DATA_TYPE wantedType, const std::vector<std::string>& defaultValue, bool required)
:
key{ key },
constrainType{ constrainType },
wantedType{ wantedType },
defaultValue{ defaultValue },
required{ required }
{
return;
}
std::string key;
bool constrainType = false;
DATA_TYPE wantedType = DATA_TYPE::VOID;
std::vector<std::string> defaultValue;
bool required = false;
};
}
Hazelnp
Definition: DataType.h:3
DataType.h
Hazelnp::DATA_TYPE::VOID
@ VOID
Hazelnp::ParamConstraint::wantedType
DATA_TYPE wantedType
Constrain the parameter to this value. Requires constrainType to be set to true.
Definition: ParamConstraint.h:57
Hazelnp::ParamConstraint
Definition: ParamConstraint.h:8
Hazelnp::ParamConstraint::constrainType
bool constrainType
Should this parameter be forced to be of a certain type? Remember to set constrainTo to the wanted ...
Definition: ParamConstraint.h:54
Hazelnp::ParamConstraint::ParamConstraint
ParamConstraint()=default
Empty constructor.
Hazelnp::ParamConstraint::key
std::string key
The key of the parameter to constrain.
Definition: ParamConstraint.h:50
Hazelnp::ParamConstraint::required
bool required
If set to true, and no default value set, an error will be produced if this parameter is not supplied...
Definition: ParamConstraint.h:66
Hazelnp::ParamConstraint::Require
static ParamConstraint Require(const std::string &key, const std::vector< std::string > &defaultValue={}, bool required=true)
Constructs a require constraint.
Definition: ParamConstraint.h:16
Hazelnp::ParamConstraint::ParamConstraint
ParamConstraint(const std::string &key, bool constrainType, DATA_TYPE wantedType, const std::vector< std::string > &defaultValue, bool required)
Whole constructor.
Definition: ParamConstraint.h:38
Hazelnp::ParamConstraint::TypeSafety
static ParamConstraint TypeSafety(const std::string &key, DATA_TYPE wantedType, bool constrainType=true)
Constructs a type-safety constraint.
Definition: ParamConstraint.h:27
Hazelnp::DATA_TYPE
DATA_TYPE
The different data types a paramater can be.
Definition: DataType.h:7
Hazelnp::ParamConstraint::defaultValue
std::vector< std::string > defaultValue
The default value for this parameter.
Definition: ParamConstraint.h:62