22#include <nlohmann/json.hpp>
40 { JOBSET_OUTPUT_TYPE::FOLDER,
42 { JOBSET_OUTPUT_TYPE::ARCHIVE,
49 { JOBSET_OUTPUT_TYPE::FOLDER,
"folder" },
50 { JOBSET_OUTPUT_TYPE::ARCHIVE,
"archive" }
55 j = nlohmann::json{ {
"id", f.
m_id },
58 {
"settings", nlohmann::json::object( {} ) }
61 f.
m_job->ToJson( j.at(
"settings" ) );
67 j.at(
"type" ).get_to( f.
m_type );
68 j.at(
"id" ).get_to( f.
m_id );
71 nlohmann::json settings_obj = j.at(
"settings" );
73 f.
m_job.reset( JOB_REGISTRY::CreateInstance<JOB>( f.
m_type ) );
75 if( f.
m_job !=
nullptr )
77 f.
m_job->FromJson( settings_obj );
84 j = nlohmann::json{ {
"id", f.
m_id },
88 {
"settings", nlohmann::json::object( {} ) }
98 if( j.contains(
"id" ) )
99 j.at(
"id" ).get_to( f.
m_id );
103 j.at(
"type" ).get_to( f.
m_type );
104 f.
m_only = j.value(
"only", std::vector<wxString>() );
107 const nlohmann::json& settings_obj = j.at(
"settings" );
120 m_outputHandler( nullptr ),
130 m_outputHandler( nullptr ),
149 if(
m_type == JOBSET_OUTPUT_TYPE::FOLDER )
153 else if(
m_type == JOBSET_OUTPUT_TYPE::ARCHIVE )
189 if( aDescription ==
m_job->GetDefaultDescription() )
221 m_jobs.emplace_back(
KIID().AsString(), aType, aJob );
240 return output.
m_id == aOutput->
m_id;
257 if( aJobIdx <
m_jobs.size() - 1 )
289 if( output.m_id == aOutput )
304 wxASSERT( aOutput !=
nullptr );
306 if( aOutput->
m_only.size() == 0 )
311 std::vector<JOBSET_JOB> result;
312 for( wxString& onlyId : aOutput->
m_only )
317 if( job.m_id == onlyId )
324 result.push_back( *it );
331#if !defined( __MINGW32__ )
wxString m_fileNameWithoutPath
std::vector< JOBSET_JOB > GetJobsForOutput(JOBSET_OUTPUT *aOutput)
bool SaveToFile(const wxString &aDirectory="", bool aForce=false) override
Calls Store() and then writes the contents of the JSON document to a file.
void SetDirty(bool aFlag=true)
void RemoveOutput(JOBSET_OUTPUT *aOutput)
void MoveJobUp(size_t aJobIdx)
JOBSET_OUTPUT * GetOutput(wxString &aOutput)
std::vector< JOBSET_JOB > m_jobs
void RemoveJob(size_t aJobIdx)
std::vector< JOBSET_OUTPUT > m_outputs
void AddNewJob(wxString aType, JOB *aJob)
void MoveJobDown(size_t aJobIdx)
wxString getFileExt() const override
JOBSET(const wxString &aFilename)
JOBSET_OUTPUT * AddNewJobOutput(JOBSET_OUTPUT_TYPE aType)
virtual wxString GetDefaultDescription() const
virtual void ToJson(nlohmann::json &j) const =0
virtual void FromJson(const nlohmann::json &j)=0
An simple container class that lets us dispatch output jobs to kifaces.
std::vector< PARAM_BASE * > m_params
The list of parameters (owned by this object)
virtual bool SaveToFile(const wxString &aDirectory="", bool aForce=false)
Calls Store() and then writes the contents of the JSON document to a file.
wxString AsString() const
static const std::string KiCadJobSetFileExtension
static wxString ZipFileWildcard()
Some functions to handle hotkeys in KiCad.
NLOHMANN_JSON_SERIALIZE_ENUM(JOBSET_OUTPUT_TYPE, { { JOBSET_OUTPUT_TYPE::FOLDER, "folder" }, { JOBSET_OUTPUT_TYPE::ARCHIVE, "archive" } }) KICOMMON_API void to_json(nlohmann
KICOMMON_API std::map< JOBSET_OUTPUT_TYPE, JOBSET_OUTPUT_TYPE_INFO > JobsetOutputTypeInfos
KICOMMON_API void from_json(const nlohmann::json &j, JOBSET_JOB &f)
KICOMMON_API void to_json(nlohmann::json &j, const JOBSET_OUTPUT &f)
const int jobsFileSchemaVersion
enum KICOMMON_API JOBSET_OUTPUT_TYPE
@ NONE
No connection to this item.
std::shared_ptr< JOB > m_job
bool operator==(const JOBSET_JOB &rhs) const
wxString GetDescription() const
void SetDescription(const wxString &aDescription)
wxString GetDescription() const
std::vector< wxString > m_only
void SetDescription(const wxString &aDescription)
Transient property, not stored for now.
JOBS_OUTPUT_HANDLER * m_outputHandler
std::unordered_map< wxString, REPORTER * > m_lastRunReporters
bool operator==(const JOBSET_OUTPUT &rhs) const
JOBSET_OUTPUT_TYPE m_type
Definition of file extensions used in Kicad.