40 virtual void FromJson(
const nlohmann::json& j )
const = 0;
42 virtual void ToJson( nlohmann::json& j ) = 0;
48template <
typename ValueType>
53 JOB_PARAM(
const std::string& aJsonPath, ValueType* aPtr,
54 ValueType aDefault ) :
59 virtual void FromJson(
const nlohmann::json& j )
const override
72template <
typename ListElementType>
76 JOB_PARAM_LIST(
const std::string& aJsonPath, std::vector<ListElementType>* aPtr,
77 std::vector<ListElementType> aDefault ) :
83 virtual void FromJson(
const nlohmann::json& j )
const override
88 std::vector<ListElementType> val;
92 for(
const auto& el : js.items() )
93 val.push_back( el.value().template get<ListElementType>() );
102 void ToJson( nlohmann::json& j )
override
104 nlohmann::json js = nlohmann::json::array();
106 for(
const auto& el : *
m_ptr )
113 std::vector<ListElementType>*
m_ptr;
126 virtual void FromJson(
const nlohmann::json& j )
const override
135 for(
const nlohmann::json& layer : js )
137 if( layer.is_string() )
139 wxString
name = layer.get<wxString>();
142 layers.push_back(
static_cast<PCB_LAYER_ID>( layerId ) );
146 int layerId = layer.get<
int>();
148 layers.push_back(
static_cast<PCB_LAYER_ID>( layerId ) );
158 void ToJson( nlohmann::json& j )
override
160 nlohmann::json js = nlohmann::json::array();
173 JOB_OUTPUT( wxString outputPath ) { m_outputPath = outputPath; }
184 JOB(
const std::string& aType,
bool aOutputIsDirectory );
188 const std::string&
GetType()
const {
return m_type; };
190 const std::map<wxString, wxString>&
GetVarOverrides()
const {
return m_varOverrides; }
194 m_varOverrides = aVarOverrides;
199 virtual void FromJson(
const nlohmann::json& j );
200 virtual void ToJson( nlohmann::json& j )
const;
202 virtual wxString GetDefaultDescription()
const;
203 virtual wxString GetSettingsDialogTitle()
const;
205 const std::vector<JOB_PARAM_BASE*>&
GetParams() {
return m_params; }
208 const std::vector<JOB_OUTPUT>&
GetOutputs() {
return m_outputs; }
209 void AddOutput( wxString aOutputPath ) { m_outputs.emplace_back( aOutputPath ); }
216 void SetTempOutputDirectory(
const wxString& aBase );
221 void SetConfiguredOutputPath(
const wxString& aPath );
245 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)