KiCad PCB EDA Suite
Loading...
Searching...
No Matches
jobset.h
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2024 Mark Roszko <[email protected]>
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef JOBS_FILE_H
22#define JOBS_FILE_H
23
24#include <reporter.h>
26#include <jobs/job.h>
27#include <jobs/jobs_output.h>
29#include <settings/parameters.h>
31#include <ctime>
32#include <memory>
33
34
36{
37public:
38 JOBSET_OUTPUT_REPORTER( const wxString& aTempDirPath, PROGRESS_REPORTER* aProgressReporter ) :
39 m_tempDirPath( aTempDirPath ),
40 m_includeDebug( false ),
41 m_progressReporter( aProgressReporter )
42 {
43 }
44
45 REPORTER& Report( const wxString& aText, SEVERITY aSeverity ) override
46 {
47 wxString text( aText );
48
49 if( aSeverity == RPT_SEVERITY_DEBUG && !m_includeDebug )
50 return *this;
51
52 if( aSeverity == RPT_SEVERITY_ACTION )
53 text.Replace( m_tempDirPath, wxEmptyString );
54
56 {
59 }
60
61 return WX_STRING_REPORTER::Report( text, aSeverity );
62 }
63
64private:
65 wxString m_tempDirPath;
68};
69
70
71
73{
75 m_job( nullptr )
76 {}
77
78 JOBSET_JOB( const wxString& id, const wxString& type, JOB* job ) :
79 m_id( id ),
80 m_type( type ),
81 m_job( job )
82 {}
83
84 wxString m_id;
85 wxString m_type;
86 wxString m_description;
87 std::shared_ptr<JOB> m_job;
88
89 wxString GetDescription() const;
90 void SetDescription( const wxString& aDescription );
91
92 bool operator==( const JOBSET_JOB& rhs ) const;
93};
94
95
97{
99 ARCHIVE
100};
101
103{
104 wxString name;
107 wxString fileWildcard;
108};
109
110extern KICOMMON_API
111std::map<JOBSET_DESTINATION_T, JOBSET_DESTINATION_T_INFO> JobsetDestinationTypeInfos;
112
113
115{
117
118 JOBSET_DESTINATION( const wxString& id, JOBSET_DESTINATION_T type );
119
120 void InitOutputHandler();
121
122 wxString GetDescription() const;
123 void SetDescription( const wxString& aDescription );
124
125 wxString GetPathInfo() const;
126
127 bool operator==( const JOBSET_DESTINATION& rhs ) const;
128
129public:
130 wxString m_id;
133 std::shared_ptr<JOBS_OUTPUT_HANDLER> m_outputHandler;
134 std::vector<wxString> m_only;
135
137 std::optional<bool> m_lastRunSuccess;
138 std::unordered_map<wxString, std::optional<bool>> m_lastRunSuccessMap;
139 std::unordered_map<wxString, std::shared_ptr<JOBSET_OUTPUT_REPORTER>> m_lastRunReporters;
140};
141
142
144{
145public:
146 JOBSET( const wxString& aFilename );
147
148 virtual ~JOBSET() {}
149
150 std::vector<JOBSET_JOB>& GetJobs()
151 {
152 return m_jobs;
153 }
154
155 std::vector<JOBSET_JOB> GetJobsForDestination( JOBSET_DESTINATION* aDestination );
156
157 std::vector<JOBSET_DESTINATION>& GetDestinations() { return m_destinations; }
158
163 JOBSET_DESTINATION* FindDestination( wxString& aDestinationStr );
164
165 bool SaveToFile( const wxString& aDirectory = "", bool aForce = false ) override;
166
167 void SetDirty( bool aFlag = true ) { m_dirty = aFlag; }
168 bool GetDirty() const { return m_dirty; }
169
170 wxString GetFullName() const { return m_fileNameWithoutPath; }
171
172 void AddNewJob( wxString aType, JOB* aJob );
173 JOBSET_DESTINATION* AddNewDestination( JOBSET_DESTINATION_T aType );
174
175 void RemoveDestination( JOBSET_DESTINATION* aDestination );
176 void MoveJobUp( size_t aJobIdx );
177 void MoveJobDown( size_t aJobIdx );
178 void RemoveJob( size_t aJobIdx );
179
180protected:
181 wxString getFileExt() const override;
182
183private:
184 std::vector<JOBSET_JOB> m_jobs;
185 std::vector<JOBSET_DESTINATION> m_destinations;
186
189};
190
191
192KICOMMON_API void to_json( nlohmann::json& j, const JOBSET_JOB& f );
193KICOMMON_API void from_json( const nlohmann::json& j, JOBSET_JOB& f );
194
195KICOMMON_API void to_json( nlohmann::json& j, const JOBSET_DESTINATION& f );
196KICOMMON_API void from_json( const nlohmann::json& j, JOBSET_DESTINATION& f );
197
198#if defined( __MINGW32__ )
201#else
202extern template class APIVISIBLE PARAM_LIST<JOBSET_JOB>;
203extern template class APIVISIBLE PARAM_LIST<JOBSET_DESTINATION>;
204#endif
205
206#endif
bool operator==(const wxAuiPaneInfo &aLhs, const wxAuiPaneInfo &aRhs)
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
wxString m_tempDirPath
Definition: jobset.h:65
REPORTER & Report(const wxString &aText, SEVERITY aSeverity) override
Report a string with a given severity.
Definition: jobset.h:45
PROGRESS_REPORTER * m_progressReporter
Definition: jobset.h:67
JOBSET_OUTPUT_REPORTER(const wxString &aTempDirPath, PROGRESS_REPORTER *aProgressReporter)
Definition: jobset.h:38
Definition: jobset.h:144
std::vector< JOBSET_DESTINATION > & GetDestinations()
Definition: jobset.h:157
wxString m_fileNameWithoutPath
Definition: jobset.h:188
bool GetDirty() const
Definition: jobset.h:168
void SetDirty(bool aFlag=true)
Definition: jobset.h:167
std::vector< JOBSET_DESTINATION > m_destinations
Definition: jobset.h:185
std::vector< JOBSET_JOB > m_jobs
Definition: jobset.h:184
std::vector< JOBSET_JOB > & GetJobs()
Definition: jobset.h:150
bool m_dirty
Definition: jobset.h:187
wxString GetFullName() const
Definition: jobset.h:170
virtual ~JOBSET()
Definition: jobset.h:148
An simple container class that lets us dispatch output jobs to kifaces.
Definition: job.h:183
A progress reporter interface for use in multi-threaded environments.
virtual bool KeepRefreshing(bool aWait=false)=0
Update the UI (if any).
virtual void Report(const wxString &aMessage)=0
Display aMessage in the progress bar dialog.
A pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:73
A wrapper for reporting to a wxString object.
Definition: reporter.h:190
REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Report a string with a given severity.
Definition: reporter.cpp:74
#define APIVISIBLE
Definition: import_export.h:55
enum KICOMMON_API JOBSET_DESTINATION_T
Definition: jobset.h:97
KICOMMON_API void from_json(const nlohmann::json &j, JOBSET_JOB &f)
Definition: jobset.cpp:67
FOLDER
Definition: jobset.h:98
KICOMMON_API std::map< JOBSET_DESTINATION_T, JOBSET_DESTINATION_T_INFO > JobsetDestinationTypeInfos
Definition: jobset.cpp:40
KICOMMON_API void to_json(nlohmann::json &j, const JOBSET_JOB &f)
#define KICOMMON_API
Definition: kicommon.h:28
SEVERITY
@ RPT_SEVERITY_DEBUG
@ RPT_SEVERITY_ACTION
std::unordered_map< wxString, std::shared_ptr< JOBSET_OUTPUT_REPORTER > > m_lastRunReporters
Definition: jobset.h:139
std::shared_ptr< JOBS_OUTPUT_HANDLER > m_outputHandler
Definition: jobset.h:133
JOBSET_DESTINATION_T m_type
Definition: jobset.h:131
wxString m_description
Definition: jobset.h:132
std::vector< wxString > m_only
Transient property, not stored for now.
Definition: jobset.h:134
std::optional< bool > m_lastRunSuccess
Definition: jobset.h:137
std::unordered_map< wxString, std::optional< bool > > m_lastRunSuccessMap
Definition: jobset.h:138
wxString m_id
Definition: jobset.h:130
wxString m_id
Definition: jobset.h:84
std::shared_ptr< JOB > m_job
Definition: jobset.h:87
wxString m_description
Definition: jobset.h:86
JOBSET_JOB(const wxString &id, const wxString &type, JOB *job)
Definition: jobset.h:78
wxString m_type
Definition: jobset.h:85
JOBSET_JOB()
Definition: jobset.h:74