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

#include <proposal_registry.h>

Classes

struct  ProposalMetadata
 

Public Types

enum class  ProposalStatus { kPending , kAccepted , kRejected }
 

Public Member Functions

void SetRootDirectory (const std::filesystem::path &root)
 
const std::filesystem::path & RootDirectory () const
 
absl::StatusOr< ProposalMetadataCreateProposal (absl::string_view sandbox_id, const std::filesystem::path &sandbox_rom_path, absl::string_view prompt, absl::string_view description)
 
absl::Status RecordDiff (const std::string &proposal_id, absl::string_view diff_content)
 
absl::Status AppendLog (const std::string &proposal_id, absl::string_view log_entry)
 
absl::Status AddScreenshot (const std::string &proposal_id, const std::filesystem::path &screenshot_path)
 
absl::Status UpdateCommandStats (const std::string &proposal_id, int commands_executed)
 
absl::Status UpdateStatus (const std::string &proposal_id, ProposalStatus status)
 
absl::StatusOr< ProposalMetadataGetProposal (const std::string &proposal_id) const
 
std::vector< ProposalMetadataListProposals (std::optional< ProposalStatus > filter_status=std::nullopt) const
 
absl::StatusOr< ProposalMetadataGetLatestPendingProposal () const
 
absl::Status RemoveProposal (const std::string &proposal_id)
 
absl::StatusOr< int > CleanupOlderThan (absl::Duration max_age)
 

Static Public Member Functions

static ProposalRegistryInstance ()
 

Private Member Functions

 ProposalRegistry ()
 
absl::Status EnsureRootExistsLocked ()
 
absl::Status LoadProposalsFromDiskLocked ()
 
std::string GenerateProposalIdLocked ()
 
std::filesystem::path ProposalDirectory (absl::string_view proposal_id) const
 
absl::Status WriteMetadataLocked (const ProposalMetadata &metadata) const
 

Private Attributes

std::filesystem::path root_directory_
 
std::mutex mutex_
 
std::unordered_map< std::string, ProposalMetadataproposals_
 
int sequence_ = 0
 

Detailed Description

Definition at line 29 of file proposal_registry.h.

Member Enumeration Documentation

◆ ProposalStatus

Enumerator
kPending 
kAccepted 
kRejected 

Definition at line 31 of file proposal_registry.h.

Constructor & Destructor Documentation

◆ ProposalRegistry()

yaze::cli::ProposalRegistry::ProposalRegistry ( )
private

Definition at line 78 of file proposal_registry.cc.

Referenced by Instance().

Member Function Documentation

◆ Instance()

◆ SetRootDirectory()

void yaze::cli::ProposalRegistry::SetRootDirectory ( const std::filesystem::path &  root)

Definition at line 81 of file proposal_registry.cc.

References EnsureRootExistsLocked(), mutex_, and root_directory_.

Here is the call graph for this function:

◆ RootDirectory()

const std::filesystem::path & yaze::cli::ProposalRegistry::RootDirectory ( ) const

Definition at line 87 of file proposal_registry.cc.

References root_directory_.

◆ CreateProposal()

absl::StatusOr< ProposalRegistry::ProposalMetadata > yaze::cli::ProposalRegistry::CreateProposal ( absl::string_view  sandbox_id,
const std::filesystem::path &  sandbox_rom_path,
absl::string_view  prompt,
absl::string_view  description 
)

◆ RecordDiff()

absl::Status yaze::cli::ProposalRegistry::RecordDiff ( const std::string &  proposal_id,
absl::string_view  diff_content 
)

Definition at line 330 of file proposal_registry.cc.

References mutex_, proposals_, RETURN_IF_ERROR, and WriteMetadataLocked().

Here is the call graph for this function:

◆ AppendLog()

absl::Status yaze::cli::ProposalRegistry::AppendLog ( const std::string &  proposal_id,
absl::string_view  log_entry 
)

Definition at line 356 of file proposal_registry.cc.

References mutex_, and proposals_.

◆ AddScreenshot()

absl::Status yaze::cli::ProposalRegistry::AddScreenshot ( const std::string &  proposal_id,
const std::filesystem::path &  screenshot_path 
)

Definition at line 380 of file proposal_registry.cc.

References mutex_, proposals_, RETURN_IF_ERROR, and WriteMetadataLocked().

Here is the call graph for this function:

◆ UpdateCommandStats()

absl::Status yaze::cli::ProposalRegistry::UpdateCommandStats ( const std::string &  proposal_id,
int  commands_executed 
)

Definition at line 402 of file proposal_registry.cc.

References mutex_, proposals_, RETURN_IF_ERROR, and WriteMetadataLocked().

Here is the call graph for this function:

◆ UpdateStatus()

absl::Status yaze::cli::ProposalRegistry::UpdateStatus ( const std::string &  proposal_id,
ProposalStatus  status 
)

Definition at line 416 of file proposal_registry.cc.

References mutex_, proposals_, RETURN_IF_ERROR, and WriteMetadataLocked().

Here is the call graph for this function:

◆ GetProposal()

absl::StatusOr< ProposalRegistry::ProposalMetadata > yaze::cli::ProposalRegistry::GetProposal ( const std::string &  proposal_id) const

Definition at line 432 of file proposal_registry.cc.

References mutex_, and proposals_.

◆ ListProposals()

std::vector< ProposalRegistry::ProposalMetadata > yaze::cli::ProposalRegistry::ListProposals ( std::optional< ProposalStatus filter_status = std::nullopt) const

Definition at line 443 of file proposal_registry.cc.

References LoadProposalsFromDiskLocked(), mutex_, and proposals_.

Here is the call graph for this function:

◆ GetLatestPendingProposal()

absl::StatusOr< ProposalRegistry::ProposalMetadata > yaze::cli::ProposalRegistry::GetLatestPendingProposal ( ) const

◆ RemoveProposal()

absl::Status yaze::cli::ProposalRegistry::RemoveProposal ( const std::string &  proposal_id)

Definition at line 559 of file proposal_registry.cc.

References mutex_, ProposalDirectory(), and proposals_.

Here is the call graph for this function:

◆ CleanupOlderThan()

absl::StatusOr< int > yaze::cli::ProposalRegistry::CleanupOlderThan ( absl::Duration  max_age)

Definition at line 579 of file proposal_registry.cc.

References mutex_, ProposalDirectory(), and proposals_.

Here is the call graph for this function:

◆ EnsureRootExistsLocked()

absl::Status yaze::cli::ProposalRegistry::EnsureRootExistsLocked ( )
private

Definition at line 91 of file proposal_registry.cc.

References root_directory_.

Referenced by CreateProposal(), and SetRootDirectory().

◆ LoadProposalsFromDiskLocked()

◆ GenerateProposalIdLocked()

std::string yaze::cli::ProposalRegistry::GenerateProposalIdLocked ( )
private

Definition at line 273 of file proposal_registry.cc.

References sequence_.

Referenced by CreateProposal().

◆ ProposalDirectory()

std::filesystem::path yaze::cli::ProposalRegistry::ProposalDirectory ( absl::string_view  proposal_id) const
private

◆ WriteMetadataLocked()

Member Data Documentation

◆ root_directory_

std::filesystem::path yaze::cli::ProposalRegistry::root_directory_
private

◆ mutex_

◆ proposals_

◆ sequence_

int yaze::cli::ProposalRegistry::sequence_ = 0
private

Definition at line 127 of file proposal_registry.h.

Referenced by GenerateProposalIdLocked().


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