Skip to content

AUI_DO_ONCE#

Executes following function call or {} block once per program execution

Header:#include <AUI/Util/kAUI.h>
CMake:aui_link(my_target PUBLIC aui::core)

Definition#

#define AUI_DO_ONCE if(static bool _aui_once = false; (!_aui_once && (_aui_once = true)))

Detailed Description#

Guarantees that the following code block will be executed only once per application execution.

without with
static bool done = false;
if (!done) {
    done = true;
    std::printf("Only once!");
}
AUI_DO_ONCE {
    std::printf("Only once!");
}

Examples#

examples/ui/views/src/ExampleWindow.cpp

Views Example - All-in-one views building example.

                                    }
                                }),
                            _new<ASpacerExpanding>(),
                          },
                          AUI_DECLARATIVE_FOR(i, *state->colors, AWordWrappingLayout) {
                              return Horizontal {
                                  _new<ALabel>(i.toString()) AUI_WITH_STYLE {
                                      TextColor { i.readableBlackOrWhite() },
                                  }
                              } AUI_WITH_STYLE {