63 static constexpr std::chrono::milliseconds
DefaultTimeout = std::chrono::milliseconds(10);
114 using namespace std::chrono_literals;
118 constexpr int NumTries = 2;
120 if (
OwnerID != std::this_thread::get_id())
126 bool Success =
false;
127 auto TimeoutPerTry = Timeout / NumTries;
128 for (
auto i = NumTries; i > 0 && !Success; --i)
129 Success =
LockMutex.try_lock_for(TimeoutPerTry);
135 OwnerID = std::this_thread::get_id();
169 template <
typename T>
209 Other.LockableObject =
nullptr;
221 template <
typename U>
224 if (!Other.LockableObject)
232 Other.LockableObject =
nullptr;
280 bool Wait(
const std::chrono::milliseconds Timeout = std::chrono::milliseconds(0));
297 template <
typename T,
typename... ListTs>
303 template <
typename T,
typename... ListTs>
312 template <
typename CallableT>
318 template <
typename ReturnT,
typename ObjectT,
typename... ArgumentTs>
329 template <
typename ReturnT,
typename ObjectT,
typename... ArgumentTs>
340 template <
typename ReturnT,
typename ObjectT,
typename... ArgumentTs>
351 template <
typename ReturnT,
typename ObjectT,
typename... ArgumentTs>
362 template <
typename CallableT>
368 template <
typename CallableT>
374 template <
typename CallableT>
380 template <
typename TupleT>
386 template <
typename FirstElementT,
typename... ElementTs>
392 template <
typename TupleT>
402 template <
size_t Offset,
typename IndexSequence>
408 template <
size_t Offset,
size_t... Indices>
414 using type = std::index_sequence<Indices + Offset...>;
420 template <
size_t Offset,
typename IndexSequence>
428 template <
size_t From,
size_t To>
437 template <
size_t From,
size_t To>
447 template <
typename ObjectT,
typename CallableT>
470 template <
typename... ArgTs>
477 template <
size_t... Indices,
typename... ArgTs>
478 auto Invoke(std::integer_sequence<size_t, Indices...>, ArgTs&& ...Args)
const
493 template <
typename ObjectT,
typename CallableT>
504 template <
typename... ArgTs>
506 :
CallableWrapper(Object, std::move(Callable), { std::forward<ArgTs>(Args)... }) {}
536 DataPtrType::element_type*
Release() noexcept;
588 template <
typename T>
589 static size_t Get() noexcept
591 static const size_t ID =
Make();
601 static size_t Make() noexcept;
611 template <typename T>
615 seed ^= hasher(value) + 0x9e3779b9 + (seed << 6) + (seed >> 2);
622 using seconds = std::chrono::duration<double>;
646 template <
typename T>
647 std::ostream&
operator<<(std::ostream& stream,
const std::chrono::time_point<T>& TimePoint)
649 const auto ZonedTime = std::chrono::zoned_time(std::chrono::current_zone(), std::chrono::round<std::chrono::seconds>(TimePoint));
650 stream << std::format(
"{:%T %d.%m.%Y}", ZonedTime);
662 template <
typename T>
665 std::stringstream ss(String);
670 throw InvalidDataException(
"String cannot be converted to " + std::string(
typeid(T).name()) +
".");
683 template <
typename T>
684 std::string
ToStr(
const T& Value,
int Precision = -1)
686 std::stringstream ss;
689 ss << std::fixed << std::setprecision(Precision);
701 template <
typename T>
702 std::string
ToStr(
const std::chrono::time_point<T>& TimePoint)
704 std::stringstream ss;
715 inline std::string
ToStr(
const char Value) {
return ToStr(
static_cast<int>(Value)); }
720 inline std::string
ToStr(
const uint8_t Value) {
return ToStr(
static_cast<int>(Value)); }
727 inline std::string
ToStr(
const QString& Str) {
return Str.toStdString(); }
742 template <
typename ToT,
typename FromT, std::enable_if_t<
743 std::is_integral_v<ToT> && std::is_integral_v<FromT> &&
744 std::is_same_v<std::remove_cv_t<ToT>, std::remove_cv_t<FromT>>,
int> = 0
754 template <
typename ToT,
typename FromT, std::enable_if_t<
755 std::is_integral_v<ToT> && std::is_integral_v<FromT> &&
756 !std::is_same_v<std::remove_cv_t<ToT>, std::remove_cv_t<FromT>> &&
757 ((std::is_signed_v<ToT> && std::is_signed_v<FromT>) || (std::is_unsigned_v<ToT> && std::is_unsigned_v<FromT>)),
int> = 0
759 ToT
NumToT(
const FromT Value)
761 if (Value < std::numeric_limits<ToT>::lowest() || Value > std::numeric_limits<ToT>::max())
762 throw OutOfRangeException(
"Cannot convert Value into destiny type since this would cause an underflow or an overflow.");
764 return static_cast<ToT
>(Value);
770 template <
typename ToT,
typename FromT, std::enable_if_t<
771 std::is_integral_v<ToT> && std::is_integral_v<FromT> &&
772 !std::is_same_v<std::remove_cv_t<ToT>, std::remove_cv_t<FromT>> &&
773 std::is_signed_v<ToT> && std::is_unsigned_v<FromT>,
int> = 0
775 ToT
NumToT(
const FromT Value)
777 if (Value >
static_cast<std::make_unsigned_t<ToT>
>(std::numeric_limits<ToT>::max()))
778 throw OverflowException(
"Cannot convert Value into destiny type since this would cause an overflow.");
780 return static_cast<ToT
>(Value);
786 template <
typename ToT,
typename FromT, std::enable_if_t<
787 std::is_integral_v<ToT> && std::is_integral_v<FromT> &&
788 !std::is_same_v<std::remove_cv_t<ToT>, std::remove_cv_t<FromT>> &&
789 std::is_unsigned_v<ToT> && std::is_signed_v<FromT>,
int> = 0
791 ToT
NumToT(
const FromT Value)
794 throw UnderflowException(
"Cannot convert Value into destiny type since this would cause an underflow.");
795 if (
static_cast<std::make_unsigned_t<FromT>
>(Value) > std::numeric_limits<ToT>::max())
796 throw OverflowException(
"Cannot convert Value into destiny type since this would cause an overflow.");
798 return static_cast<ToT
>(Value);
804 template <
typename ToT, std::enable_if_t<
805 std::is_integral_v<ToT> &&
806 !std::is_same_v<std::remove_cv_t<ToT>,
double>,
int> = 0
810 const double RoundedValue = std::round(Value);
812 if (RoundedValue <
static_cast<double>(std::numeric_limits<ToT>::lowest()))
813 throw UnderflowException(
"Cannot convert Value into double since this would cause an underflow.");
814 if (RoundedValue >
static_cast<double>(std::numeric_limits<ToT>::max()))
815 throw OverflowException(
"Cannot convert Value into double since this would cause an overflow.");
817 return static_cast<ToT
>(RoundedValue);
826 template <
typename T>
889 inline std::string
TrimTrailingZeros(
const std::string& Str) {
return Str.substr(0, Str.find(
'\0')); }
902 inline auto FilenameFromPath(std::string Path) {
return Path.substr(Path.find_last_of(
"\\") + 1, Path.length() - Path.find_last_of(
"\\") - 1); }
909 inline auto RemoveExtFromPath(std::string Path) {
return Path.substr(0, Path.find_last_of(
".")); }
916 unsigned int Major{};
917 unsigned int Minor{};
918 unsigned int Patch{};
927 std::strong_ordering
operator<=>(
const VersionType& lhs,
const VersionType& rhs);
953 template <
typename... Ts>
954 std::vector<std::tuple<Ts...>>
ParseCSV(
const std::string& CSVData,
const char Delimiter =
';',
const size_t SkipLines = 0)
956 std::vector<std::tuple<Ts...>> ParsedLines;
957 std::istringstream CSVDataStream(CSVData);
960 for (
auto i = SkipLines; i > 0; --i)
961 CSVDataStream.ignore(std::numeric_limits<std::streamsize>::max(), CSVDataStream.widen(
'\n'));
964 const auto GetValue = [Delimiter]<
typename T>(std::istringstream& LineStream) {
965 std::string ValueStr;
966 std::getline(LineStream, ValueStr, Delimiter);
967 std::istringstream ValueStream(ValueStr);
968 ValueStream.exceptions(std::istringstream::failbit | std::istringstream::badbit);
971 ValueStream >> Value;
978 while (std::getline(CSVDataStream, Line))
980 std::istringstream LineStream(Line);
981 LineStream.exceptions(std::istringstream::failbit | std::istringstream::badbit);
985 ParsedLines.push_back({ GetValue.template operator()<Ts>(LineStream)... });
997 std::string
ExceptionToStr(
const std::exception_ptr ExceptionPtr);
1004 std::string
ToLower(std::string_view Str);
1015 std::vector<std::complex<double>>
FFT(
const std::vector<std::complex<double>>& Data,
bool InverseTransform =
false);
1035 WarningData(std::string Description,
const int ErrorCode = DynExpErrorCodes::GeneralError,
1036 const std::source_location Location = std::source_location::current())
1037 : Description(std::move(Description)), ErrorCode(ErrorCode),
1038 Line(Location.line()), Function(Location.function_name()), File(Location.file_name()) {}
1039 WarningData(std::string Description,
const int ErrorCode = DynExpErrorCodes::GeneralError,
1040 const size_t Line = 0, std::string Function =
"", std::string File =
"")
1041 : Description(std::move(Description)), ErrorCode(ErrorCode),
1042 Line(Line), Function(std::move(Function)), File(std::move(File)) {}
1044 explicit operator bool() const noexcept {
return ErrorCode != DynExpErrorCodes::NoError; }
1064 Warning(std::string Description,
const int ErrorCode = DynExpErrorCodes::GeneralError,
1065 const std::source_location Location = std::source_location::current())
1066 : Data(std::make_unique<
WarningData>(std::move(Description), ErrorCode, Location)) {}
1073 : Data(std::make_unique<
WarningData>(e.what(), e.ErrorCode, e.Line, e.Function, e.File)) {}
1103 : Message(std::move(Message)), Type(Type), TimePoint(TimePoint) {}
1154 void Log(
const std::string& Message,
const ErrorType Type = ErrorType::Info,
1155 const size_t Line = 0,
const std::string& Function =
"",
const std::string& File =
"",
const int ErrorCode = 0
1157 ,
const std::stacktrace& Trace = {}
1165 void Log(
const Exception& E)
noexcept;
1171 void Log(
const Warning& W)
noexcept;
1184 static std::string FormatLog(
const std::string& Message,
const size_t Line = 0,
1185 const std::string& Function =
"",
const std::string& Filename =
"",
const int ErrorCode = 0,
const bool PrefixMessage =
true);
1199 static std::string FormatLogHTML(
const std::string& Message,
const ErrorType Type = ErrorType::Info,
1200 const size_t Line = 0,
const std::string& Function =
"",
const std::string& Filename =
"",
const int ErrorCode = 0
1202 ,
const std::stacktrace& Trace = {}
1210 void OpenLogFile(std::string Filename);
1215 void CloseLogFile() {
auto lock = AcquireLock(LogOperationTimeout); CloseLogFileUnsafe(); }
1221 bool IsOpen()
const {
auto lock = AcquireLock(LogOperationTimeout);
return IsOpenUnsafe(); }
1227 std::string
GetLogFilename()
const {
auto lock = AcquireLock(LogOperationTimeout);
return Filename; }
1232 void ClearLog() {
auto lock = AcquireLock(LogOperationTimeout); ClearLogUnsafe(); }
1240 std::vector<LogEntry> GetLog(
size_t FirstElement = 0)
const;
1246 auto GetLogSize()
const {
auto lock = AcquireLock(LogOperationTimeout);
return LogEntries.size(); }
1255 void CloseLogFileUnsafe();
1263 static constexpr auto LogOperationTimeout = std::chrono::milliseconds(100);
1285 template <
typename EnumType, std::enable_if_t<
1286 std::is_enum_v<EnumType>,
int> = 0
1304 for (
const auto Flag : Flags)
1315 bool Test(
const std::array<EnumType, N>& Flags)
const
1317 for (
const auto Flag : Flags)
1319 auto Result = Features.test(
static_cast<size_t>(Flag));
1333 bool Test(EnumType Flag)
const {
return Features.test(
static_cast<size_t>(Flag)); }
1339 void Set(EnumType Flag) { Features.set(
static_cast<size_t>(Flag)); }
1345 std::bitset<static_cast<size_t>(EnumType::NUM_ELEMENTS)>
Features;
1360 std::enable_if_t<std::is_enum_v<return_of_t<CallableT>>,
int> = 0
1376 : State(State), StateFunction(StateFunction), Description(Description), Final(IsFinal)
1381 constexpr bool IsFinal() const noexcept {
return Final; }
1391 template <
typename... ArgTs>
1394 return (Instance.*StateFunction)(std::forward<ArgTs>(Args)...);
1418 template <
typename StateMachineStateT>
1442 std::initializer_list<const StateMachineContext*> BaseContexts = {})
1443 : ReplacementList(std::move(ReplacementList)), Description(Description)
1445 for (
auto BaseContext : BaseContexts)
1447 this->ReplacementList.insert(BaseContext->ReplacementList.cbegin(), BaseContext->ReplacementList.cend());
1464 auto AdaptedState = ReplacementList.find(State);
1466 return AdaptedState == ReplacementList.cend() ? State : AdaptedState->second;
1491 template <
typename StateMachineStateT>
1507 template <
typename... StateMachineStateTs>
1509 : StatesList{ { InitialState.GetState(), &InitialState }, { States.GetState(), &States }... },
1510 CurrentState(&InitialState), CurrentContext(
nullptr)
1524 CurrentState = StatesList.at(CurrentContext.load()->AdaptState(NewState));
1526 CurrentState = StatesList.at(NewState);
1549 template <
typename... ArgTs>
1555 if (CurrentState.load()->IsFinal())
1556 CurrentState.load()->Invoke(Instance, std::forward<ArgTs>(Args)...);
1558 SetCurrentState(CurrentState.load()->Invoke(Instance, std::forward<ArgTs>(Args)...));
1566 const std::unordered_map<StateEnumType, const StateType*>
StatesList;
Provides exception type and error definitions used by DynExp.
Physical units used in DynExp. This file does not depend on further DynExp files and therefore can be...
Data type which manages a binary large object. The reserved memory is freed upon destruction.
void Reserve(size_t Size)
Reserves Size bytes of memory freeing any previously reserved memory.
size_t DataSize
Size of the stored data in bytes.
unsigned char[] DataType
Type of the buffer's data.
DataPtrType::element_type * Release() noexcept
Releases ownership of the stored buffer returning a pointer to it and leaving this instance empty.
std::unique_ptr< DataType > DataPtrType
Type of the underlying smart pointer managing the buffer.
DataPtrType DataPtr
Pointer to the buffer.
auto Size() const noexcept
Returns the size of the stored data in bytes.
void Reset()
Frees any reserved memory.
BlobDataType()=default
Constructs an empty object.
auto GetPtr() noexcept
Returns a pointer to the stored buffer.
void Assign(size_t Size, const DataType Data)
Copies Size bytes from Data to the buffer freeing any previously reserved memory.
BlobDataType & operator=(const BlobDataType &Other)
Copy-assigns data from Other.
Wraps a member function of some object and stores its default arguments. Moving from CallableMemberWr...
auto operator()(ArgTs &&...Args) const
Invokes the stored member function. If arguments are passed, they are are forwarded instead of the st...
argument_of_t< CallableT > ArgumentTs
constexpr CallableMemberWrapper(ObjectT &Object, const CallableT Callable, ArgumentTs DefaultArgs={}) noexcept
Constructs a CallableMemberWrapper instance.
ObjectT & Object
Instance of class Callable belongs to. Callable is invoked on this instance.
auto Invoke(std::integer_sequence< size_t, Indices... >, ArgTs &&...Args) const
const ArgumentTs DefaultArgs
Default arguments to be passed when invoking operator() with less arguments Callable expects.
const CallableT Callable
Pointer to class member function to be invoked.
Logs events like errors and writes them immediately to a HTML file in a human-readable format....
bool IsOpenUnsafe() const
void CloseLogFile()
Closes the log file on disk and writes terminating HTML tags.
EventLogger(std::string Filename)
Constructs the event logger with opening a log file on disk.
std::string GetLogFilename() const
Determines the full file path to the currently openend log file.
auto GetLogSize() const
Determines the number of entries in the internal event log.
std::ofstream LogFile
Stream object to write to the log file on disk.
std::string Filename
Filename and path to the log file on disk.
~EventLogger()
Destructor closes the log file on disk.
void ClearLog()
Clears the internal event log.
std::vector< LogEntry > LogEntries
Internally stored log entries.
bool IsOpen() const
Determines whether the log file has been openend on disk.
DynExp exceptions are derived from this class. It contains basic information about the cause of the e...
Holds a bitset containing flags to indicate which features a certain instrument/ module etc....
constexpr FeatureTester() noexcept=default
Constructs a FeatureTester instance with no flags set.
void Set(EnumType Flag)
Sets a flag.
bool Test(const std::array< EnumType, N > &Flags) const
Tests whether all of the flags passed as an array are set.
std::bitset< static_cast< size_t >(EnumType::NUM_ELEMENTS)> Features
Bitset containing the flags and their states.
bool Test(EnumType Flag) const
Tests whether a single flag is set.
Interface to allow synchronizing the access to derived classes between different threads by providing...
LockType AcquireLock(const std::chrono::milliseconds Timeout=DefaultTimeout) const
Locks the internal mutex. Blocks until the mutex is locked or until the timeout duration is exceeded.
std::timed_mutex MutexType
std::unique_lock< MutexType > LockType
MutexType LockMutex
Internal mutex used for locking.
static constexpr std::chrono::milliseconds DefaultTimeout
Duration which is used as a default timeout within all methods of this class if no different duration...
Interface to delete copy constructor and copy assignment operator and thus make derived classes non-c...
constexpr INonCopyable()=default
INonCopyable & operator=(const INonCopyable &)=delete
INonCopyable(const INonCopyable &)=delete
Interface to delete move constructor and move assignment operator and thus make derived classes non-m...
INonMovable(const INonMovable &)=default
INonMovable(INonMovable &&)=delete
INonMovable & operator=(const INonMovable &)=default
constexpr INonMovable()=default
INonMovable & operator=(INonMovable &&)=delete
Interface to allow synchronizing the access to derived classes between different threads by making th...
std::timed_mutex LockMutex
Internal mutex used for locking.
void ReleaseLock() const
Releases the internal mutex. Does nothing if the mutex was not locked or if the calling thread is not...
~ISynchronizedPointerLockable()
Object should never be destroyed before completely unlocked.
ISynchronizedPointerLockable()
std::atomic< size_t > OwnedCount
Counts the lock requests of the current owning thread.
std::atomic< std::thread::id > OwnerID
ID of the thread which currently owns the internal mutex.
void AcquireLock(const std::chrono::milliseconds Timeout) const
Locks the internal mutex. Blocks until the mutex is locked or until the timeout duration is exceeded....
Data to operate on is invalid for a specific purpose. This indicates a corrupted data structure or fu...
An operation cannot be performed currently since the related object is in an invalid state like an er...
Holds a CallableMemberWrapper and invokes its callable when being destroyed.
CallableMemberWrapper< ObjectT, CallableT > CallableWrapper
OnDestruction(ObjectT &Object, const CallableT Callable, ArgTs &&...Args)
Constructs a OnDestruction instance which calls Callable upon destruction of this instance.
Helper class to communicate flags between different threads based on a condition variable and a mutex...
std::condition_variable ConditionVariable
std::atomic< bool > MutexCanBeDestroyed
bool Wait(const std::chrono::milliseconds Timeout=std::chrono::milliseconds(0))
Makes current thread wait until it is notified or until given timeout duration is exceeded....
void Notify()
Set notification to stop waiting (sets EventOccurred to true).
void Ignore()
Ignore last notification (sets EventOccurred to false).
Data type which stores an optional bool value (unknown, false, true). The type evaluates to bool whil...
Values
Possible values. Values::Unknown evaluates to false.
constexpr OptionalBool(bool b) noexcept
Contructs an instance holding b.
constexpr OptionalBool(const OptionalBool &Other) noexcept
Contructs a copy of Other.
constexpr OptionalBool(Values Value) noexcept
Contructs an instance holding Value.
constexpr bool operator!=(Values Value) const noexcept
Returns false when Value matches stored value, true otherwise.
constexpr bool operator==(Values Value) const noexcept
Returns true when Value matches stored value, false otherwise.
constexpr OptionalBool & operator=(Values Value) noexcept
Assigns Value, returns reference to this.
constexpr OptionalBool() noexcept
Contructs an instance holding Values::Unknown.
constexpr OptionalBool & operator=(OptionalBool &Other) noexcept
Assigns value of Other, returns reference to this.
Values Value
Internal value.
constexpr Values Get() const noexcept
Returns internal value.
constexpr OptionalBool & operator=(bool b) noexcept
Assigns b, returns reference to this.
Thrown when a numeric operation would result in an overflow (e.g. due to incompatible data types)
State machine context as used by class StateMachine. A state machine context holds a map with keys an...
typename StateType::StateEnumType StateEnumType
Refer to class StateMachineState.
StateEnumType AdaptState(StateEnumType State) const
Checks whether the context contains a replacement entry for the state identified by State and returns...
std::unordered_map< StateEnumType, StateEnumType > ReplacementListType
constexpr auto GetDescription() const noexcept
Returns the context's description.
StateMachineStateT StateType
ReplacementListType ReplacementList
Within this context, the map's key states are replaced by the corresponding value states....
StateMachineContext()=default
Default constructor constructs an empty context not performing any state replacement.
StateMachineContext(ReplacementListType &&ReplacementList, const char *Description="", std::initializer_list< const StateMachineContext * > BaseContexts={})
Constructs a StateMachineContext from a replacement list appending the replacement lists of each cont...
State machine state as used by class StateMachine. A state mainly wraps a state function of the membe...
const StateEnumType State
StateEnumType Invoke(instance_of_t< CallableT > &Instance, ArgTs &&... Args) const
Invokes the state function associated with this state on an instance of the class the state function ...
const bool Final
For final states, it is ensured that the state's state function can delete the state machine....
return_of_t< CallableT > StateEnumType
constexpr StateEnumType GetState() const noexcept
Returns the state's unique identifier.
const std::decay_t< CallableT > StateFunction
constexpr auto GetDescription() const noexcept
Returns the state's description.
constexpr StateMachineState(StateEnumType State, CallableT StateFunction, const char *Description="", const bool IsFinal=false) noexcept
Constructs a state machine state and assigns fixed parameters to it.
constexpr bool IsFinal() const noexcept
Returns whether this is a final state.
This class models a state machine. It keeps track of the current state and allows to invoke its assoc...
std::atomic< const StateType * > CurrentState
void Invoke(instance_of_t< typename StateType::CallableType > &Instance, ArgTs &&... Args)
Invokes the state function associated with the current state machine state on an instance of the clas...
void SetContext(const ContextType *NewContext)
Sets the current state machine context.
StateMachineStateT StateType
void ResetContext()
Removes the current state machine context.
void SetCurrentState(StateEnumType NewState)
Sets the current state as identified by an element from StateEnumType.
StateMachine(const StateType &InitialState, const StateMachineStateTs &... States)
Constructs a state machine assigning possible states to it. Automatically also adds InitialState,...
typename StateType::StateEnumType StateEnumType
Refer to class StateMachineState.
const StateType * GetCurrentState() const noexcept
Returns a pointer to the current state.
std::atomic< const ContextType * > CurrentContext
const std::unordered_map< StateEnumType, const StateType * > StatesList
Map of possible states. All states are uniquely identified by an element from StateEnumType....
const ContextType * GetContext() const noexcept
Returns a pointer to the current context.
Pointer to lock a class derived from ISynchronizedPointerLockable for synchronizing between threads....
bool operator!=(const T *rhs) const noexcept
SynchronizedPointer(SynchronizedPointer< U > &&Other)
Moves the LockableObject from a SynchronizedPointer<U> of another type U to a new instance of Synchro...
SynchronizedPointer(T *const LockableObject, const std::chrono::milliseconds Timeout=ILockable::DefaultTimeout)
Constructs a pointer locking LockableObject. Blocks until LockableObject's mutex is locked or until t...
bool operator==(const SynchronizedPointer &rhs) const noexcept
SynchronizedPointer & operator=(SynchronizedPointer &&Other) noexcept
Move-assigns the LockableObject from another SynchronizedPointer instance Other to this instance....
SynchronizedPointer() noexcept
Contructs an instance with an empty pointer.
SynchronizedPointer(SynchronizedPointer &&Other) noexcept
Moves the LockableObject from another SynchronizedPointer instance Other to a new instance....
auto operator->() const noexcept
auto & operator*() const noexcept
bool operator!=(const SynchronizedPointer &rhs) const noexcept
T * LockableObject
Pointer to the locakable object managed by this class.
auto get() const noexcept
Returns the managed (locked) object.
bool operator==(const T *rhs) const noexcept
Thrown when an operation timed out before it could be completed, especially used for locking shared d...
Thrown when an attempt was made to convert two incompatible types into each other.
Thrown when a numeric operation would result in an underflow (e.g. due to incompatible data types)
Collection of static functions to generate a unique ID for data types.
static size_t Get() noexcept
Generates a unique ID for each template instantiation. The first ID is 1 to allow assigning a special...
static size_t Make() noexcept
Creates a new ID for each call.
Class to store information about warnings in a thread-safe manner (deriving from ILockable)....
Warning()
Constructs an empty Warning.
virtual ~Warning()=default
Warning(std::string Description, const int ErrorCode=DynExpErrorCodes::GeneralError, const std::source_location Location=std::source_location::current())
Constructs a Warning from specified information.
Warning(const Exception &e)
Constructs a Warning retrieving the warning data from an exception e.
std::unique_ptr< WarningData > Data
Pointer to warning data. Must never be nullptr.
static constexpr double SpeedOfLight
Speed of light in vacuum in m/s.
DynExp's Util namespace contains commonly used functions and templates as well as extensions to Qt an...
std::string ToStr(const T &Value, int Precision=-1)
Converts a (numeric) value of type T to a std::string using operator<< of std::stringstream.
typename member_fn_ptr_traits< CallableT >::instance_type instance_of_t
Alias for the class type a member function callable of type CallableT is member of.
std::string ToUnitStr< std::chrono::seconds >()
Returns a string describing the physical unit associated with type T. For example,...
constexpr bool is_contained_in_v
Value type of is_contained_in.
constexpr auto ConvertFrequencyWavelength(double Value) noexcept
Converts the frequency value of an electromagnetic wave in Hz to the corresponding wavelength in m an...
std::index_sequence< Indices+Offset... > type
Alias for offset index sequence.
auto FilenameFromPath(std::string Path)
Extracts the filename from a path.
std::string ExceptionToStr(const std::exception_ptr ExceptionPtr)
Returns the what() information of an exception derived from std::exception and stored in an exception...
std::tuple< ArgumentTs... > argument_types
T StrToT(const std::string &String)
Converts a std::string to a value of type T using operator<< of std::stringstream.
std::tuple< ElementTs... > type
std::string ToUnitStr< picoseconds >()
Returns a string describing the physical unit associated with type T. For example,...
std::tuple< ArgumentTs... > argument_types
auto CurrentTimeAndDateString()
Returns a human-readable string describing the current time and date in the current time zone.
typename remove_first_from_tuple< TupleT >::type remove_first_from_tuple_t
Alias for a tuple of types where the first type of the input tuple TupleT is removed.
VersionType VersionFromString(std::string_view Str)
Extracts a program version from a string.
typename OffsetIndexSequence< Offset, IndexSequence >::type OffsetIndexSequence_t
Alias for type contained in OffsetIndexSequence.
EventLogger & EventLog()
This function holds a static EventLogger instance and returns a reference to it. DynExp uses only one...
std::tuple< ArgumentTs... > argument_types
std::vector< std::tuple< Ts... > > ParseCSV(const std::string &CSVData, const char Delimiter=';', const size_t SkipLines=0)
Parses a string containing comma-separated values (csv) and inserts each row as one tuple containing ...
typename member_fn_ptr_traits< CallableT >::return_type return_of_t
Alias for the return type of a member function callable of type CallableT.
std::string ToUnitStr()
Returns a string describing the physical unit associated with type T. For example,...
std::chrono::duration< double, std::pico > picoseconds
Extends std::chrono by a duration data type for picoseconds.
std::strong_ordering operator<=>(const VersionType &lhs, const VersionType &rhs)
Compares two program version types with each other.
std::string ToUnitStr< std::chrono::milliseconds >()
Returns a string describing the physical unit associated with type T. For example,...
std::string ToUnitStr< std::chrono::nanoseconds >()
Returns a string describing the physical unit associated with type T. For example,...
std::string ToLower(std::string_view Str)
Transforms a string into lower case.
std::chrono::duration< double > seconds
Extends std::chrono by a duration data type for seconds capable of storing fractions of seconds.
auto RemoveExtFromPath(std::string Path)
Removes the filename's extension from a path.
std::string TrimTrailingZeros(const std::string &Str)
Removes trailing zeros ('\0') from a string.
std::tuple< ArgumentTs... > argument_types
typename RangeIndexSequence< From, To >::type RangeIndexSequence_t
Alias for type contained in RangeIndexSequence.
ToT NumToT(const FromT Value)
Converts a value of a numeric type to a value of another numeric type checking the conversion for its...
std::ostream & operator<<(std::ostream &stream, const Exception &e)
Writes a DynExp exception in a user-readable way to a stream.
void HashCombine(std::size_t &seed, const T &value)
Combines the std::hash seed with the hash of value. Resembles hash_combine() from the Boost library p...
ErrorType
DynExp's error types
std::vector< std::complex< double > > FFT(const std::vector< std::complex< double > > &Data, bool InverseTransform)
Computes the Fast Fourier Transform (FFT) a vector of complex values.
typename member_fn_ptr_traits< CallableT >::argument_types argument_of_t
Alias for a tuple of argument types the member function callable of type CallableT expects.
std::string ToUnitStr< seconds >()
Returns a string describing the physical unit associated with type T. For example,...
std::string ToUnitStr< std::chrono::microseconds >()
Returns a string describing the physical unit associated with type T. For example,...
OffsetIndexSequence_t< From, std::make_index_sequence< To - From > > type
Holds an alias for a std::index_sequence where all indices are shifted by an offset.
Holds an alias for a std::index_sequence spanning a certain range.
Data type describing DynExp's program version in the form Major.Minor.Patch.
Extracts the return value type, the class type the callable is member of, and the argument types of a...
Removes first type from a tuple of types TupleT.
#define DYNEXP_HAS_STACKTRACE
Data type of a single entry in DynExp's log.
LogEntry(std::string Message, ErrorType Type, std::chrono::system_clock::time_point TimePoint)
const std::string Message
String describing the log entry including reasons and consequences of the message.
const ErrorType Type
DynExp error code from DynExpErrorCodes::DynExpErrorCodes associated with the log enty
const std::chrono::system_clock::time_point TimePoint
Time point associated with the log enty.
Data associated with a warning. The class is convertible to bool (true if it describes an error/warni...
const std::string Function
Function in source code where the warning occurred.
const std::string Description
String describing the reason and consequences of the warning.
const std::string File
Source code file where the warning occurred.
const size_t Line
Line in source code where the warning occurred.
WarningData(std::string Description, const int ErrorCode=DynExpErrorCodes::GeneralError, const size_t Line=0, std::string Function="", std::string File="")
WarningData()
Default constructor sets ErrorCode to a non-error code.
const int ErrorCode
DynExp error code from DynExpErrorCodes::DynExpErrorCodes
WarningData(std::string Description, const int ErrorCode=DynExpErrorCodes::GeneralError, const std::source_location Location=std::source_location::current())
Checks whether a type T is contained in a template parameter pack of types ListTs.