41 virtual void FromJson(
const nlohmann::json& j )
const = 0;
43 virtual void ToJson( nlohmann::json& j ) = 0;
49template <
typename ValueType>
54 JOB_PARAM(
const std::string& aJsonPath, ValueType* aPtr,
55 ValueType aDefault ) :
60 virtual void FromJson(
const nlohmann::json& j )
const override
73template <
typename ListElementType>
77 JOB_PARAM_LIST(
const std::string& aJsonPath, std::vector<ListElementType>* aPtr,
78 std::vector<ListElementType> aDefault ) :
84 virtual void FromJson(
const nlohmann::json& j )
const override
89 std::vector<ListElementType> val;
93 for(
const auto& el : js.items() )
94 val.push_back( el.value().template get<ListElementType>() );
103 void ToJson( nlohmann::json& j )
override
105 nlohmann::json js = nlohmann::json::array();
107 for(
const auto& el : *
m_ptr )
114 std::vector<ListElementType>*
m_ptr;
127 virtual void FromJson(
const nlohmann::json& j )
const override
136 for(
const nlohmann::json& layer : js )
138 if( layer.is_string() )
140 wxString
name = layer.get<wxString>();
143 layers.push_back(
static_cast<PCB_LAYER_ID>( layerId ) );
147 int layerId = layer.get<
int>();
149 layers.push_back(
static_cast<PCB_LAYER_ID>( layerId ) );
159 void ToJson( nlohmann::json& j )
override
161 nlohmann::json js = nlohmann::json::array();
174 JOB_OUTPUT( wxString outputPath ) { m_outputPath = outputPath; }
185 JOB(
const std::string& aType,
bool aOutputIsDirectory );
189 const std::string&
GetType()
const {
return m_type; };
191 const std::map<wxString, wxString>&
GetVarOverrides()
const {
return m_varOverrides; }
195 m_varOverrides = aVarOverrides;
200 virtual void FromJson(
const nlohmann::json& j );
201 virtual void ToJson( nlohmann::json& j )
const;
203 virtual wxString GetDefaultDescription()
const;
204 virtual wxString GetSettingsDialogTitle()
const;
206 const std::vector<JOB_PARAM_BASE*>&
GetParams() {
return m_params; }
209 const std::vector<JOB_OUTPUT>&
GetOutputs() {
return m_outputs; }
210 void AddOutput( wxString aOutputPath ) { m_outputs.emplace_back( aOutputPath ); }
217 void SetTempOutputDirectory(
const wxString& aBase );
222 void SetConfiguredOutputPath(
const wxString& aPath );
246 wxString GetFullOutputPath(
PROJECT* aProject )
const;
virtual void ToJson(nlohmann::json &j)=0
virtual void FromJson(const nlohmann::json &j) const =0
virtual ~JOB_PARAM_BASE()=default
void ToJson(nlohmann::json &j) override
std::vector< ListElementType > m_default
JOB_PARAM_LIST(const std::string &aJsonPath, std::vector< ListElementType > *aPtr, std::vector< ListElementType > aDefault)
virtual void FromJson(const nlohmann::json &j) const override
std::vector< ListElementType > * m_ptr
JOB_PARAM_LSEQ(const std::string &aJsonPath, LSEQ *aPtr, LSEQ aDefault)
void ToJson(nlohmann::json &j) override
virtual void FromJson(const nlohmann::json &j) const override
JOB_PARAM(const std::string &aJsonPath, ValueType *aPtr, ValueType aDefault)
virtual void ToJson(nlohmann::json &j) override
virtual void FromJson(const nlohmann::json &j) const override
An simple container class that lets us dispatch output jobs to kifaces.
void SetVarOverrides(const std::map< wxString, wxString > &aVarOverrides)
std::vector< JOB_PARAM_BASE * > m_params
const std::vector< JOB_OUTPUT > & GetOutputs()
void AddOutput(wxString aOutputPath)
const std::vector< JOB_PARAM_BASE * > & GetParams()
wxString GetWorkingOutputPath() const
Returns the working output path for the job, if one has been set.
wxString m_workingOutputPath
bool GetOutputPathIsDirectory() const
wxString m_tempOutputDirectory
wxString GetConfiguredOutputPath() const
Returns the configured output path for the job.
std::vector< JOB_OUTPUT > m_outputs
bool m_outputPathIsDirectory
void SetTitleBlock(const TITLE_BLOCK &aTitleBlock)
void SetWorkingOutputPath(const wxString &aPath)
Sets a transient output path for the job, it takes priority over the configured output path when GetF...
const std::string & GetType() const
std::map< wxString, wxString > m_varOverrides
const std::map< wxString, wxString > & GetVarOverrides() const
void ClearExistingOutputs()
LSEQ is a sequence (and therefore also a set) of PCB_LAYER_IDs.
static int NameToLayer(wxString &aName)
Return the layer number from a layer name.
static wxString Name(PCB_LAYER_ID aLayerId)
Return the fixed name association with aLayerId.
Container for project specific data.
Hold the information shown in the lower right corner of a plot, printout, or editing view.
KICOMMON_API void to_json(nlohmann::json &j, const JOB &f)
KICOMMON_API void from_json(const nlohmann::json &j, JOB &f)
PCB_LAYER_ID
A quick note on layer IDs:
JOB_OUTPUT(wxString outputPath)