ORE Studio 0.0.4
Loading...
Searching...
No Matches
Public Member Functions | List of all members
system_flags_service Class Reference

Service for accessing well-known system flags with type-safe methods. More...

#include <system_flags_service.hpp>

Collaboration diagram for system_flags_service:
Collaboration graph

Public Member Functions

 system_flags_service (database::context ctx)
 Constructs a system_flags_service.
 
void refresh ()
 Refreshes the cache by reading all system flags from the database.
 
const domain::system_flags_cachecache () const
 Gets a const reference to the cached system flags.
 
bool is_enabled (domain::system_flag flag) const
 Checks if a system flag is enabled (from cache).
 
void set_enabled (domain::system_flag flag, bool enabled, std::string_view recorded_by)
 Sets a system flag's enabled state.
 
bool is_bootstrap_mode_enabled () const
 Checks if the system is in bootstrap mode (from cache).
 
void set_bootstrap_mode (bool enabled, std::string_view recorded_by)
 Sets the bootstrap mode state.
 
bool is_user_signups_enabled () const
 Checks if user self-registration (signups) is enabled (from cache).
 
void set_user_signups (bool enabled, std::string_view recorded_by)
 Sets the user signups state.
 

Detailed Description

Service for accessing well-known system flags with type-safe methods.

This service provides a typed interface for querying and modifying system flags. Unlike feature_flags_service which works with arbitrary flag names, this service only handles the predefined system flags enumerated in domain::system_flag.

The service maintains an internal cache of flag values for fast access. The cache is populated on first access or via explicit refresh(). Write operations automatically update the cache after persisting to database.

The service wraps feature_flags_service internally and translates between the system_flag enum and the underlying string-based storage.

Constructor & Destructor Documentation

◆ system_flags_service()

Constructs a system_flags_service.

Parameters
ctxThe database context to be used by the underlying repository.

Member Function Documentation

◆ refresh()

void refresh ( )

Refreshes the cache by reading all system flags from the database.

Call this at startup after system_flags_seeder has run, or when you need to ensure the cache reflects the latest database state.

Here is the caller graph for this function:

◆ cache()

const domain::system_flags_cache & cache ( ) const

Gets a const reference to the cached system flags.

This provides fast, read-only access to the cached flag values without database queries. The cache must be populated via refresh() first.

Returns
Const reference to the cached system flags.

◆ is_enabled()

bool is_enabled ( domain::system_flag  flag) const

Checks if a system flag is enabled (from cache).

Returns the cached value. Call refresh() first to populate the cache.

Parameters
flagThe system flag to check.
Returns
true if the flag is enabled, false otherwise.

◆ set_enabled()

void set_enabled ( domain::system_flag  flag,
bool  enabled,
std::string_view  recorded_by 
)

Sets a system flag's enabled state.

Persists to database and updates the cache.

Parameters
flagThe system flag to modify.
enabledThe new enabled state.
recorded_byUsername of the user making the change.
Here is the caller graph for this function:

◆ is_bootstrap_mode_enabled()

bool is_bootstrap_mode_enabled ( ) const

Checks if the system is in bootstrap mode (from cache).

Returns
true if bootstrap mode is enabled, false otherwise.
Here is the caller graph for this function:

◆ set_bootstrap_mode()

void set_bootstrap_mode ( bool  enabled,
std::string_view  recorded_by 
)

Sets the bootstrap mode state.

Persists to database and updates the cache.

Parameters
enabledThe new bootstrap mode state.
recorded_byUsername of the user making the change.
Here is the caller graph for this function:

◆ is_user_signups_enabled()

bool is_user_signups_enabled ( ) const

Checks if user self-registration (signups) is enabled (from cache).

Returns
true if user signups are enabled, false otherwise.

◆ set_user_signups()

void set_user_signups ( bool  enabled,
std::string_view  recorded_by 
)

Sets the user signups state.

Persists to database and updates the cache.

Parameters
enabledThe new user signups state.
recorded_byUsername of the user making the change.