22#include <nlohmann/json.hpp>
41 { JOBSET_DESTINATION_T::FOLDER,
43 { JOBSET_DESTINATION_T::ARCHIVE,
50 { JOBSET_DESTINATION_T::FOLDER,
"folder" },
51 { JOBSET_DESTINATION_T::ARCHIVE,
"archive" }
56 j = nlohmann::json{ {
"id", f.
m_id },
59 {
"settings", nlohmann::json::object( {} ) }
62 f.
m_job->ToJson( j.at(
"settings" ) );
68 j.at(
"type" ).get_to( f.
m_type );
69 j.at(
"id" ).get_to( f.
m_id );
72 nlohmann::json settings_obj = j.at(
"settings" );
74 f.
m_job.reset( JOB_REGISTRY::CreateInstance<JOB>( f.
m_type ) );
76 if( f.
m_job !=
nullptr )
78 f.
m_job->FromJson( settings_obj );
85 j = nlohmann::json{ {
"id", destination.
m_id },
86 {
"type", destination.
m_type },
87 {
"only", destination.
m_only },
89 {
"settings", nlohmann::json::object( {} ) }
99 if( j.contains(
"id" ) )
100 j.at(
"id" ).get_to( destination.
m_id );
104 j.at(
"type" ).get_to( destination.
m_type );
105 destination.
m_only = j.value(
"only", std::vector<wxString>() );
108 const nlohmann::json& settings_obj = j.at(
"settings" );
119 m_outputHandler( nullptr ),
129 m_outputHandler( nullptr ),
148 if(
m_type == JOBSET_DESTINATION_T::FOLDER )
152 else if(
m_type == JOBSET_DESTINATION_T::ARCHIVE )
188 if( aDescription ==
m_job->GetDefaultDescription() )
220 m_jobs.emplace_back(
KIID().AsString(), aType, aJob );
239 return destination.
m_id == aDestination->
m_id;
256 if( aJobIdx <
m_jobs.size() - 1 )
288 if( destination.m_id == aDestination )
303 wxASSERT( aDestination !=
nullptr );
305 if( aDestination->
m_only.size() == 0 )
310 std::vector<JOBSET_JOB> result;
311 for( wxString& onlyId : aDestination->
m_only )
316 if( job.m_id == onlyId )
323 result.push_back( *it );
330#if !defined( __MINGW32__ )
wxString m_fileNameWithoutPath
JOBSET_DESTINATION * GetDestination(wxString &aDestination)
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 MoveJobUp(size_t aJobIdx)
std::vector< JOBSET_DESTINATION > m_destinations
std::vector< JOBSET_JOB > GetJobsForDestination(JOBSET_DESTINATION *aDestination)
std::vector< JOBSET_JOB > m_jobs
void RemoveJob(size_t aJobIdx)
void AddNewJob(wxString aType, JOB *aJob)
void MoveJobDown(size_t aJobIdx)
JOBSET_DESTINATION * AddNewDestination(JOBSET_DESTINATION_T aType)
wxString getFileExt() const override
JOBSET(const wxString &aFilename)
void RemoveDestination(JOBSET_DESTINATION *aDestination)
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.
KICOMMON_API void to_json(nlohmann::json &j, const JOBSET_DESTINATION &destination)
KICOMMON_API void from_json(const nlohmann::json &j, JOBSET_JOB &f)
NLOHMANN_JSON_SERIALIZE_ENUM(JOBSET_DESTINATION_T, { { JOBSET_DESTINATION_T::FOLDER, "folder" }, { JOBSET_DESTINATION_T::ARCHIVE, "archive" } }) KICOMMON_API void to_json(nlohmann
const int jobsFileSchemaVersion
KICOMMON_API std::map< JOBSET_DESTINATION_T, JOBSET_DESTINATION_T_INFO > JobsetDestinationTypeInfos
enum KICOMMON_API JOBSET_DESTINATION_T
void SetDescription(const wxString &aDescription)
Transient property, not stored for now.
std::unordered_map< wxString, REPORTER * > m_lastRunReporters
JOBSET_DESTINATION_T m_type
JOBS_OUTPUT_HANDLER * m_outputHandler
std::vector< wxString > m_only
bool operator==(const JOBSET_DESTINATION &rhs) const
wxString GetDescription() const
std::shared_ptr< JOB > m_job
bool operator==(const JOBSET_JOB &rhs) const
wxString GetDescription() const
void SetDescription(const wxString &aDescription)
Definition of file extensions used in Kicad.