8#include "../core/core-data.hpp"
9#include "helics_cxx_export.h"
51template<
typename BaseType, Identifiers ID, BaseType inval
idValue>
58 using UnderlyingType = BaseType;
62 constexpr explicit IdentifierId(BaseType val)
noexcept: ivalue(val) {}
75 BaseType
value() const noexcept {
return ivalue; };
83 bool isValid() const noexcept {
return (ivalue !=
invalidValue); }
90template<
typename BaseType, helics::Identifiers ID, BaseType inval
idValue>
91struct hash<
helics::IdentifierId<BaseType, ID, invalidValue>> {
98 return std::hash<BaseType>{}(key.value());
104using PublicationId = IdentifierId<IdentifierType, Identifiers::PUBLICATION, invalid_id_value>;
105using InputId = IdentifierId<IdentifierType, Identifiers::INPUT, invalid_id_value>;
107using QueryId = IdentifierId<IdentifierType, Identifiers::QUERY, invalid_id_value>;
114 std::numeric_limits<double>::quiet_NaN();
125 return ((std::isnan(
value)) && (std::isnan(np.
value))) ?
151 return typeid(X).name();
153namespace typestrings {
154 constexpr auto svecstr =
"string_vector";
155 constexpr auto dvecstr =
"double_vector";
156 constexpr auto cvecstr =
"complex_vector";
158 constexpr auto doublestr =
"double";
159 constexpr auto floatstr =
"float";
160 constexpr auto boolstr =
"bool";
162 constexpr auto charstr =
"char";
163 constexpr auto ucharstr =
"uchar";
164 constexpr auto i32str =
"int32";
165 constexpr auto ui32str =
"uint32";
166 constexpr auto i64str =
"int64";
167 constexpr auto ui64str =
"uint64";
169 constexpr auto cfloatstr =
"complex_f";
170 constexpr auto cdoublestr =
"complex";
171 constexpr auto npstr =
"named_point";
172 constexpr auto strstr =
"string";
176inline constexpr const char* typeNameString<std::vector<std::string>>()
178 return typestrings::svecstr;
181inline constexpr const char* typeNameString<std::vector<double>>()
183 return typestrings::dvecstr;
187inline constexpr const char* typeNameString<std::vector<std::complex<double>>>()
189 return typestrings::cvecstr;
196 return typestrings::doublestr;
203 return typestrings::floatstr;
210 return typestrings::boolstr;
217 return typestrings::charstr;
223 return typestrings::ucharstr;
229 return typestrings::i32str;
235 return typestrings::ui32str;
241 return typestrings::i64str;
247 return typestrings::ui64str;
251inline constexpr const char* typeNameString<std::complex<float>>()
253 return typestrings::cfloatstr;
257inline constexpr const char* typeNameString<std::complex<double>>()
259 return typestrings::cdoublestr;
262inline constexpr const char* typeNameString<std::string>()
264 return typestrings::strstr;
268inline constexpr const char* typeNameString<NamedPoint>()
270 return typestrings::npstr;
274 HELICS_UNKNOWN = HELICS_DATA_TYPE_UNKNOWN,
292inline constexpr bool isBytesType(
DataType type)
294 return (type == DataType::HELICS_ANY) || (type == DataType::HELICS_CUSTOM);
323HELICS_CXX_EXPORT std::string
331HELICS_CXX_EXPORT std::complex<double>
helicsGetComplex(std::string_view val);
333HELICS_CXX_EXPORT std::vector<double>
helicsGetVector(std::string_view val);
334HELICS_CXX_EXPORT
void helicsGetVector(std::string_view val, std::vector<double>& data);
341 std::vector<std::complex<double>>& data);
354HELICS_CXX_EXPORT
double vectorNorm(
const std::vector<double>& vec);
356HELICS_CXX_EXPORT
double vectorNorm(
const std::vector<std::complex<double>>& vec);
366HELICS_CXX_EXPORT SmallBuffer typeConvertComplex(
DataType type,
const double* vals,
size_t size);
368 const std::vector<std::complex<double>>& val);
380 return DataType::HELICS_CUSTOM;
384constexpr DataType helicsType<int64_t>()
386 return DataType::HELICS_INT;
390constexpr DataType helicsType<bool>()
392 return DataType::HELICS_BOOL;
396constexpr DataType helicsType<std::string>()
398 return DataType::HELICS_STRING;
402constexpr DataType helicsType<NamedPoint>()
404 return DataType::HELICS_NAMED_POINT;
407constexpr DataType helicsType<double>()
409 return DataType::HELICS_DOUBLE;
413constexpr DataType helicsType<Time>()
415 return DataType::HELICS_TIME;
419constexpr DataType helicsType<std::complex<double>>()
421 return DataType::HELICS_COMPLEX;
425constexpr DataType helicsType<std::vector<double>>()
427 return DataType::HELICS_VECTOR;
431constexpr DataType helicsType<std::vector<std::complex<double>>>()
433 return DataType::HELICS_COMPLEX_VECTOR;
438constexpr bool isConvertableType()
444constexpr bool isConvertableType<float>()
450constexpr bool isConvertableType<long double>()
456constexpr bool isConvertableType<int32_t>()
462constexpr bool isConvertableType<int16_t>()
468constexpr bool isConvertableType<uint16_t>()
474constexpr bool isConvertableType<char>()
480constexpr bool isConvertableType<unsigned char>()
486constexpr bool isConvertableType<uint64_t>()
502constexpr double invalidValue<double>()
508constexpr int64_t invalidValue<int64_t>()
510 return (std::numeric_limits<int64_t>::min)();
514constexpr uint64_t invalidValue<uint64_t>()
516 return (std::numeric_limits<uint64_t>::max)();
520constexpr Time invalidValue<Time>()
522 return Time::minVal();
526inline NamedPoint invalidValue<NamedPoint>()
528 return {std::string(), std::nan(
"0")};
532constexpr std::complex<double> invalidValue<std::complex<double>>()
534 return {invalidValue<double>(), 0.0};
540constexpr int primaryType = 0;
541constexpr int convertibleType = 1;
542constexpr int nonConvertibleType = 2;
549 std::conditional_t<helicsType<remove_cv_ref<X>>() != DataType::HELICS_CUSTOM,
550 std::integral_constant<int, primaryType>,
552 std::integral_constant<int, convertibleType>,
553 std::integral_constant<int, nonConvertibleType>>>;
Definition helicsTypes.hpp:52
BaseType value() const noexcept
Definition helicsTypes.hpp:75
constexpr IdentifierId(const IdentifierId &id) noexcept
Definition helicsTypes.hpp:64
IdentifierId & operator=(BaseType val) noexcept
Definition helicsTypes.hpp:66
bool operator!=(IdentifierId id) const noexcept
Definition helicsTypes.hpp:79
bool operator<(IdentifierId id) const noexcept
Definition helicsTypes.hpp:81
IdentifierId & operator=(const IdentifierId &id)=default
constexpr IdentifierId() noexcept
Definition helicsTypes.hpp:60
static const Identifiers identity
the type of the identifier
Definition helicsTypes.hpp:57
bool operator==(IdentifierId id) const noexcept
Definition helicsTypes.hpp:77
constexpr IdentifierId(BaseType val) noexcept
Definition helicsTypes.hpp:62
Definition helicsTypes.hpp:110
double value
the data value for the named point
Definition helicsTypes.hpp:113
bool operator<(const NamedPoint &np) const
Definition helicsTypes.hpp:133
bool operator==(const NamedPoint &np) const
Definition helicsTypes.hpp:123
bool operator>(const NamedPoint &np) const
Definition helicsTypes.hpp:140
NamedPoint(std::string_view valname, double valval)
Definition helicsTypes.hpp:118
std::string name
the text value for the named point
Definition helicsTypes.hpp:112
@ HELICS_DATA_TYPE_INT
Definition helics_enums.h:74
@ HELICS_DATA_TYPE_DOUBLE
Definition helics_enums.h:72
@ HELICS_DATA_TYPE_STRING
Definition helics_enums.h:70
@ HELICS_DATA_TYPE_TIME
Definition helics_enums.h:86
@ HELICS_DATA_TYPE_COMPLEX_VECTOR
Definition helics_enums.h:80
@ HELICS_DATA_TYPE_RAW
Definition helics_enums.h:90
@ HELICS_DATA_TYPE_NAMED_POINT
Definition helics_enums.h:82
@ HELICS_DATA_TYPE_JSON
Definition helics_enums.h:92
@ HELICS_DATA_TYPE_COMPLEX
Definition helics_enums.h:76
@ HELICS_DATA_TYPE_CHAR
Definition helics_enums.h:88
@ HELICS_DATA_TYPE_ANY
Definition helics_enums.h:97
@ HELICS_DATA_TYPE_MULTI
Definition helics_enums.h:94
@ HELICS_DATA_TYPE_VECTOR
Definition helics_enums.h:78
@ HELICS_DATA_TYPE_BOOLEAN
Definition helics_enums.h:84
the main namespace for the helics co-simulation library User functions will be in the helics namespac...
Definition AsyncFedCallInfo.hpp:14
constexpr DataType helicsType()
Definition helicsTypes.hpp:378
bool helicsBoolValue(std::string_view val)
Definition helicsTypes.cpp:658
DataType
Definition helicsTypes.hpp:273
NamedPoint helicsGetNamedPoint(std::string_view val)
Definition helicsTypes.cpp:417
constexpr const char * typeNameString()
Definition helicsTypes.hpp:148
std::string helicsVectorString(const std::vector< double > &val)
Definition helicsTypes.cpp:373
std::vector< std::complex< double > > helicsGetComplexVector(std::string_view val)
Definition helicsTypes.cpp:410
constexpr double invalidDouble
defined constant for an invalid value as a double
Definition helicsTypes.hpp:499
constexpr IdentifierType invalid_id_value
defining an invalid id value
Definition helicsTypes.hpp:26
std::vector< double > helicsGetVector(std::string_view val)
Definition helicsTypes.cpp:403
const std::string & typeNameStringRef(DataType type)
Definition helicsTypes.cpp:64
std::string_view getCleanedTypeName(std::string_view typeName)
Definition helicsTypes.cpp:274
constexpr const char * typeNameString< std::int32_t >()
Definition helicsTypes.hpp:227
std::int64_t getIntFromString(std::string_view val)
Definition helicsTypes.cpp:492
constexpr const char * typeNameString< float >()
Definition helicsTypes.hpp:201
std::complex< double > helicsGetComplex(std::string_view val)
Definition helicsTypes.cpp:304
SmallBuffer typeConvert(DataType type, double val)
Definition helicsTypes.cpp:745
std::string helicsDoubleString(double val)
Definition helicsTypes.cpp:368
std::remove_cv_t< std::remove_reference_t< T > > remove_cv_ref
Helper template to remove const volatile references.
Definition helicsTypes.hpp:538
constexpr const char * typeNameString< unsigned char >()
Definition helicsTypes.hpp:221
DataType getTypeFromString(std::string_view typeName)
Definition helicsTypes.cpp:248
constexpr const char * typeNameString< char >()
Definition helicsTypes.hpp:215
constexpr const char * typeNameString< std::uint32_t >()
Definition helicsTypes.hpp:233
Identifiers
Definition helicsTypes.hpp:30
constexpr const char * typeNameString< bool >()
Definition helicsTypes.hpp:208
std::string helicsIntString(std::int64_t val)
Definition helicsTypes.cpp:363
std::string helicsComplexVectorString(const std::vector< std::complex< double > > &val)
Definition helicsTypes.cpp:383
constexpr const char * typeNameString< double >()
Definition helicsTypes.hpp:194
double getDoubleFromString(std::string_view val)
Definition helicsTypes.cpp:503
constexpr const char * typeNameString< int64_t >()
Definition helicsTypes.hpp:239
std::string helicsNamedPointString(const NamedPoint &point)
Definition helicsTypes.cpp:388
constexpr const char * typeNameString< std::uint64_t >()
Definition helicsTypes.hpp:245
std::uint32_t IdentifierType
specify the underlying type used in the identifiers
Definition helicsTypes.hpp:22
double vectorNorm(const std::vector< double > &vec)
Definition helicsTypes.cpp:109
std::string helicsComplexString(double real, double imag)
Definition helicsTypes.cpp:131
InterfaceVisibility
Definition helicsTypes.hpp:40
X invalidValue()
Definition helicsTypes.hpp:493
std::conditional_t< helicsType< remove_cv_ref< X > >() !=DataType::HELICS_CUSTOM, std::integral_constant< int, primaryType >, std::conditional_t< isConvertableType< remove_cv_ref< X > >(), std::integral_constant< int, convertibleType >, std::integral_constant< int, nonConvertibleType > > > typeCategory
Definition helicsTypes.hpp:553
TimeRepresentation< count_time< 9 > > Time
Definition helicsTime.hpp:27
std::complex< double > getComplexFromString(std::string_view val)
Definition helicsTypes.cpp:474
std::size_t result_type
the result type of the hash code
Definition helicsTypes.hpp:94
result_type operator()(argument_type const &key) const noexcept
Definition helicsTypes.hpp:96