ALib C++ Framework
by
Library Version: 2605 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
main.cpp
Go to the documentation of this file.
1// #################################################################################################
2// ALib C++ Framework
3// App Sample
4//
5// Copyright 2025 A-Worx GmbH, Germany
6// Published under Boost Software License (a free software license, see LICENSE.txt)
7// #################################################################################################
8/// \file
9#include "ALib.App.H"
10#if !DOXYGEN // otherwise this sample would be seen in the ALib dox
11
12#include "sample.hpp"
13
14
15//#define TEST_MINIMAL_APP
16#define TEST_MINIMAL_APP_WITH_CUSTOM_METHOD
17
18//------ A minimal pure App used with dox. Should be tested after changes ------
19#if defined(TEST_MINIMAL_APP)
20DOX_MARKER( [DOX_APP_MINIMAL_APP])
21struct MyApp : alib::app::App {
22
23 void onRun() override { cOut->Add("Hello ALib App!"); };
24};
25
26int main( int argc, const char** argv) {
27 return MyApp().Main(argc, argv);
28}
29DOX_MARKER( [DOX_APP_MINIMAL_APP])
30
31//------- A minimal pure App with custom method. Should be tested after changes --------
32
33#elif defined(TEST_MINIMAL_APP_WITH_CUSTOM_METHOD)
34DOX_MARKER( [DOX_APP_MINIMAL_APP_WITH_CUSTOM_METHOD])
35// My derived app
36struct MyApp : public alib::app::App {
37
38 // Define an own states enumeration with one entry. The value of the state element
39 // defines the execution order. Here, we use RunStart as the reference. Thus the state
40 // will be executed after RunStart and before Run.
41 enum class MyStates { WarmUp = int(States::RunStart) + 1 };
42
43 // Constructor: Inserts the custom state
44 MyApp() {
45 machine.Program.Add<MyApp, &MyApp::WarmUpStep>(( MyStates::WarmUp ) );
46 }
47
48 // The method associated with the custom state
49 virtual void WarmUpStep() {
50 cOut->Add("I'm still warming up");
51 }
52
53 // Overriding the original run method
54 void onRun() override {
55 cOut->Add("Hello ALib App!");
56 }
57};
58
59// C++ main() calls App::Main and returns its exit code
60int main( int argc, const char** argv) {
61 return MyApp().Main(argc, argv);
62}
63DOX_MARKER( [DOX_APP_MINIMAL_APP_WITH_CUSTOM_METHOD])
64
65
66///---------------- The real sample ----------------
67#else
68int main( int argc, const char** argv) {
69
70 return Sample().Main(argc, argv);
71}
72
73#endif //TEST_MINIMAL_APP
74
75
76#endif // !DOXYGEN
77
virtual void onRun()
Definition app.cpp:594
virtual int Main(int argc, const char **argv, const wchar_t **argvw=nullptr)
Definition app.cpp:45