Stroika Library 3.0d16
 
Loading...
Searching...
No Matches
ModuleInit.h
1/*
2 * Copyright(c) Sophist Solutions, Inc. 1990-2025. All rights reserved
3 */
4#ifndef _Stroika_Foundation_Execution_ModuleInit_h_
5#define _Stroika_Foundation_Execution_ModuleInit_h_ 1
6
7#include "Stroika/Foundation/StroikaPreComp.h"
8
9#include <cstdint>
10
11#include "Stroika/Foundation/Common/Common.h"
12#include "Stroika/Foundation/Memory/Common.h"
13
14/**
15 */
16
18
19 class [[deprecated ("Since Stroika v3.0d4 - use call_once or static inline")]] ModuleDependency {
20 public:
21 ModuleDependency (void (*start) (), void (*end) ());
22 ~ModuleDependency ();
23
24 private:
25 void (*fEnd_) ();
26 };
27
28 template <typename MODULE_DATA>
29 class [[deprecated ("Since Stroika v3.0d4 - use call_once or static inline")]] ModuleInitializer {
30 public:
31 /**
32 */
33 ModuleInitializer ();
34 ~ModuleInitializer ();
35
36 public:
37 /**
38 */
39 static void Start ();
40
41 public:
42 /**
43 */
44 static void End ();
45
46 public:
47 /**
48 */
49 static MODULE_DATA& Actual ();
50
51 public:
52 /**
53 * In order for one module to depend on another, the other module calls this modules 'GetDependency' method, and stores
54 * the ModuleDependency object in its ModuleInitializer. That way - this dependency gets started before, and gets terminated after
55 * the referring dependent module.
56 */
57 static ModuleDependency GetDependency ();
58
59 private:
60 alignas (alignof (MODULE_DATA)) static byte sActualModuleInitializer_Storage_[sizeof (MODULE_DATA)]; // avoid actual memory allocation call - since only one of these
61 static inline uint16_t sInitCnt_{0};
62 };
63
64}
65
66/*
67 ********************************************************************************
68 ***************************** Implementation Details ***************************
69 ********************************************************************************
70 */
71#include "ModuleInit.inl"
72
73#endif /*_Stroika_Foundation_Execution_ModuleInit_h_*/
CONTAINER::value_type * End(CONTAINER &c)
For a contiguous container (such as a vector or basic_string) - find the pointer to the end of the co...
CONTAINER::value_type * Start(CONTAINER &c)
For a contiguous container (such as a vector or basic_string) - find the pointer to the start of the ...