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 uint64_t data_type;
46 typedef int64_t sdata_type;
58 static constexpr size_t npos = std::numeric_limits<size_type>::max();
59
66 template<typename T>
67 constexpr std::enable_if_t<(sizeof(T) <= sizeof(data_type)), data_type> toDataType(T value) const
68 {
69 if constexpr (std::is_pointer_v<T>)
70 {
71 return reinterpret_cast<data_type>(value);// Safe for pointers
72 }
73 else
74 {
75 return static_cast<data_type>(value);// Safe for integral and smaller types
76 }
77 }
78
85 template<typename T>
86 constexpr std::enable_if_t<(sizeof(T) <= sizeof(data_type)), T> fromDataType(data_type value) const
87 {
88 if constexpr (std::is_pointer_v<T>)
89 {
90 return reinterpret_cast<T>(value);
91 }
92 else
93 {
94 return static_cast<T>(value);
95 }
96 }
97};
98
99}// 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
uint64_t data_type
Type used for containing a single data element which is the largest integer.
Definition InformationBase.h:42
constexpr std::enable_if_t<(sizeof(T)<=sizeof(data_type)), T > fromDataType(data_type value) const
Casts a data_type value to a given type.
Definition InformationBase.h:86
constexpr std::enable_if_t<(sizeof(T)<=sizeof(data_type)), data_type > toDataType(T value) const
Casts any type to a data_type value.
Definition InformationBase.h:67
TVector< InformationBase * > Vector
Vector for containing different information base derived classes.
Definition InformationBase.h:54
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
int64_t sdata_type
Type used for containing a single data element which is the largest signed integer.
Definition InformationBase.h:46
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:50
Counted vector having additional methods and operators for ease of usage.
Definition TVector.h:25
#define _GII_CLASS
Definition gii/global.h:38
Definition Application.h:10