Loading...
Searching...
No Matches
ml::MultiCustomFlaggable< Enums > Class Template Reference

Aggregates flag stores for multiple enum types into one class. More...

#include <MultiCustomFlaggable.h>

Inheritance diagram for ml::MultiCustomFlaggable< Enums >:

Public Member Functions

bool checkFlag (Enums flag) const
 Return true if flag is set, false if unset or never written.
void disableFlag (Enums flag)
 Set flag to false.
void enableFlag (Enums flag)
 Set flag to true.
void setFlag (Enums flag, bool value)
 Set flag to an explicit value.
void toggleFlag (Enums flag)
 Flip flag between true and false.

Detailed Description

template<typename... Enums>
class ml::MultiCustomFlaggable< Enums >

Aggregates flag stores for multiple enum types into one class.

MultiCustomFlaggable<Enums...> inherits one SingleFlaggable per enum in the pack and lifts all their methods into a single overload set via using declarations. This allows a component to call a single checkFlag overloaded on enum type rather than casting to the right base.

It is instantiated by GatherFlags, which collects all Flag enums from a component's manifest and from every trait mixed in via ComponentWith. The result is a single base class that holds all custom flag storage for the component.

Example (automatic — no user action required)

// Given:
struct MyManifest { enum class Flag { Selected }; };
class Draggable : public TraitWith<DraggableManifest> {}; // Flag::DRAGGING
class MyWidget : public ml::ComponentWith<MyManifest, Draggable> {};
MyWidget w;
w.enableFlag(MyManifest::Flag::Selected); // stored in SingleFlaggable<MyManifest::Flag>
w.enableFlag(DraggableManifest::Flag::DRAGGING); // stored in SingleFlaggable<DraggableManifest::Flag>
@ DRAGGING
Set while the user is actively dragging.
Definition Draggable.h:37
Component< M, Traits... > ComponentWith
Alias for Component<M, Traits...>.
Definition Component.h:150
Flag
System-level boolean flags available on every ml::Core object.
Definition Flag.h:60
Template Parameters
EnumsZero or more enum class types, one per flag set. The empty specialization (MultiCustomFlaggable<>) is used when no custom flags are declared.
See also
SingleFlaggable, GatherFlags, ComponentCore

MultiCustomFlaggable.

Definition at line 94 of file MultiCustomFlaggable.h.

Member Function Documentation

◆ checkFlag()

bool ml::SingleFlaggable< Enums >::checkFlag ( Enums flag) const
inlineinherited

Return true if flag is set, false if unset or never written.

Definition at line 44 of file MultiCustomFlaggable.h.

◆ disableFlag()

void ml::SingleFlaggable< Enums >::disableFlag ( Enums flag)
inlineinherited

Set flag to false.

Definition at line 41 of file MultiCustomFlaggable.h.

◆ enableFlag()

void ml::SingleFlaggable< Enums >::enableFlag ( Enums flag)
inlineinherited

Set flag to true.

Definition at line 38 of file MultiCustomFlaggable.h.

◆ setFlag()

void ml::SingleFlaggable< Enums >::setFlag ( Enums flag,
bool value )
inlineinherited

Set flag to an explicit value.

Definition at line 47 of file MultiCustomFlaggable.h.

◆ toggleFlag()

void ml::SingleFlaggable< Enums >::toggleFlag ( Enums flag)
inlineinherited

Flip flag between true and false.

Definition at line 50 of file MultiCustomFlaggable.h.


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