DynExp
Highly flexible laboratory automation for dynamically changing experiments.
|
DynExp's Util namespace contains commonly used functions and templates as well as extensions to Qt and its widgets. More...
Namespaces | |
DynExpErrorCodes | |
Classes | |
class | circularbuf |
Circular stream buffer to be used with the standard library's stream classes. Reading from or writing behind the buffer's end continues at the buffer's beginning. More... | |
class | Exception |
DynExp exceptions are derived from this class. It contains basic information about the cause of the exception as well as a stacktrace. More... | |
class | ForwardedException |
Class to forward an Exception instance from one DynExp::Object instance to another DynExp::Object instance. Refer to class DynExp::LinkedObjectWrapperContainer . More... | |
class | InvalidArgException |
An invalid argument like a null pointer has been passed to a function. More... | |
class | InvalidStateException |
An operation cannot be performed currently since the related object is in an invalid state like an error state. More... | |
class | InvalidDataException |
Data to operate on is invalid for a specific purpose. This indicates a corrupted data structure or function calls not returning data in the expected format. More... | |
class | InvalidCallException |
Thrown when a function call is not allowed to a specific thread in a multi-threading context. More... | |
class | UnderflowException |
Thrown when a numeric operation would result in an underflow (e.g. due to incompatible data types) More... | |
class | OverflowException |
Thrown when a numeric operation would result in an overflow (e.g. due to incompatible data types) More... | |
class | OutOfRangeException |
Thrown when an argument passed to a function exceeds the valid range. More... | |
class | EmptyException |
Thrown when a list is expected to contain entries and when a query results in an empty answer or an empty argument has been passed to a function, or a stored list is empty. More... | |
class | NotFoundException |
Thrown when a requested ressource does not exist. More... | |
class | TypeErrorException |
Thrown when an attempt was made to convert two incompatible types into each other. More... | |
class | TimeoutException |
Thrown when an operation timed out before it could be completed, especially used for locking shared data in a multi-threading context. More... | |
class | ThreadDidNotRespondException |
Thrown in a multi-threading context when an answer is expected from another thread an when the communication timed out. More... | |
class | NotAvailableException |
Thrown when some operation or feature is temporarily or permanently not available. More... | |
class | NotImplementedException |
Thrown when a requested feature is either under development and thus not implemented yet or when a specific instrument does not support certain operation. More... | |
class | FileIOErrorException |
Thrown when reading from or writing to a file failed. More... | |
class | LinkedObjectNotLockedException |
Thrown when RunnableInstance::LockObject() has not been called on an object link parameter to establish the relation between the object using another object and the used object. More... | |
class | InvalidObjectLinkException |
Thrown when RunnableInstance cannot lock an object to be used by another object due to an invalid link between the objects. This happens when the used object the link points to has been removed from the project. More... | |
class | ServiceFailedException |
Denotes that e.g. a remote gRPC service failed. More... | |
class | PyStdoutLoggerWrapper |
Forwards Python's stdout to Util::EventLogger instance defined in Util::EventLog(). More... | |
class | PyGilReleasedInterpreter |
Initialize Python interpreter and directly release the GIL after construction. More... | |
class | PyObject |
Wraps a class derived from pybind11::object and ensures that the GIL is acquired when the PyObject is destroyed. For any other operation on this wrapper, the GIL still needs to be acquired manually before! More... | |
class | QWorker |
Implements a QObject belonging to a hardware adapter (derived from DynExp::HardwareAdapterBase) that operates in DynExpCore's worker thread, not in the main user interface thread. This is useful to move e.g. ethernet/serial communication operations from the user interface thread to a worker thread. After construction, QWorker instances have to be moved to the worker thread calling QWorker::MoveToWorkerThread(). More... | |
class | MarkerGraphicsView |
Implements a QGraphicsView the user can interact with to insert graphical markers. Furthermore, the graphics view enables zooming into its content. More... | |
class | QSortingListWidget |
Implements a QListWidget that sorts its items after inserting an item by drag & drop. More... | |
class | NumericSortingTableWidgetItem |
Implements a QTableWidgetItem which contains numeric content such that table widget items can be numerically compared with each other. More... | |
class | NumericOnlyItemDelegate |
Implements a QItemDelegate which forces e.g. a QTableWidgetItem's content to be numeric (double-precision). More... | |
class | DigitalOnlyItemDelegate |
Implements a QItemDelegate which forces e.g. a QTableWidgetItem's content to be boolean (0 or 1). More... | |
class | INonCopyable |
Interface to delete copy constructor and copy assignment operator and thus make derived classes non-copyable. More... | |
class | INonMovable |
Interface to delete move constructor and move assignment operator and thus make derived classes non-movable. More... | |
class | ILockable |
Interface to allow synchronizing the access to derived classes between different threads by providing a mutex and a method to lock that mutex. Recursive locking is not allowed. More... | |
class | SynchronizedPointer |
Pointer to lock a class derived from ISynchronizedPointerLockable for synchronizing between threads. Instances of this class are not intended to be stored somewhere since they make other threads block. Only use as temporary objects. More... | |
class | ISynchronizedPointerLockable |
Interface to allow synchronizing the access to derived classes between different threads by making the class lockable by SynchronizedPointer smart pointer objects. Recursive locking is allowed. More... | |
class | OneToOneNotifier |
Helper class to communicate flags between different threads based on a condition variable and a mutex. Two threads make use of the same instance of this class. One of the thread awaits a flag to be set by the other thread. More... | |
struct | is_contained_in |
Checks whether a type T is contained in a template parameter pack of types ListTs . More... | |
struct | member_fn_ptr_traits |
Extracts the return value type, the class type the callable is member of, and the argument types of a callable type CallableT which is a member function of some class. The extracted types are stored using type aliases return_type and instance_type and an alias of a tuple of types argument_types . More... | |
struct | member_fn_ptr_traits< ReturnT(ObjectT::*)(ArgumentTs...) const > |
Extracts the return value type, the class type the callable is member of, and the argument types of a callable type CallableT which is a member function of some class. The extracted types are stored using type aliases return_type and instance_type and an alias of a tuple of types argument_types . More... | |
struct | member_fn_ptr_traits< ReturnT(ObjectT::*)(ArgumentTs...) noexcept > |
Extracts the return value type, the class type the callable is member of, and the argument types of a callable type CallableT which is a member function of some class. The extracted types are stored using type aliases return_type and instance_type and an alias of a tuple of types argument_types . More... | |
struct | member_fn_ptr_traits< ReturnT(ObjectT::*)(ArgumentTs...) const noexcept > |
Extracts the return value type, the class type the callable is member of, and the argument types of a callable type CallableT which is a member function of some class. The extracted types are stored using type aliases return_type and instance_type and an alias of a tuple of types argument_types . More... | |
struct | member_fn_ptr_traits< ReturnT(ObjectT::*)(ArgumentTs...)> |
Extracts the return value type, the class type the callable is member of, and the argument types of a callable type CallableT which is a member function of some class. The extracted types are stored using type aliases return_type and instance_type and an alias of a tuple of types argument_types . More... | |
struct | remove_first_from_tuple |
Removes first type from a tuple of types TupleT . More... | |
struct | remove_first_from_tuple< std::tuple< FirstElementT, ElementTs... > > |
Removes first type from a tuple of types TupleT . More... | |
struct | OffsetIndexSequence |
Holds an alias for a std::index_sequence where all indices are shifted by an offset. More... | |
struct | OffsetIndexSequence< Offset, std::index_sequence< Indices... > > |
Holds an alias for a std::index_sequence where all indices are shifted by an offset. More... | |
struct | RangeIndexSequence |
Holds an alias for a std::index_sequence spanning a certain range. More... | |
class | CallableMemberWrapper |
Wraps a member function of some object and stores its default arguments. Moving from CallableMemberWrapper does not work since this class holds const members and a reference to the object the member function is invoked on. Copy instead. More... | |
class | OnDestruction |
Holds a CallableMemberWrapper and invokes its callable when being destroyed. More... | |
class | BlobDataType |
Data type which manages a binary large object. The reserved memory is freed upon destruction. More... | |
class | OptionalBool |
Data type which stores an optional bool value (unknown, false, true). The type evaluates to bool while an unknown value is considered false. More... | |
struct | VersionType |
Data type describing DynExp's program version in the form Major.Minor.Patch. More... | |
class | Warning |
Class to store information about warnings in a thread-safe manner (deriving from ILockable ). All function calls are thread-safe. More... | |
struct | LogEntry |
Data type of a single entry in DynExp's log. More... | |
class | EventLogger |
Logs events like errors and writes them immediately to a HTML file in a human-readable format. The logger also stores the events in an internal event log to be displayed within DynExp. The class is designed such that instances can be shared between different threads. Member function calls are synchronized. More... | |
class | FeatureTester |
Holds a bitset containing flags to indicate which features a certain instrument/ module etc. supports. More... | |
class | StateMachineState |
State machine state as used by class StateMachine. A state mainly wraps a state function of the member function pointer type CallableT to be invoked by the state machine. More... | |
class | StateMachineContext |
State machine context as used by class StateMachine. A state machine context holds a map with keys and values of unique state identifiers of type StateEnumType (refer to class StateMachineState). Each map entry indicates a state (key) to be replaced by another state (value). StateMachine::Invoke checks the state identifiers returned by StateMachineState::Invoke and possibly replaces them according to the current context before setting the new state machine state. Contexts can be derived from base contexts unifying and including their replacement lists. More... | |
class | StateMachine |
This class models a state machine. It keeps track of the current state and allows to invoke its associated state function. The return value of the state function determines the new state to transition into. Additionally, a context of type StateMachineContext can be assigned to the state machine. Contexts allow for replacing states with other states. This makes sense to write inner protocols BeginState -> StateA -> ... -> StateN -> EndState and to embed them into outer protocols. The outer protocol can transition into BeginState and take control back by replacing EndState with one of its own states by setting a respective context. All states (of type StateMachineState) have to be registered upon construction of the StateMachine instance. More... | |
Typedefs | |
using | TextType = std::string |
String type of text-type parameters (DynExp::ParamsBase::Param) More... | |
using | TextRefType = std::string_view |
Reference-to-string type of text-type parameters (DynExp::ParamsBase::Param) More... | |
using | TextListType = std::vector< TextType > |
List type of text-type parameters. More... | |
using | TextListIndexType = size_t |
List index type of Util::TextListType . More... | |
template<typename ValueType > | |
using | TextValueListType = std::vector< std::pair< TextType, ValueType > > |
Type of a list containing key-value pairs where key is a text of type Util::TextType . More... | |
template<typename CallableT > | |
using | return_of_t = typename member_fn_ptr_traits< CallableT >::return_type |
Alias for the return type of a member function callable of type CallableT . More... | |
template<typename CallableT > | |
using | instance_of_t = typename member_fn_ptr_traits< CallableT >::instance_type |
Alias for the class type a member function callable of type CallableT is member of. More... | |
template<typename CallableT > | |
using | argument_of_t = typename member_fn_ptr_traits< CallableT >::argument_types |
Alias for a tuple of argument types the member function callable of type CallableT expects. More... | |
template<typename TupleT > | |
using | remove_first_from_tuple_t = typename remove_first_from_tuple< TupleT >::type |
Alias for a tuple of types where the first type of the input tuple TupleT is removed. More... | |
template<size_t Offset, typename IndexSequence > | |
using | OffsetIndexSequence_t = typename OffsetIndexSequence< Offset, IndexSequence >::type |
Alias for type contained in OffsetIndexSequence . More... | |
template<size_t From, size_t To> | |
using | RangeIndexSequence_t = typename RangeIndexSequence< From, To >::type |
Alias for type contained in RangeIndexSequence . More... | |
Enumerations | |
enum class | ErrorType { Info , Warning , Error , Fatal } |
DynExp's error types More... | |
Functions | |
std::ostream & | operator<< (std::ostream &stream, const Exception &e) |
Writes a DynExp exception in a user-readable way to a stream. More... | |
void | ForwardException (std::exception_ptr e) |
Wraps the exception passed to the function in a ForwardedException and throws the ForwardedException. Does nothing if e is not an exception. More... | |
const QLocale & | GetDefaultQtLocale () |
Returns the default locale properties to be assigned to Qt widgets. More... | |
void | ActivateWindow (QWidget &Widget) |
Renders a window active and brings it to the front. More... | |
template<typename EnumType > | |
auto | QtEnumToTextValueList (unsigned short SkipEntriesFront=0, unsigned short SkipEntriesEnd=0, unsigned short SkipCharsFront=0, unsigned short SkipCharsEnd=0) |
Returns a TextValueListType containing entries which reflect the items (names and values) of an enumeration registered to Qt's meta-object system. More... | |
std::strong_ordering | operator<=> (const VersionType &lhs, const VersionType &rhs) |
Compares two program version types with each other. More... | |
VersionType | VersionFromString (std::string_view Str) |
Extracts a program version from a string. More... | |
std::string | ExceptionToStr (const std::exception_ptr ExceptionPtr) |
Returns the what() information of an exception derived from std::exception and stored in an exception pointer. More... | |
std::string | ToLower (std::string_view Str) |
Transforms a string into lower case. More... | |
std::vector< std::complex< double > > | FFT (const std::vector< std::complex< double >> &Data, bool InverseTransform=false) |
Computes the Fast Fourier Transform (FFT) a vector of complex values. More... | |
EventLogger & | EventLog () |
This function holds a static EventLogger instance and returns a reference to it. DynExp uses only one EventLogger instance to log events from any thread. A local static object instead of a global object is employed to avoid initialization order problems. More... | |
std::string | TrimTrailingZeros (const std::string &Str) |
Removes trailing zeros ('\0') from a string. More... | |
auto | CurrentTimeAndDateString () |
Returns a human-readable string describing the current time and date in the current time zone. More... | |
auto | FilenameFromPath (std::string Path) |
Extracts the filename from a path. More... | |
auto | RemoveExtFromPath (std::string Path) |
Removes the filename's extension from a path. More... | |
std::string | ToStr (const VersionType &Version) |
Converts a program version to a string in the form specified by VersionType . More... | |
template<typename... Ts> | |
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 column data into a vector of tuples. More... | |
DOM functions | |
These functions can be used to walk through an (XML-)DOM tree. | |
std::vector< QDomNode > | GetChildDOMNodes (const QDomElement &Parent, const QString &ChildTagName) |
Finds child nodes with a certain tag name. More... | |
QDomNode | GetSingleChildDOMNode (const QDomElement &Parent, const QString &ChildTagName) |
Finds a single child node with a certain tag name. More... | |
QDomElement | GetSingleChildDOMElement (const QDomElement &Parent, const QString &ChildTagName) |
Behaves like GetSingleChildDOMNode() but returns the node converted to a DOM element. More... | |
std::string | GetStringFromDOMElement (const QDomElement &Parent, const QString &ChildTagName) |
Behaves like GetSingleChildDOMElement() but returns the text from a DOM element. More... | |
template<> | |
std::string | GetTFromDOMElement (const QDomElement &Parent, const QString &ChildTagName) |
Behaves like GetSingleChildDOMElement() but returns the content from a DOM element converted to a certain type using Util::StrToT(). More... | |
QDomAttr | GetDOMAttribute (const QDomElement &Element, const QString &AttributeName) |
Extracts an attribute from a DOM element. More... | |
std::string | GetStringFromDOMAttribute (const QDomElement &Element, const QString &AttributeName) |
Behaves like GetDOMAttribute() but returns the text from the attribute. More... | |
template<> | |
std::string | GetTFromDOMAttribute (const QDomElement &Element, const QString &AttributeName) |
Behaves like GetDOMAttribute() but returns the content from an attribute converted to a certain type using Util::StrToT(). More... | |
File open and save dialogs | |
QString | PromptOpenFilePath (QWidget *Parent, const QString &Title, const QString &DefaultSuffix, const QString &NameFilter, const QString &InitialDirectory="") |
Opens a file dialog to ask the user to select a single existing file. More... | |
QString | PromptSaveFilePath (QWidget *Parent, const QString &Title, const QString &DefaultSuffix, const QString &NameFilter, const QString &InitialDirectory="") |
Works as PromptOpenFilePath() but asks the user to select a single file which does not need to exist. More... | |
QString | PromptSaveFilePathModule (DynExp::QModuleWidget *Parent, const QString &Title, const QString &DefaultSuffix, const QString &NameFilter) |
Works as PromptOpenFilePath() but asks the user to select a single file which does not need to exist. Furthermore, the dialog automatically derives the initial directory using QModuleWidget::GetDataSaveDirectory() and sets the new global directory for saving data to the folder containing the selected file when the user accepts the dialog. More... | |
Reading and writing files | |
bool | SaveToFile (const QString &Filename, std::string_view Text) |
Saves a std::string_view to a file (using QFile). Creates a new file or truncates an existing file's content. More... | |
std::string | ReadFromFile (const QString &Filename) |
Reads the entire content from a text file. More... | |
std::string | ReadFromFile (const std::string &Filename) |
Reads the entire content from a text file. More... | |
std::string | ReadFromFile (const std::filesystem::path &Filename) |
Reads the entire content from a text file. More... | |
Variables | |
static constexpr auto | PyTab = " " |
Character sequence to indent a Python instruction by one level. More... | |
template<typename T , typename... ListTs> | |
constexpr bool | is_contained_in_v = is_contained_in<T, ListTs...>::value |
Value type of is_contained_in . More... | |
Image manipulation | |
using | ImageHistogramType = std::array< unsigned long long, 256 > |
Alias which represents a histogram as a std::array with 256 numeric bins. The lowest (highest) index represents the darkest (brightest) intensity. More... | |
using | ImageRGBHistogramType = std::tuple< ImageHistogramType, ImageHistogramType, ImageHistogramType > |
Alias which represents a RGB histogram as a std::tuple of three ImageHistogramType elements. The first tuple element represents the histogram for red, the second for green, the third for blue. More... | |
QImage | QImageFromBlobData (BlobDataType &&BlobData, int Width, int Height, int BytesPerLine, QImage::Format Format) |
Converts raw pixel data stored in a Util::BlobDataType object to a QImage transfering the ownership of BlobData's content. More... | |
ImageHistogramType | ComputeIntensityHistogram (const QImage &Image) |
Computes an intensity (grayscale) histogram from a QImage object. More... | |
ImageRGBHistogramType | ComputeRGBHistogram (const QImage &Image) |
Computes a RGB histogram from a QImage object. More... | |
ImageHistogramType | ConvertRGBToIntensityHistogram (const ImageRGBHistogramType &RGBHistogram) |
Computes an intensity (grayscale) histogram from a RGB histogram. More... | |
QPolygonF | MakeCrossPolygon (QPointF Center, unsigned int ArmLength) |
Returns a QPolygonF representing a cross-style marker. More... | |
Conversion functions | |
These functions can be used to convert between different number and string types. | |
using | seconds = std::chrono::duration< double > |
Extends std::chrono by a duration data type for seconds capable of storing fractions of seconds. More... | |
using | picoseconds = std::chrono::duration< double, std::pico > |
Extends std::chrono by a duration data type for picoseconds. More... | |
template<typename T > | |
std::ostream & | operator<< (std::ostream &stream, const std::chrono::time_point< T > &TimePoint) |
Formats a time point to a human-readable string describing the time in the current time zone and writes the string to a stream. More... | |
template<typename T > | |
T | StrToT (const std::string &String) |
Converts a std::string to a value of type T using operator<< of std::stringstream. More... | |
template<typename T > | |
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. More... | |
template<typename T > | |
std::string | ToStr (const std::chrono::time_point< T > &TimePoint) |
Converts a time point to a human-readable string describing the time in the current time zone. More... | |
std::string | ToStr (const char Value) |
Converts Value to a std::string using operator<< of std::stringstream. More... | |
std::string | ToStr (const uint8_t Value) |
Converts Value to a std::string using operator<< of std::stringstream. More... | |
std::string | ToStr (const QString &Str) |
Converts the Qt QString Str to a std::string. More... | |
template<typename ToT , typename FromT , std::enable_if_t< std::is_integral_v< ToT > &&std::is_integral_v< FromT > &&std::is_same_v< std::remove_cv_t< ToT >, std::remove_cv_t< FromT >>, int > = 0> | |
ToT | NumToT (const FromT Value) |
Converts a value of a numeric type to a value of another numeric type checking the conversion for its bounds. More... | |
template<typename ToT , std::enable_if_t< std::is_integral_v< ToT > &&!std::is_same_v< std::remove_cv_t< ToT >, double >, int > = 0> | |
ToT | NumToT (const double Value) |
Converts a value of a numeric type to a value of another numeric type checking the conversion for its bounds. More... | |
template<typename T > | |
std::string | ToUnitStr () |
Returns a string describing the physical unit associated with type T . For example, if T is std::chrono::milliseconds, the function returns the string "ms". More... | |
template<> | |
std::string | ToUnitStr< std::chrono::seconds > () |
Returns a string describing the physical unit associated with type T . For example, if T is std::chrono::milliseconds, the function returns the string "ms". More... | |
template<> | |
std::string | ToUnitStr< std::chrono::milliseconds > () |
Returns a string describing the physical unit associated with type T . For example, if T is std::chrono::milliseconds, the function returns the string "ms". More... | |
template<> | |
std::string | ToUnitStr< std::chrono::microseconds > () |
Returns a string describing the physical unit associated with type T . For example, if T is std::chrono::milliseconds, the function returns the string "ms". More... | |
template<> | |
std::string | ToUnitStr< std::chrono::nanoseconds > () |
Returns a string describing the physical unit associated with type T . For example, if T is std::chrono::milliseconds, the function returns the string "ms". More... | |
template<> | |
std::string | ToUnitStr< seconds > () |
Returns a string describing the physical unit associated with type T . For example, if T is std::chrono::milliseconds, the function returns the string "ms". More... | |
template<> | |
std::string | ToUnitStr< picoseconds > () |
Returns a string describing the physical unit associated with type T . For example, if T is std::chrono::milliseconds, the function returns the string "ms". More... | |
DynExp's Util namespace contains commonly used functions and templates as well as extensions to Qt and its widgets.
struct Util::member_fn_ptr_traits |
Extracts the return value type, the class type the callable is member of, and the argument types of a callable type CallableT
which is a member function of some class. The extracted types are stored using type aliases return_type
and instance_type
and an alias of a tuple of types argument_types
.
struct Util::member_fn_ptr_traits< ReturnT(ObjectT::*)(ArgumentTs...) const > |
Extracts the return value type, the class type the callable is member of, and the argument types of a callable type CallableT
which is a member function of some class. The extracted types are stored using type aliases return_type
and instance_type
and an alias of a tuple of types argument_types
.
Class Members | ||
---|---|---|
argument_types | ||
typedef ObjectT | instance_type | |
typedef ReturnT | return_type |
struct Util::member_fn_ptr_traits< ReturnT(ObjectT::*)(ArgumentTs...) noexcept > |
Extracts the return value type, the class type the callable is member of, and the argument types of a callable type CallableT
which is a member function of some class. The extracted types are stored using type aliases return_type
and instance_type
and an alias of a tuple of types argument_types
.
Class Members | ||
---|---|---|
argument_types | ||
typedef ObjectT | instance_type | |
typedef ReturnT | return_type |
struct Util::member_fn_ptr_traits< ReturnT(ObjectT::*)(ArgumentTs...) const noexcept > |
Extracts the return value type, the class type the callable is member of, and the argument types of a callable type CallableT
which is a member function of some class. The extracted types are stored using type aliases return_type
and instance_type
and an alias of a tuple of types argument_types
.
Class Members | ||
---|---|---|
argument_types | ||
typedef ObjectT | instance_type | |
typedef ReturnT | return_type |
struct Util::member_fn_ptr_traits< ReturnT(ObjectT::*)(ArgumentTs...)> |
Extracts the return value type, the class type the callable is member of, and the argument types of a callable type CallableT
which is a member function of some class. The extracted types are stored using type aliases return_type
and instance_type
and an alias of a tuple of types argument_types
.
Class Members | ||
---|---|---|
argument_types | ||
typedef ObjectT | instance_type | |
typedef ReturnT | return_type |
struct Util::remove_first_from_tuple |
struct Util::remove_first_from_tuple< std::tuple< FirstElementT, ElementTs... > > |
struct Util::OffsetIndexSequence |
Holds an alias for a std::index_sequence where all indices are shifted by an offset.
IndexSequence | Indices passes as template arguments to std::index_sequence |
Offset | Offset added to all indices |
struct Util::OffsetIndexSequence< Offset, std::index_sequence< Indices... > > |
Holds an alias for a std::index_sequence where all indices are shifted by an offset.
IndexSequence | Indices passes as template arguments to std::index_sequence |
Offset | Offset added to all indices |
Class Members | ||
---|---|---|
type | Alias for offset index sequence. |
struct Util::RangeIndexSequence |
Holds an alias for a std::index_sequence spanning a certain range.
From | Start value the index sequency begins with |
To | Last value contained in the index sequence |
Class Members | ||
---|---|---|
typedef OffsetIndexSequence_t< From, make_index_sequence< To - From > > | type |
struct Util::VersionType |
using Util::argument_of_t = typedef typename member_fn_ptr_traits<CallableT>::argument_types |
using Util::ImageHistogramType = typedef std::array<unsigned long long, 256> |
using Util::ImageRGBHistogramType = typedef std::tuple<ImageHistogramType, ImageHistogramType, ImageHistogramType> |
using Util::instance_of_t = typedef typename member_fn_ptr_traits<CallableT>::instance_type |
using Util::OffsetIndexSequence_t = typedef typename OffsetIndexSequence<Offset, IndexSequence>::type |
Alias for type contained in OffsetIndexSequence
.
using Util::picoseconds = typedef std::chrono::duration<double, std::pico> |
using Util::RangeIndexSequence_t = typedef typename RangeIndexSequence<From, To>::type |
Alias for type contained in RangeIndexSequence
.
using Util::remove_first_from_tuple_t = typedef typename remove_first_from_tuple<TupleT>::type |
using Util::return_of_t = typedef typename member_fn_ptr_traits<CallableT>::return_type |
using Util::seconds = typedef std::chrono::duration<double> |
using Util::TextListIndexType = typedef size_t |
List index type of Util::TextListType
.
using Util::TextListType = typedef std::vector<TextType> |
using Util::TextRefType = typedef std::string_view |
Reference-to-string type of text-type parameters (DynExp::ParamsBase::Param)
using Util::TextType = typedef std::string |
String type of text-type parameters (DynExp::ParamsBase::Param)
using Util::TextValueListType = typedef std::vector<std::pair<TextType, ValueType> > |
Type of a list containing key-value pairs where key is a text of type Util::TextType
.
ValueType | Value-type assocaited with a text-type key |
|
strong |
void Util::ActivateWindow | ( | QWidget & | Widget | ) |
Renders a window active and brings it to the front.
Widget | representing a Qt (dialog) window |
Definition at line 229 of file QtUtil.cpp.
ImageHistogramType Util::ComputeIntensityHistogram | ( | const QImage & | Image | ) |
Computes an intensity (grayscale) histogram from a QImage object.
Image | Image to compute histogram from |
Definition at line 171 of file QtUtil.cpp.
ImageRGBHistogramType Util::ComputeRGBHistogram | ( | const QImage & | Image | ) |
Computes a RGB histogram from a QImage object.
Image | Image to compute histogram from |
Definition at line 186 of file QtUtil.cpp.
ImageHistogramType Util::ConvertRGBToIntensityHistogram | ( | const ImageRGBHistogramType & | RGBHistogram | ) |
Computes an intensity (grayscale) histogram from a RGB histogram.
RGBHistogram | RGB histogram to compute the grayscale histogram from |
Definition at line 204 of file QtUtil.cpp.
|
inline |
EventLogger & Util::EventLog | ( | ) |
This function holds a static EventLogger instance and returns a reference to it. DynExp uses only one EventLogger instance to log events from any thread. A local static object instead of a global object is employed to avoid initialization order problems.
std::string Util::ExceptionToStr | ( | const std::exception_ptr | ExceptionPtr | ) |
Returns the what() information of an exception derived from std::exception and stored in an exception pointer.
ExceptionPtr | Pointer to an exception derived from std::exception. |
ExceptionPtr
contains an exception. Empty string if ExceptionPtr
does not contain an exception. Placeholder string if the exception stored in ExceptionPtr
is not derived from std::exception. std::vector< std::complex< double > > Util::FFT | ( | const std::vector< std::complex< double >> & | Data, |
bool | InverseTransform = false |
||
) |
Computes the Fast Fourier Transform (FFT) a vector of complex values.
Data | Vector of complex values to be transformed |
InverseTransform | If true, the inverse FFT is computed. False is default. |
OverflowException | if Data contains more items than half of the maximal value size_t can represent. |
NotAvailableException | if GSL functions fail reserving memory. |
InvalidDataException | if GSL fails to perform the FFT on Data . |
|
inline |
void Util::ForwardException | ( | std::exception_ptr | e | ) |
Wraps the exception passed to the function in a ForwardedException and throws the ForwardedException. Does nothing if e is not an exception.
e | Pointer to an exception |
Definition at line 30 of file Exception.cpp.
std::vector< QDomNode > Util::GetChildDOMNodes | ( | const QDomElement & | Parent, |
const QString & | ChildTagName | ||
) |
Finds child nodes with a certain tag name.
Parent | Parent node whose child nodes are searched |
ChildTagName | Tag name to search for |
Util::InvalidDataException | is thrown when Parent is a null node. |
Definition at line 19 of file QtUtil.cpp.
const QLocale & Util::GetDefaultQtLocale | ( | ) |
Returns the default locale properties to be assigned to Qt widgets.
Definition at line 12 of file QtUtil.cpp.
QDomAttr Util::GetDOMAttribute | ( | const QDomElement & | Element, |
const QString & | AttributeName | ||
) |
Extracts an attribute from a DOM element.
Element | DOM element containing the attribute |
AttributeName | Name of the attribute to extract |
Util::InvalidDataException | is thrown if Element is null or if the requested attribute is invalid or does not exist. |
Definition at line 87 of file QtUtil.cpp.
QDomElement Util::GetSingleChildDOMElement | ( | const QDomElement & | Parent, |
const QString & | ChildTagName | ||
) |
Behaves like GetSingleChildDOMNode() but returns the node converted to a DOM element.
Parent | Refer to GetSingleChildDOMNode(). |
ChildTagName | Refer to GetSingleChildDOMNode(). |
Util::InvalidDataException | is additionally thrown if the matching DOM element is null. |
Definition at line 62 of file QtUtil.cpp.
QDomNode Util::GetSingleChildDOMNode | ( | const QDomElement & | Parent, |
const QString & | ChildTagName | ||
) |
Finds a single child node with a certain tag name.
Parent | Parent node whose child nodes are searched |
ChildTagName | Tag name to search for |
Util::InvalidDataException | is thrown when Parent is a null node or when multiple child nodes with matching tag name have been found. |
Util::NotFoundException | is thrown when not any matching node has been found. |
Definition at line 36 of file QtUtil.cpp.
std::string Util::GetStringFromDOMAttribute | ( | const QDomElement & | Element, |
const QString & | AttributeName | ||
) |
Behaves like GetDOMAttribute() but returns the text from the attribute.
Element | Refer to GetDOMAttribute(). |
AttributeName | Refer to GetDOMAttribute(). |
Definition at line 99 of file QtUtil.cpp.
std::string Util::GetStringFromDOMElement | ( | const QDomElement & | Parent, |
const QString & | ChildTagName | ||
) |
Behaves like GetSingleChildDOMElement() but returns the text from a DOM element.
Parent | Refer to GetSingleChildDOMNode(). |
ChildTagName | Refer to GetSingleChildDOMNode(). |
Definition at line 73 of file QtUtil.cpp.
std::string Util::GetTFromDOMAttribute | ( | const QDomElement & | Element, |
const QString & | AttributeName | ||
) |
Behaves like GetDOMAttribute() but returns the content from an attribute converted to a certain type using Util::StrToT().
T | Type to convert the attribute's content to |
Element | Refer to GetDOMAttribute(). |
AttributeName | Refer to GetDOMAttribute(). |
T
extracted from the matching attribute Definition at line 108 of file QtUtil.cpp.
std::string Util::GetTFromDOMElement | ( | const QDomElement & | Parent, |
const QString & | ChildTagName | ||
) |
Behaves like GetSingleChildDOMElement() but returns the content from a DOM element converted to a certain type using Util::StrToT().
T | Type to convert the DOM element's content to |
Parent | Refer to GetSingleChildDOMNode(). |
ChildTagName | Refer to GetSingleChildDOMNode(). |
T
extracted from the matching DOM element Definition at line 82 of file QtUtil.cpp.
QPolygonF Util::MakeCrossPolygon | ( | QPointF | Center, |
unsigned int | ArmLength | ||
) |
Returns a QPolygonF representing a cross-style marker.
Center | Center coordinate of the marker |
ArmLength | Length of one of the four arms of the cross. |
Definition at line 216 of file QtUtil.cpp.
ToT Util::NumToT | ( | const double | Value | ) |
Converts a value of a numeric type to a value of another numeric type checking the conversion for its bounds.
ToT | Numeric type to convert to |
FromT | Numeric type to convert from |
Value | Value to be converted |
OutOfRangeException | is thrown in case Value of type FromT does not fit into type ToT when both integral types, FromT and ToT , are either signed or unsigned. |
OverflowException | is thrown in case the conversion of Value from type FromT to type ToT would yield an overflow when one of the types, FromT or ToT , is signed and the respective other type is unsigned or when FromT is non-integral. |
UnderflowException | is thrown in case the conversion of Value from type FromT to type ToT would yield an underflow when one of the types, FromT or ToT , is signed and the respective other type is unsigned or when FromT is non-integral. |
|
inline |
Converts a value of a numeric type to a value of another numeric type checking the conversion for its bounds.
ToT | Numeric type to convert to |
FromT | Numeric type to convert from |
Value | Value to be converted |
OutOfRangeException | is thrown in case Value of type FromT does not fit into type ToT when both integral types, FromT and ToT , are either signed or unsigned. |
OverflowException | is thrown in case the conversion of Value from type FromT to type ToT would yield an overflow when one of the types, FromT or ToT , is signed and the respective other type is unsigned or when FromT is non-integral. |
UnderflowException | is thrown in case the conversion of Value from type FromT to type ToT would yield an underflow when one of the types, FromT or ToT , is signed and the respective other type is unsigned or when FromT is non-integral. |
std::ostream & Util::operator<< | ( | std::ostream & | stream, |
const Exception & | e | ||
) |
Writes a DynExp exception in a user-readable way to a stream.
stream | Stream to write to |
e | Exception to be logged to the stream |
Definition at line 17 of file Exception.cpp.
std::ostream& Util::operator<< | ( | std::ostream & | stream, |
const std::chrono::time_point< T > & | TimePoint | ||
) |
Formats a time point to a human-readable string describing the time in the current time zone and writes the string to a stream.
T | TimePoint's clock type |
stream | Stream to write to |
TimePoint | Time point to format and to write to stream |
std::strong_ordering Util::operator<=> | ( | const VersionType & | lhs, |
const VersionType & | rhs | ||
) |
std::vector<std::tuple<Ts...> > Util::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 column data into a vector of tuples.
...Ts | Data types of the columns |
CSVData | csv data to parse |
Delimiter | Delimiter character the csv data is separated with |
SkipLines | Amount of header lines (separated by '\n') to skip at the beginning of CSVData |
QString Util::PromptOpenFilePath | ( | QWidget * | Parent, |
const QString & | Title, | ||
const QString & | DefaultSuffix, | ||
const QString & | NameFilter, | ||
const QString & | InitialDirectory = "" |
||
) |
Opens a file dialog to ask the user to select a single existing file.
Parent | Parent widget of this dialog |
Title | Title used for the dialog window |
DefaultSuffix | Default file extension (e.g. ".dynp") |
NameFilter | Filter to select files (e.g. "DynExp project files (*.dynp)") |
InitialDirectory | Initial directory to show in the dile dialog. If empty, the default directory is specified. |
Definition at line 113 of file QtUtil.cpp.
QString Util::PromptSaveFilePath | ( | QWidget * | Parent, |
const QString & | Title, | ||
const QString & | DefaultSuffix, | ||
const QString & | NameFilter, | ||
const QString & | InitialDirectory = "" |
||
) |
Works as PromptOpenFilePath() but asks the user to select a single file which does not need to exist.
Parent | Refer to PromptOpenFilePath(). |
Title | Refer to PromptOpenFilePath(). |
DefaultSuffix | Refer to PromptOpenFilePath(). |
NameFilter | Refer to PromptOpenFilePath(). |
InitialDirectory | Refer to PromptOpenFilePath(). |
Definition at line 128 of file QtUtil.cpp.
QString Util::PromptSaveFilePathModule | ( | DynExp::QModuleWidget * | Parent, |
const QString & | Title, | ||
const QString & | DefaultSuffix, | ||
const QString & | NameFilter | ||
) |
Works as PromptOpenFilePath() but asks the user to select a single file which does not need to exist. Furthermore, the dialog automatically derives the initial directory using QModuleWidget::GetDataSaveDirectory() and sets the new global directory for saving data to the folder containing the selected file when the user accepts the dialog.
Parent | Refer to PromptOpenFilePath(). |
Title | Refer to PromptOpenFilePath(). |
DefaultSuffix | Refer to PromptOpenFilePath(). |
NameFilter | Refer to PromptOpenFilePath(). |
Definition at line 143 of file QtUtil.cpp.
QImage Util::QImageFromBlobData | ( | BlobDataType && | BlobData, |
int | Width, | ||
int | Height, | ||
int | BytesPerLine, | ||
QImage::Format | Format | ||
) |
Converts raw pixel data stored in a Util::BlobDataType object to a QImage transfering the ownership of BlobData's
content.
BlobData | Binary large object containing pixel data |
Width | Width of the image represented by BlobData in pixels |
Height | Height of the image represented by BlobData in pixels |
BytesPerLine | Number of bytes which represent a single row of pixels |
Format | Format of the pixel data stored in BlobData . |
Util::InvalidArgException | is thrown if any of Width , Height , or BytesPerLine is 0 or if Format is QImage::Format::Format_Invalid . |
Definition at line 153 of file QtUtil.cpp.
auto Util::QtEnumToTextValueList | ( | unsigned short | SkipEntriesFront = 0 , |
unsigned short | SkipEntriesEnd = 0 , |
||
unsigned short | SkipCharsFront = 0 , |
||
unsigned short | SkipCharsEnd = 0 |
||
) |
Returns a TextValueListType containing entries which reflect the items (names and values) of an enumeration registered to Qt's meta-object system.
EnumType | Enumeration type to extract entries from. The enumeration type has to be registered to Qt's meta-object system with the Q_ENUM macro. |
SkipEntriesFront | Number of enumeration entries to skip from the beginning of the enum declaration |
SkipEntriesEnd | Number of enumeration entries to skip from the end of the enum declaration |
SkipCharsFront | Number of characters to remove from the beginning of each enum entry's name |
SkipCharsEnd | Number of characters to remove from the end of each enum entry's name |
EnumType's
entries with entries skipped according to SkipEntriesFront
and SkipEntriesEnd
ans entry names trimmed according to SkipCharsFront
and SkipCharsEnd
. Util::OutOfRangeException | is thrown when SkipEntriesFront and SkipEntriesEnd are incompatible with the actual amount of enum entries in EnumType . |
std::string Util::ReadFromFile | ( | const QString & | Filename | ) |
Reads the entire content from a text file.
Filename | Full filename of the file to read from |
Util::FileIOErrorException | is thrown if the specified file cannot be opened. |
Definition at line 250 of file QtUtil.cpp.
std::string Util::ReadFromFile | ( | const std::filesystem::path & | Filename | ) |
Reads the entire content from a text file.
Filename | Full filename of the file to read from |
Util::FileIOErrorException | is thrown if the specified file cannot be opened. |
Definition at line 267 of file QtUtil.cpp.
std::string Util::ReadFromFile | ( | const std::string & | Filename | ) |
Reads the entire content from a text file.
Filename | Full filename of the file to read from |
Util::FileIOErrorException | is thrown if the specified file cannot be opened. |
Definition at line 262 of file QtUtil.cpp.
|
inline |
bool Util::SaveToFile | ( | const QString & | Filename, |
std::string_view | Text | ||
) |
Saves a std::string_view to a file (using QFile). Creates a new file or truncates an existing file's content.
Filename | Path of the file to write to. |
Text | Content to be written. |
Definition at line 236 of file QtUtil.cpp.
T Util::StrToT | ( | const std::string & | String | ) |
Converts a std::string to a value of type T
using operator<< of std::stringstream.
T | Type of the value the string should be converted to |
String | String to convert |
T
. InvalidDataException | is thrown in case of an incompatible conversion. |
std::string Util::ToLower | ( | std::string_view | Str | ) |
|
inline |
|
inline |
std::string Util::ToStr | ( | const std::chrono::time_point< T > & | TimePoint | ) |
std::string Util::ToStr | ( | const T & | Value, |
int | Precision = -1 |
||
) |
Converts a (numeric) value of type T
to a std::string using operator<< of std::stringstream.
T | Type of the value to convert |
Value | Value to convert |
Precision | Fixed precision of the numeric conversion for Precision >= 0. For any Precision < 0 (default) the precision is not set. |
Value
converted to a string.
|
inline |
|
inline |
Converts a program version to a string in the form specified by VersionType
.
Version | Program version to convert |
|
inline |
Returns a string describing the physical unit associated with type T
. For example, if T
is std::chrono::milliseconds, the function returns the string "ms".
T | Type which has a physical unit associated with |
|
inline |
Returns a string describing the physical unit associated with type T
. For example, if T
is std::chrono::milliseconds, the function returns the string "ms".
T | Type which has a physical unit associated with |
|
inline |
Returns a string describing the physical unit associated with type T
. For example, if T
is std::chrono::milliseconds, the function returns the string "ms".
T | Type which has a physical unit associated with |
|
inline |
Returns a string describing the physical unit associated with type T
. For example, if T
is std::chrono::milliseconds, the function returns the string "ms".
T | Type which has a physical unit associated with |
|
inline |
Returns a string describing the physical unit associated with type T
. For example, if T
is std::chrono::milliseconds, the function returns the string "ms".
T | Type which has a physical unit associated with |
|
inline |
Returns a string describing the physical unit associated with type T
. For example, if T
is std::chrono::milliseconds, the function returns the string "ms".
T | Type which has a physical unit associated with |
|
inline |
Returns a string describing the physical unit associated with type T
. For example, if T
is std::chrono::milliseconds, the function returns the string "ms".
T | Type which has a physical unit associated with |
|
inline |
VersionType Util::VersionFromString | ( | std::string_view | Str | ) |
Extracts a program version from a string.
Str | String containing a programm version in the form specified by VersionType |
VersionType
object containing the extracted program version InvalidDataException | if Str does not contain a valid version number. |
|
inlineconstexpr |
Value type of is_contained_in
.