Scanframe Modular Application 0.1.0
Loading...
Searching...
No Matches
InformationBase.h
Go to the documentation of this file.
1#pragma once
2#include <gii/global.h>
3#include <limits>
4#include <misc/gen/TVector.h>
5
6namespace sf
7{
8
13{
14 public:
18 virtual ~InformationBase() = default;
19};
20
25{
26 public:
30 typedef unsigned long long id_type;
34 typedef int32_t flags_type;
38 typedef size_t size_type;
42 typedef ssize_t ssize_type;
46 typedef uintptr_t data_type;
50 typedef intptr_t sdata_type;
62 static constexpr size_t npos = std::numeric_limits<size_type>::max();
63
70 template<typename T>
71 static constexpr std::enable_if_t<(sizeof(T) <= sizeof(data_type)), data_type> toDataType(T value)
72 {
73 if constexpr (std::is_pointer_v<T>)
74 {
75 return reinterpret_cast<data_type>(value);
76 }
77 else if constexpr (std::is_arithmetic_v<T> || std::is_enum_v<T>)
78 {
79 return static_cast<data_type>(value);
80 }
81 }
82
90 template<typename T>
91 static constexpr std::enable_if_t<(sizeof(T) <= sizeof(data_type) || std::is_reference_v<T>), T> fromDataType(data_type value)
92 {
93 if constexpr (std::is_reference_v<T>)
94 {
95 return *reinterpret_cast<std::remove_reference_t<T>*>(value);
96 }
97 else if constexpr (std::is_pointer_v<T>)
98 {
99 return reinterpret_cast<T>(value);
100 }
101 else if constexpr (std::is_arithmetic_v<T> || std::is_enum_v<T>)
102 {
103 return static_cast<T>(value);
104 }
105 }
106};
107
108}// namespace sf
Base class for all generic information objects to be able to put them in a typed list together.
Definition InformationBase.h:13
virtual ~InformationBase()=default
Virtual destructor so derived classes can be destroyed by a pointer of this type.
Base class for all generic information objects to be able to put them in a typed list together.
Definition InformationBase.h:25
ssize_t ssize_type
Same as size_type but a signed version.
Definition InformationBase.h:42
static constexpr std::enable_if_t<(sizeof(T)<=sizeof(data_type)||std::is_reference_v< T >), T > fromDataType(data_type value)
Casts a data_type value to a given type. Reference types are also possible since they are the same si...
Definition InformationBase.h:91
TVector< InformationBase * > Vector
Vector for containing different information base derived classes.
Definition InformationBase.h:58
uintptr_t data_type
Type used for containing a single data element which is the largest integer.
Definition InformationBase.h:46
static constexpr std::enable_if_t<(sizeof(T)<=sizeof(data_type)), data_type > toDataType(T value)
Casts any type to a data_type value.
Definition InformationBase.h:71
unsigned long long id_type
Type used for the identifying integer (64-bits).
Definition InformationBase.h:30
size_t size_type
Type used for size of vectors.
Definition InformationBase.h:38
intptr_t sdata_type
Type used for containing a single data element which is the largest signed integer.
Definition InformationBase.h:50
int32_t flags_type
Type used for the flag integer.
Definition InformationBase.h:34
TVector< id_type > IdVector
Vector for lists of information ID's.
Definition InformationBase.h:54
Counted vector having additional methods and operators for ease of usage. This template class extends...
Definition TVector.h:19
#define _GII_CLASS
Definition gii/global.h:38
Definition Application.h:10