yaze 0.3.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
yaze::cli::resources::CommandContext Class Reference

Encapsulates common context for CLI command execution. More...

#include <command_context.h>

Collaboration diagram for yaze::cli::resources::CommandContext:

Classes

struct  Config
 Configuration for command context. More...
 

Public Member Functions

 CommandContext (const Config &config)
 
 ~CommandContext ()
 
absl::Status Initialize ()
 Initialize the context and load ROM if needed.
 
absl::StatusOr< Rom * > GetRom ()
 Get the ROM instance (loads if not already loaded)
 
emu::debug::SymbolProviderGetSymbolProvider ()
 Get the SymbolProvider instance.
 
const std::string & GetFormat () const
 Get the output format ("json" or "text")
 
bool IsVerbose () const
 Check if verbose mode is enabled.
 
absl::Status EnsureLabelsLoaded (Rom *rom)
 Ensure resource labels are loaded.
 
project::YazeProjectGetProjectContext ()
 Returns loaded project context when –project-context was used.
 

Private Member Functions

absl::Status ApplyProjectRuntimeContext ()
 
void RestoreProjectRuntimeContext ()
 

Private Attributes

Config config_
 
Rom rom_storage_
 
Romactive_rom_
 
emu::debug::SymbolProvider symbol_provider_
 
std::optional< project::YazeProjectloaded_project_
 
std::optional< core::FeatureFlags::Flagsprevious_feature_flags_
 
std::optional< zelda3::CustomObjectManager::Stateprevious_custom_object_state_
 
bool project_runtime_applied_ = false
 
bool initialized_ = false
 

Detailed Description

Encapsulates common context for CLI command execution.

Provides unified ROM loading, argument parsing, and common options management to reduce duplication across command handlers.

Definition at line 27 of file command_context.h.

Constructor & Destructor Documentation

◆ CommandContext()

yaze::cli::resources::CommandContext::CommandContext ( const Config & config)
explicit

Definition at line 41 of file command_context.cc.

◆ ~CommandContext()

yaze::cli::resources::CommandContext::~CommandContext ( )

Definition at line 43 of file command_context.cc.

References RestoreProjectRuntimeContext().

Here is the call graph for this function:

Member Function Documentation

◆ Initialize()

◆ GetRom()

absl::StatusOr< Rom * > yaze::cli::resources::CommandContext::GetRom ( )

Get the ROM instance (loads if not already loaded)

Definition at line 121 of file command_context.cc.

References active_rom_, Initialize(), and initialized_.

Referenced by yaze::cli::resources::CommandHandler::Run().

Here is the call graph for this function:

◆ GetSymbolProvider()

emu::debug::SymbolProvider * yaze::cli::resources::CommandContext::GetSymbolProvider ( )

Get the SymbolProvider instance.

Definition at line 136 of file command_context.cc.

References Initialize(), initialized_, and symbol_provider_.

Referenced by yaze::cli::resources::CommandHandler::Run().

Here is the call graph for this function:

◆ GetFormat()

const std::string & yaze::cli::resources::CommandContext::GetFormat ( ) const
inline

Get the output format ("json" or "text")

Definition at line 65 of file command_context.h.

References config_, and yaze::cli::resources::CommandContext::Config::format.

◆ IsVerbose()

bool yaze::cli::resources::CommandContext::IsVerbose ( ) const
inline

Check if verbose mode is enabled.

Definition at line 70 of file command_context.h.

References config_, and yaze::cli::resources::CommandContext::Config::verbose.

◆ EnsureLabelsLoaded()

◆ GetProjectContext()

project::YazeProject * yaze::cli::resources::CommandContext::GetProjectContext ( )
inline

Returns loaded project context when –project-context was used.

Definition at line 80 of file command_context.h.

References loaded_project_.

Referenced by yaze::cli::resources::CommandHandler::Run().

◆ ApplyProjectRuntimeContext()

◆ RestoreProjectRuntimeContext()

Member Data Documentation

◆ config_

Config yaze::cli::resources::CommandContext::config_
private

Definition at line 88 of file command_context.h.

Referenced by ApplyProjectRuntimeContext(), GetFormat(), Initialize(), and IsVerbose().

◆ rom_storage_

Rom yaze::cli::resources::CommandContext::rom_storage_
private

Definition at line 89 of file command_context.h.

Referenced by Initialize().

◆ active_rom_

Rom* yaze::cli::resources::CommandContext::active_rom_
private
Initial value:
=
nullptr

Definition at line 90 of file command_context.h.

Referenced by GetRom(), and Initialize().

◆ symbol_provider_

emu::debug::SymbolProvider yaze::cli::resources::CommandContext::symbol_provider_
private

Definition at line 92 of file command_context.h.

Referenced by GetSymbolProvider(), and Initialize().

◆ loaded_project_

std::optional<project::YazeProject> yaze::cli::resources::CommandContext::loaded_project_
private

◆ previous_feature_flags_

std::optional<core::FeatureFlags::Flags> yaze::cli::resources::CommandContext::previous_feature_flags_
private

Definition at line 94 of file command_context.h.

Referenced by ApplyProjectRuntimeContext(), and RestoreProjectRuntimeContext().

◆ previous_custom_object_state_

std::optional<zelda3::CustomObjectManager::State> yaze::cli::resources::CommandContext::previous_custom_object_state_
private

Definition at line 96 of file command_context.h.

Referenced by ApplyProjectRuntimeContext(), and RestoreProjectRuntimeContext().

◆ project_runtime_applied_

bool yaze::cli::resources::CommandContext::project_runtime_applied_ = false
private

Definition at line 97 of file command_context.h.

Referenced by ApplyProjectRuntimeContext(), and RestoreProjectRuntimeContext().

◆ initialized_

bool yaze::cli::resources::CommandContext::initialized_ = false
private

Definition at line 98 of file command_context.h.

Referenced by GetRom(), GetSymbolProvider(), and Initialize().


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