|  | CuteHMI - CuteHMI (CuteHMI.2)
    | 
Initializer template. More...
#include <cutehmi/Initializer.hpp>
 
  
| Public Member Functions | |
| Initializer (std::function< void()> init, std::function< void()> deinit=nullptr) | |
| Constructor.  More... | |
| Protected Member Functions | |
| ~Initializer () | |
|  Protected Member Functions inherited from cutehmi::NonCopyable | |
| NonCopyable ()=default | |
| NonCopyable (NonCopyable &&other)=default | |
| ~NonCopyable ()=default | |
| NonCopyable & | operator= (NonCopyable &&other)=default | 
Initializer template.
Initializer can be used to initialize an extension. This is achieved by subclassing the template and creating a global instance of a derived class, which is a subject of static initialization. This relies on following C++ principle.
"If a variable with static storage duration has initialization or a destructor with side effects, it shall not be eliminated even if it appears to be unused, except that a class object or its copy/move may be eliminated as specified in 11.9.5."
 Initializer counts its own references and runs initialization and deinitialization code only once - for the first constructed and last destroyed instance.
| cutehmi::Initializer< DERIVED >::Initializer | ( | std::function< void()> | init, | 
| std::function< void()> | deinit = nullptr | ||
| ) | 
Constructor.
| init | initialization code. Typically a lambda expression can be passed for initialization code. | 
| deinit | deinitialization code or nullptrif there is no deinitialization. | 
| 
 | protected |