 |
helics
3.0.1
|
Go to the documentation of this file.
8 #include "../core/core-data.hpp"
9 #include "helics_cxx_export.h"
14 #include <string_view>
50 template<
typename BaseType, Identifiers ID, BaseType inval
idValue>
57 using UnderlyingType = BaseType;
61 constexpr
explicit IdentifierId(BaseType val) noexcept: ivalue(val) {}
74 BaseType
value() const noexcept {
return ivalue; };
82 bool isValid() const noexcept {
return (ivalue !=
invalidValue); }
89 template<
typename BaseType, helics::Identifiers ID, BaseType inval
idValue>
90 struct hash<
helics::IdentifierId<BaseType, ID, invalidValue>> {
97 return std::hash<BaseType>{}(key.value());
103 using PublicationId = IdentifierId<IdentifierType, Identifiers::PUBLICATION, invalid_id_value>;
104 using InputId = IdentifierId<IdentifierType, Identifiers::INPUT, invalid_id_value>;
106 using QueryId = IdentifierId<IdentifierType, Identifiers::QUERY, invalid_id_value>;
113 std::numeric_limits<double>::quiet_NaN();
124 return ((std::isnan(
value)) && (std::isnan(np.
value))) ?
150 return typeid(X).name();
152 namespace typestrings {
153 constexpr
auto svecstr =
"string_vector";
154 constexpr
auto dvecstr =
"double_vector";
155 constexpr
auto cvecstr =
"complex_vector";
157 constexpr
auto doublestr =
"double";
158 constexpr
auto floatstr =
"float";
159 constexpr
auto boolstr =
"bool";
161 constexpr
auto charstr =
"char";
162 constexpr
auto ucharstr =
"uchar";
163 constexpr
auto i32str =
"int32";
164 constexpr
auto ui32str =
"uint32";
165 constexpr
auto i64str =
"int64";
166 constexpr
auto ui64str =
"uint64";
168 constexpr
auto cfloatstr =
"complex_f";
169 constexpr
auto cdoublestr =
"complex";
170 constexpr
auto npstr =
"named_point";
171 constexpr
auto strstr =
"string";
175 inline constexpr
const char* typeNameString<std::vector<std::string>>()
177 return typestrings::svecstr;
180 inline constexpr
const char* typeNameString<std::vector<double>>()
182 return typestrings::dvecstr;
186 inline constexpr
const char* typeNameString<std::vector<std::complex<double>>>()
188 return typestrings::cvecstr;
195 return typestrings::doublestr;
202 return typestrings::floatstr;
209 return typestrings::boolstr;
216 return typestrings::charstr;
222 return typestrings::ucharstr;
226 inline constexpr
const char* typeNameString<std::int32_t>()
228 return typestrings::i32str;
232 inline constexpr
const char* typeNameString<std::uint32_t>()
234 return typestrings::ui32str;
240 return typestrings::i64str;
244 inline constexpr
const char* typeNameString<std::uint64_t>()
246 return typestrings::ui64str;
250 inline constexpr
const char* typeNameString<std::complex<float>>()
252 return typestrings::cfloatstr;
256 inline constexpr
const char* typeNameString<std::complex<double>>()
258 return typestrings::cdoublestr;
261 inline constexpr
const char* typeNameString<std::string>()
263 return typestrings::strstr;
267 inline constexpr
const char* typeNameString<NamedPoint>()
269 return typestrings::npstr;
290 inline constexpr
bool isBytesType(
DataType type)
292 return (type == DataType::HELICS_ANY) || (type == DataType::HELICS_CUSTOM);
321 HELICS_CXX_EXPORT std::string
329 HELICS_CXX_EXPORT std::complex<double>
helicsGetComplex(std::string_view val);
331 HELICS_CXX_EXPORT std::vector<double>
helicsGetVector(std::string_view val);
332 HELICS_CXX_EXPORT
void helicsGetVector(std::string_view val, std::vector<double>& data);
339 std::vector<std::complex<double>>& data);
352 HELICS_CXX_EXPORT
double vectorNorm(
const std::vector<double>& vec);
354 HELICS_CXX_EXPORT
double vectorNorm(
const std::vector<std::complex<double>>& vec);
364 HELICS_CXX_EXPORT SmallBuffer typeConvertComplex(
DataType type,
const double* vals,
size_t size);
366 const std::vector<std::complex<double>>& val);
369 HELICS_CXX_EXPORT SmallBuffer
typeConvert(
DataType type, std::string_view str,
double val);
378 return DataType::HELICS_CUSTOM;
382 constexpr
DataType helicsType<int64_t>()
384 return DataType::HELICS_INT;
388 constexpr
DataType helicsType<bool>()
390 return DataType::HELICS_BOOL;
394 constexpr
DataType helicsType<std::string>()
396 return DataType::HELICS_STRING;
400 constexpr
DataType helicsType<NamedPoint>()
402 return DataType::HELICS_NAMED_POINT;
405 constexpr
DataType helicsType<double>()
407 return DataType::HELICS_DOUBLE;
411 constexpr
DataType helicsType<Time>()
413 return DataType::HELICS_TIME;
417 constexpr
DataType helicsType<std::complex<double>>()
419 return DataType::HELICS_COMPLEX;
423 constexpr
DataType helicsType<std::vector<double>>()
425 return DataType::HELICS_VECTOR;
429 constexpr
DataType helicsType<std::vector<std::complex<double>>>()
431 return DataType::HELICS_COMPLEX_VECTOR;
436 constexpr
bool isConvertableType()
442 constexpr
bool isConvertableType<float>()
448 constexpr
bool isConvertableType<long double>()
454 constexpr
bool isConvertableType<int32_t>()
460 constexpr
bool isConvertableType<int16_t>()
466 constexpr
bool isConvertableType<uint16_t>()
472 constexpr
bool isConvertableType<char>()
478 constexpr
bool isConvertableType<unsigned char>()
484 constexpr
bool isConvertableType<uint64_t>()
500 constexpr
double invalidValue<double>()
506 constexpr int64_t invalidValue<int64_t>()
508 return (std::numeric_limits<int64_t>::min)();
512 constexpr uint64_t invalidValue<uint64_t>()
514 return (std::numeric_limits<uint64_t>::max)();
518 constexpr
Time invalidValue<Time>()
520 return Time::minVal();
524 inline NamedPoint invalidValue<NamedPoint>()
526 return {std::string(), std::nan(
"0")};
530 constexpr std::complex<double> invalidValue<std::complex<double>>()
532 return {invalidValue<double>(), 0.0};
538 constexpr
int primaryType = 0;
539 constexpr
int convertibleType = 1;
540 constexpr
int nonConvertibleType = 2;
547 std::conditional_t<helicsType<remove_cv_ref<X>>() != DataType::HELICS_CUSTOM,
548 std::integral_constant<int, primaryType>,
550 std::integral_constant<int, convertibleType>,
551 std::integral_constant<int, nonConvertibleType>>>;
constexpr Time timeZero
Definition: helicsTime.hpp:31
std::string helicsIntString(std::int64_t val)
Definition: helicsTypes.cpp:334
constexpr IdentifierId(const IdentifierId &id) noexcept
Definition: helicsTypes.hpp:63
std::string name
the text value for the named point
Definition: helicsTypes.hpp:111
constexpr DataType helicsType()
Definition: helicsTypes.hpp:376
InterfaceVisibility
Definition: helicsTypes.hpp:39
Definition: helicsTypes.hpp:109
Definition: helicsTypes.hpp:51
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:551
@ HELICS_DATA_TYPE_JSON
Definition: helics_enums.h:86
Definition: SmallBuffer.hpp:24
BaseType value() const noexcept
Definition: helicsTypes.hpp:74
@ HELICS_DATA_TYPE_ANY
Definition: helics_enums.h:90
@ HELICS_DATA_TYPE_COMPLEX
Definition: helics_enums.h:72
std::string helicsComplexVectorString(const std::vector< std::complex< double >> &val)
Definition: helicsTypes.cpp:354
constexpr const char * typeNameString< unsigned char >()
Definition: helicsTypes.hpp:220
X invalidValue()
Definition: helicsTypes.hpp:491
Definition: ValueConverter.hpp:98
std::string_view getCleanedTypeName(std::string_view typeName)
Definition: helicsTypes.cpp:245
constexpr const char * typeNameString()
Definition: helicsTypes.hpp:147
std::vector< std::complex< double > > helicsGetComplexVector(std::string_view val)
Definition: helicsTypes.cpp:381
double value
the data value for the named point
Definition: helicsTypes.hpp:112
TimeRepresentation< count_time< 9 > > Time
Definition: helicsTime.hpp:27
Identifiers
Definition: helicsTypes.hpp:30
constexpr const char * typeNameString< char >()
Definition: helicsTypes.hpp:214
constexpr IdentifierId() noexcept
Definition: helicsTypes.hpp:59
@ HELICS_UNKNOWN
unknown state
Definition: CoreTypes.hpp:29
DataType getTypeFromString(std::string_view typeName)
Definition: helicsTypes.cpp:219
@ HELICS_DATA_TYPE_STRING
Definition: helics_enums.h:66
@ HELICS_DATA_TYPE_NAMED_POINT
Definition: helics_enums.h:78
constexpr const char * typeNameString< bool >()
Definition: helicsTypes.hpp:207
std::size_t result_type
the result type of the hash code
Definition: helicsTypes.hpp:93
double vectorNorm(const std::vector< double > &vec)
Definition: helicsTypes.cpp:85
DataType
Definition: helicsTypes.hpp:272
bool operator==(const NamedPoint &np) const
Definition: helicsTypes.hpp:122
@ HELICS_DATA_TYPE_BOOLEAN
Definition: helics_enums.h:80
@ HELICS_DATA_TYPE_RAW
Definition: helics_enums.h:84
std::string helicsDoubleString(double val)
Definition: helicsTypes.cpp:339
bool operator<(IdentifierId id) const noexcept
Definition: helicsTypes.hpp:80
static const Identifiers identity
the type of the identifier
Definition: helicsTypes.hpp:56
bool operator!=(IdentifierId id) const noexcept
Definition: helicsTypes.hpp:78
@ HELICS_DATA_TYPE_TIME
Definition: helics_enums.h:82
bool helicsBoolValue(std::string_view val)
Definition: helicsTypes.cpp:626
std::uint32_t IdentifierType
specify the underlying type used in the identifiers
Definition: helicsTypes.hpp:22
constexpr double invalidDouble
defined constant for an invalid value as a double
Definition: helicsTypes.hpp:497
@ HELICS_DATA_TYPE_VECTOR
Definition: helics_enums.h:74
std::string helicsVectorString(const std::vector< double > &val)
Definition: helicsTypes.cpp:344
NamedPoint helicsGetNamedPoint(std::string_view val)
Definition: helicsTypes.cpp:388
constexpr IdentifierId(BaseType val) noexcept
Definition: helicsTypes.hpp:61
bool operator==(IdentifierId id) const noexcept
Definition: helicsTypes.hpp:76
constexpr const char * typeNameString< int64_t >()
Definition: helicsTypes.hpp:238
@ HELICS_DATA_TYPE_INT
Definition: helics_enums.h:70
result_type operator()(argument_type const &key) const noexcept
Definition: helicsTypes.hpp:95
bool operator>(const NamedPoint &np) const
Definition: helicsTypes.hpp:139
std::remove_cv_t< std::remove_reference_t< T > > remove_cv_ref
Helper template to remove const volatile references.
Definition: helicsTypes.hpp:536
@ HELICS_DATA_TYPE_MULTI
Definition: helics_enums.h:88
std::string helicsComplexString(double real, double imag)
Definition: helicsTypes.cpp:103
@ HELICS_DATA_TYPE_DOUBLE
Definition: helics_enums.h:68
IdentifierId & operator=(BaseType val) noexcept
Definition: helicsTypes.hpp:65
constexpr const char * typeNameString< float >()
Definition: helicsTypes.hpp:200
std::int64_t getIntFromString(std::string_view val)
Definition: helicsTypes.cpp:462
SmallBuffer typeConvert(DataType type, double val)
Definition: helicsTypes.cpp:712
the main namespace for the helics co-simulation library User functions will be in the helics namespac...
Definition: AsyncFedCallInfo.hpp:14
NamedPoint(std::string_view valname, double valval)
Definition: helicsTypes.hpp:117
std::complex< double > getComplexFromString(std::string_view val)
Definition: helicsTypes.cpp:444
const std::string & typeNameStringRef(DataType type)
Definition: helicsTypes.cpp:46
std::vector< double > helicsGetVector(std::string_view val)
Definition: helicsTypes.cpp:374
constexpr const char * typeNameString< double >()
Definition: helicsTypes.hpp:193
constexpr IdentifierType invalid_id_value
defining an invalid id value
Definition: helicsTypes.hpp:26
@ HELICS_DATA_TYPE_COMPLEX_VECTOR
Definition: helics_enums.h:76
std::string helicsNamedPointString(const NamedPoint &point)
Definition: helicsTypes.cpp:359
bool operator<(const NamedPoint &np) const
Definition: helicsTypes.hpp:132
double getDoubleFromString(std::string_view val)
Definition: helicsTypes.cpp:473
std::complex< double > helicsGetComplex(std::string_view val)
Definition: helicsTypes.cpp:275