21#include <nlohmann/json.hpp>
44 j = nlohmann::json{ {
"id", f.
m_id },
46 {
"settings", nlohmann::json::object( {} ) }
49 f.
m_job->ToJson( j.at(
"settings" ) );
55 j.at(
"type" ).get_to( f.
m_type );
56 j.at(
"id" ).get_to( f.
m_id );
58 nlohmann::json settings_obj = j.at(
"settings" );
60 f.
m_job.reset( JOB_REGISTRY::CreateInstance<JOB>( f.
m_type ) );
62 if( f.
m_job !=
nullptr )
64 f.
m_job->FromJson( settings_obj );
71 j = nlohmann::json{ {
"type", f.
m_type }, {
"settings", nlohmann::json::object( {} ) } };
79 j.at(
"type" ).get_to( f.
m_type );
80 f.
m_only = j.value(
"only", std::vector<wxString>() );
82 nlohmann::json settings_obj = j.at(
"settings" );
111 if(
m_type == JOBSET_OUTPUT_TYPE::FOLDER )
115 else if(
m_type == JOBSET_OUTPUT_TYPE::ARCHIVE )
153 m_jobs.emplace_back(
KIID().AsString(), aType, aJob );
172 return output.
m_id == aOutput->
m_id;
189 if( aJobIdx <
m_jobs.size() - 1 )
221 if( output.m_id == aOutput )
236 wxASSERT( aOutput !=
nullptr );
238 if( aOutput->
m_only.size() == 0 )
243 std::vector<JOBSET_JOB> result;
244 for( wxString& onlyId : aOutput->
m_only )
249 if( job.m_id == onlyId )
256 result.push_back( *it );
263#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 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 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.
static const std::string KiCadJobSetFileExtension
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 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
@ NONE
No connection to this item.
std::shared_ptr< JOB > m_job
bool operator==(const JOBSET_JOB &rhs) const
std::vector< wxString > m_only
Transient property, not stored for now.
JOBS_OUTPUT_HANDLER * m_outputHandler
bool operator==(const JOBSET_OUTPUT &rhs) const
JOBSET_OUTPUT_TYPE m_type
Definition of file extensions used in Kicad.