1#ifndef ARION_TYPE_UTILS_HPP
2#define ARION_TYPE_UTILS_HPP
9#define COMMON_TYPE_PRIORITY 0
10#define OS_BASE_TYPE_PRIORITY 1
11#define OS_STRUCT_FACTORY_PRIORITY 2
12#define OS_STRUCT_TYPE_PRIORITY 3
13#define OS_VARIABLE_STRUCT_TYPE_PRIORITY 4
56 virtual std::string
str(std::shared_ptr<arion::Arion>
arion, uint64_t val);
88 this->initializers.emplace_back(priority, fn);
96 this->initialized =
true;
97 std::sort(this->initializers.begin(), this->initializers.end(),
98 [](
auto &a,
auto &b) { return std::get<0>(a) < std::get<0>(b); });
121#define ARION_REGISTER_KERNEL_TYPE(VAR, TYPE, PRIORITY) \
122 static_assert(std::is_same_v<decltype(VAR), std::shared_ptr<TYPE>>, \
123 "ARION_REGISTER_KERNEL_TYPE expects shared_ptr<TYPE>"); \
124 static struct KernelTypeRegistrar_##VAR \
126 KernelTypeRegistrar_##VAR() \
128 KernelTypeRegistry::instance().register_type(PRIORITY, [] { VAR = std::make_shared<TYPE>(); }); \
130 } KernelTypeRegistrarInstance_##VAR;
155 std::string
str(std::shared_ptr<arion::Arion>
arion, uint64_t val)
override;
168extern std::shared_ptr<IntType>
INT_TYPE;
184 std::string
str(std::shared_ptr<arion::Arion>
arion, uint64_t val)
override;
Class for data types represented as a set of bit flags or discrete symbolic constants.
Definition type_utils.hpp:134
std::map< uint64_t, std::string > flag_map
Map linking raw integer flag values to their string names (e.g., 0x1 to "MAP_SHARED").
Definition type_utils.hpp:137
FlagType(std::string name, std::map< uint64_t, std::string > flag_map)
Definition type_utils.hpp:145
std::string str(std::shared_ptr< arion::Arion > arion, uint64_t val) override
Concrete type representing a generic integer value.
Definition type_utils.hpp:160
IntType()
Definition type_utils.hpp:165
Singleton class responsible for managing the initialization order of all kernel type objects.
Definition type_utils.hpp:63
bool is_initialized()
Definition type_utils.hpp:108
void register_type(uint16_t priority, InitFn fn)
Definition type_utils.hpp:86
static KernelTypeRegistry & instance()
Definition type_utils.hpp:75
std::vector< std::tuple< int, InitFn > > initializers
List of initialization functions paired with their priority.
Definition type_utils.hpp:66
void init_types()
Definition type_utils.hpp:94
bool initialized
Flag indicating if initialization has been completed.
Definition type_utils.hpp:68
Abstract base class for all kernel-related data types used for visualization/logging.
Definition type_utils.hpp:27
arion::LOG_COLOR color
The log color associated with this data type for display.
Definition type_utils.hpp:32
std::string name
Display name of the data type (e.g., "File descriptor").
Definition type_utils.hpp:30
virtual std::string str(std::shared_ptr< arion::Arion > arion, uint64_t val)
KernelType(std::string name, arion::LOG_COLOR color=arion::LOG_COLOR::DEFAULT)
Definition type_utils.hpp:40
arion::LOG_COLOR get_color()
virtual ~KernelType()=default
Virtual destructor to allow polymorphic deletion.
Concrete type representing a memory address pointing to a null-terminated string.
Definition type_utils.hpp:172
RawStringType()
Definition type_utils.hpp:177
std::string str(std::shared_ptr< arion::Arion > arion, uint64_t val) override
Definition type_utils.hpp:23
std::shared_ptr< RawStringType > RAW_STRING_TYPE
Shared pointer to the singleton instance of RawStringType.
std::shared_ptr< IntType > INT_TYPE
Shared pointer to the singleton instance of IntType.
std::function< void()> InitFn
Function type used for initializing a kernel type.
Definition type_utils.hpp:60
Definition arch_x86-64.hpp:11
LOG_COLOR
These colors can be used for logging.
Definition logger.hpp:22
@ DEFAULT
Default foreground color.
Definition logger.hpp:23