Loading...
Searching...
No Matches
ml::CustomFlaggable< CustomFlagEnum > Class Template Reference

Provides enum-keyed boolean flag storage for a single flag set. More...

#include <CustomFlaggable.h>

Public Member Functions

template<typename T = CustomFlagEnum>
std::enable_if_t<!std::is_void_v< T >, bool > checkFlag (T state) const
 Return the current value of a flag.
template<typename T = CustomFlagEnum>
std::enable_if_t<!std::is_void_v< T > > disableFlag (T state)
 Set a flag to false.
template<typename T = CustomFlagEnum>
std::enable_if_t<!std::is_void_v< T > > enableFlag (T state)
 Set a flag to true.
template<typename T = CustomFlagEnum>
std::enable_if_t<!std::is_void_v< T > > setFlag (T state, bool status)
 Set a flag to an explicit value.
template<typename T = CustomFlagEnum>
std::enable_if_t<!std::is_void_v< T > > toggleFlag (T state)
 Flip a flag between true and false.

Detailed Description

template<typename CustomFlagEnum>
class ml::CustomFlaggable< CustomFlagEnum >

Provides enum-keyed boolean flag storage for a single flag set.

CustomFlaggale<CustomFlagEnum> maintains an unordered_map from enum values to bool, exposing a consistent API for querying and mutating those flags. It is the low-level storage layer used by MultiCustomFlaggable to hold each individual flag set gathered from a component's manifest and traits.

All methods are guarded by std::enable_if so they exist in the overload set only when CustomFlagEnum is not void. This allows CustomFlaggale to be safely used as a base class even when the manifest declares no flags — see the void specialization below.

Typical use (via ComponentWith)

You will rarely instantiate CustomFlaggale directly. Instead, declare a Flags enum in your manifest and call the flag methods on your component:

struct MyManifest {
enum class Flags { Selected, Hovered, Disabled };
};
class MyWidget : public ml::ComponentWith<MyManifest> {};
MyWidget w;
w.enableFlag(MyManifest::Flags::Selected);
if (w.checkFlag(MyManifest::Flags::Selected)) { ... }
w.disableFlag(MyManifest::Flags::Selected);
Component< M, Traits... > ComponentWith
Alias for Component<M, Traits...>.
Definition Component.h:150
Template Parameters
CustomFlagEnumAn enum class type used as flag keys. Use void when no custom flags are needed (selects the no-op specialization).
See also
MultiCustomFlaggable, Flaggable, ComponentCore

Definition at line 53 of file CustomFlaggable.h.

Member Function Documentation

◆ checkFlag()

template<typename CustomFlagEnum>
template<typename T = CustomFlagEnum>
std::enable_if_t<!std::is_void_v< T >, bool > ml::CustomFlaggable< CustomFlagEnum >::checkFlag ( T state) const

Return the current value of a flag.

Returns false for any flag that has never been explicitly set.

Parameters
stateThe flag to query.
Returns
true if the flag is set; false otherwise.

◆ disableFlag()

template<typename CustomFlagEnum>
template<typename T = CustomFlagEnum>
std::enable_if_t<!std::is_void_v< T > > ml::CustomFlaggable< CustomFlagEnum >::disableFlag ( T state)

Set a flag to false.

Parameters
stateThe flag to disable.

◆ enableFlag()

template<typename CustomFlagEnum>
template<typename T = CustomFlagEnum>
std::enable_if_t<!std::is_void_v< T > > ml::CustomFlaggable< CustomFlagEnum >::enableFlag ( T state)

Set a flag to true.

Parameters
stateThe flag to enable.

◆ setFlag()

template<typename CustomFlagEnum>
template<typename T = CustomFlagEnum>
std::enable_if_t<!std::is_void_v< T > > ml::CustomFlaggable< CustomFlagEnum >::setFlag ( T state,
bool status )

Set a flag to an explicit value.

Parameters
stateThe flag to modify.
statustrue to enable the flag, false to disable it.

◆ toggleFlag()

template<typename CustomFlagEnum>
template<typename T = CustomFlagEnum>
std::enable_if_t<!std::is_void_v< T > > ml::CustomFlaggable< CustomFlagEnum >::toggleFlag ( T state)

Flip a flag between true and false.

Parameters
stateThe flag to toggle.

The documentation for this class was generated from the following file: