KiCad PCB EDA Suite
Loading...
Searching...
No Matches
TEXT_EVAL::ENVIRONMENT Class Reference

A text evaluation frame with one frozen clock and memoized external queries. More...

#include <text_eval_environment.h>

Classes

struct  CROSS_REFERENCE_VALUE
 
struct  SOURCE_VALUES
 
struct  VCS_VALUE
 

Public Types

enum class  VCS_QUERY {
  HEAD , HASH , DESCRIPTION , SIGNATURE ,
  BRANCH , DIRTY , TIMESTAMP
}
 
using VCS_KEY = std::tuple<VCS_QUERY, wxString, std::string, int, bool>
 Query, absolute path (Git directory for HEAD), selector or pattern, options, and whether the context is a file.
 
using CROSS_REFERENCE_KEY = std::pair<wxString, int>
 

Public Member Functions

 ENVIRONMENT (const wxDateTime &aTime=wxDateTime::Now())
 
 ENVIRONMENT (const ENVIRONMENT &)=delete
 
ENVIRONMENToperator= (const ENVIRONMENT &)=delete
 
 ~ENVIRONMENT ()
 
void RecordEnvironmentVariable (const wxString &aName, const std::optional< wxString > &aValue)
 
void RecordRandomUse ()
 
void RecordCrossReference (const CROSS_REFERENCE_KEY &aKey, const CROSS_REFERENCE_VALUE &aValue)
 
bool IsCollectingSources () const
 
const wxString & GitHash (const wxString &aPath, const std::function< wxString()> &aRead)
 Return the value memoized for this frame.
 
const VCS_VALUEVcsValue (const VCS_KEY &aKey, const std::function< VCS_VALUE()> &aRead)
 

Static Public Member Functions

static ENVIRONMENTCurrent ()
 
static wxDateTime CurrentTime ()
 

Private Attributes

wxDateTime m_time
 
std::map< wxString, wxString > m_gitHashes
 
std::map< VCS_KEY, VCS_VALUEm_vcsValues
 
SOURCE_SCOPEm_sources = nullptr
 

Friends

class SOURCE_SCOPE
 

Detailed Description

A text evaluation frame with one frozen clock and memoized external queries.

Owned and used by a single thread. Reads made while a SOURCE_SCOPE is open are recorded so a cache can tell whether evaluated text depends on anything outside the document.

Definition at line 43 of file text_eval_environment.h.

Member Typedef Documentation

◆ CROSS_REFERENCE_KEY

using TEXT_EVAL::ENVIRONMENT::CROSS_REFERENCE_KEY = std::pair<wxString, int>

Definition at line 68 of file text_eval_environment.h.

◆ VCS_KEY

using TEXT_EVAL::ENVIRONMENT::VCS_KEY = std::tuple<VCS_QUERY, wxString, std::string, int, bool>

Query, absolute path (Git directory for HEAD), selector or pattern, options, and whether the context is a file.

Definition at line 58 of file text_eval_environment.h.

Member Enumeration Documentation

◆ VCS_QUERY

Enumerator
HEAD 
HASH 
DESCRIPTION 
SIGNATURE 
BRANCH 
DIRTY 
TIMESTAMP 

Definition at line 46 of file text_eval_environment.h.

Constructor & Destructor Documentation

◆ ENVIRONMENT() [1/2]

TEXT_EVAL::ENVIRONMENT::ENVIRONMENT ( const wxDateTime & aTime = wxDateTime::Now())
inlineexplicit

Definition at line 90 of file text_eval_environment.h.

References m_time.

Referenced by Current(), ENVIRONMENT(), and operator=().

◆ ENVIRONMENT() [2/2]

TEXT_EVAL::ENVIRONMENT::ENVIRONMENT ( const ENVIRONMENT & )
delete

References ENVIRONMENT().

◆ ~ENVIRONMENT()

TEXT_EVAL::ENVIRONMENT::~ENVIRONMENT ( )

Definition at line 32 of file text_eval_environment.cpp.

References m_sources.

Member Function Documentation

◆ Current()

◆ CurrentTime()

wxDateTime TEXT_EVAL::ENVIRONMENT::CurrentTime ( )
static
Returns
the frozen time of the active environment, or the wall clock when none is active.

Definition at line 45 of file text_eval_environment.cpp.

References SOURCE_SCOPE.

Referenced by TITLE_BLOCK::GetCurrentDate(), calc_parser::DATE_UTILS::GetCurrentDays(), TITLE_BLOCK::GetCurrentTimeHHMMSS(), TITLE_BLOCK::GetCurrentTimeLocale(), calc_parser::DATE_UTILS::GetCurrentTimestamp(), and operator=().

◆ GitHash()

const wxString & TEXT_EVAL::ENVIRONMENT::GitHash ( const wxString & aPath,
const std::function< wxString()> & aRead )

Return the value memoized for this frame.

aRead runs only on the first request for a key.

Definition at line 78 of file text_eval_environment.cpp.

References m_gitHashes, m_sources, and SOURCE_SCOPE.

◆ IsCollectingSources()

bool TEXT_EVAL::ENVIRONMENT::IsCollectingSources ( ) const
inline

Definition at line 110 of file text_eval_environment.h.

References m_sources.

◆ operator=()

ENVIRONMENT & TEXT_EVAL::ENVIRONMENT::operator= ( const ENVIRONMENT & )
delete

◆ RecordCrossReference()

void TEXT_EVAL::ENVIRONMENT::RecordCrossReference ( const CROSS_REFERENCE_KEY & aKey,
const CROSS_REFERENCE_VALUE & aValue )

Definition at line 71 of file text_eval_environment.cpp.

References m_sources, and SOURCE_SCOPE.

Referenced by operator=().

◆ RecordEnvironmentVariable()

void TEXT_EVAL::ENVIRONMENT::RecordEnvironmentVariable ( const wxString & aName,
const std::optional< wxString > & aValue )

Definition at line 57 of file text_eval_environment.cpp.

References m_sources, and SOURCE_SCOPE.

Referenced by operator=().

◆ RecordRandomUse()

void TEXT_EVAL::ENVIRONMENT::RecordRandomUse ( )

Definition at line 64 of file text_eval_environment.cpp.

References m_sources, and SOURCE_SCOPE.

Referenced by operator=().

◆ VcsValue()

const ENVIRONMENT::VCS_VALUE & TEXT_EVAL::ENVIRONMENT::VcsValue ( const VCS_KEY & aKey,
const std::function< VCS_VALUE()> & aRead )

Definition at line 92 of file text_eval_environment.cpp.

References m_sources, m_vcsValues, and SOURCE_SCOPE.

Friends And Related Symbol Documentation

◆ SOURCE_SCOPE

Member Data Documentation

◆ m_gitHashes

std::map<wxString, wxString> TEXT_EVAL::ENVIRONMENT::m_gitHashes
private

Definition at line 122 of file text_eval_environment.h.

Referenced by GitHash().

◆ m_sources

SOURCE_SCOPE* TEXT_EVAL::ENVIRONMENT::m_sources = nullptr
private

◆ m_time

wxDateTime TEXT_EVAL::ENVIRONMENT::m_time
private

Definition at line 121 of file text_eval_environment.h.

Referenced by ENVIRONMENT().

◆ m_vcsValues

std::map<VCS_KEY, VCS_VALUE> TEXT_EVAL::ENVIRONMENT::m_vcsValues
private

Definition at line 123 of file text_eval_environment.h.

Referenced by VcsValue().


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