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
25#include <jobs/job.h>
26#include <jobs/jobs_output.h>
28#include <settings/parameters.h>
29#include <ctime>
30#include <memory>
31
32class REPORTER;
33
35{
37 m_job( nullptr )
38 {}
39
40 JOBSET_JOB( const wxString& id, const wxString& type, JOB* job ) :
41 m_id( id ),
42 m_type( type ),
43 m_job( job )
44 {}
45
46 wxString m_id;
47 wxString m_type;
48 wxString m_description;
49 std::shared_ptr<JOB> m_job;
50
51 wxString GetDescription() const;
52 void SetDescription( const wxString& aDescription );
53
54 bool operator==( const JOBSET_JOB& rhs ) const;
55};
56
57
59{
61 ARCHIVE
62};
63
65{
66 wxString name;
69 wxString fileWildcard;
70};
71
72extern KICOMMON_API std::map<JOBSET_OUTPUT_TYPE, JOBSET_OUTPUT_TYPE_INFO> JobsetOutputTypeInfos;
73
74
76{
78
79 JOBSET_OUTPUT( const wxString& id, JOBSET_OUTPUT_TYPE type );
80
82
83 void InitOutputHandler();
84
85 wxString m_id;
87 wxString m_description;
89 std::vector<wxString> m_only;
90
91 wxString GetDescription() const;
92 void SetDescription( const wxString& aDescription );
93
95 std::optional<bool> m_lastRunSuccess;
96 std::unordered_map<wxString, std::optional<bool>> m_lastRunSuccessMap;
97 std::unordered_map<wxString, REPORTER*> m_lastRunReporters;
98
99 bool operator==( const JOBSET_OUTPUT& rhs ) const;
100
101};
102
103
105{
106public:
107 JOBSET( const wxString& aFilename );
108
109 virtual ~JOBSET() {}
110
111 std::vector<JOBSET_JOB>& GetJobs()
112 {
113 return m_jobs;
114 }
115
116 std::vector<JOBSET_JOB> GetJobsForOutput( JOBSET_OUTPUT* aOutput );
117
118 std::vector<JOBSET_OUTPUT>& GetOutputs() { return m_outputs; }
119
120 JOBSET_OUTPUT* GetOutput( wxString& aOutput );
121
122 bool SaveToFile( const wxString& aDirectory = "", bool aForce = false ) override;
123
124 void SetDirty( bool aFlag = true ) { m_dirty = aFlag; }
125 bool GetDirty() const { return m_dirty; }
126
127 wxString GetFullName() const { return m_fileNameWithoutPath; }
128
129 void AddNewJob( wxString aType, JOB* aJob );
130 JOBSET_OUTPUT* AddNewJobOutput( JOBSET_OUTPUT_TYPE aType );
131
132 void RemoveOutput( JOBSET_OUTPUT* aOutput );
133 void MoveJobUp( size_t aJobIdx );
134 void MoveJobDown( size_t aJobIdx );
135 void RemoveJob( size_t aJobIdx );
136
137protected:
138 wxString getFileExt() const override;
139
140private:
141 std::vector<JOBSET_JOB> m_jobs;
142 std::vector<JOBSET_OUTPUT> m_outputs;
143
146};
147
148KICOMMON_API void to_json( nlohmann::json& j, const JOBSET_JOB& f );
149KICOMMON_API void from_json( const nlohmann::json& j, JOBSET_JOB& f );
150
151KICOMMON_API void to_json( nlohmann::json& j, const JOBSET_OUTPUT& f );
152KICOMMON_API void from_json( const nlohmann::json& j, JOBSET_OUTPUT& f );
153
154#if defined( __MINGW32__ )
157#else
158extern template class APIVISIBLE PARAM_LIST<JOBSET_JOB>;
159extern template class APIVISIBLE PARAM_LIST<JOBSET_OUTPUT>;
160#endif
161
162#endif
bool operator==(const wxAuiPaneInfo &aLhs, const wxAuiPaneInfo &aRhs)
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
Definition: jobset.h:105
wxString m_fileNameWithoutPath
Definition: jobset.h:145
bool GetDirty() const
Definition: jobset.h:125
void SetDirty(bool aFlag=true)
Definition: jobset.h:124
std::vector< JOBSET_JOB > m_jobs
Definition: jobset.h:141
std::vector< JOBSET_OUTPUT > m_outputs
Definition: jobset.h:142
std::vector< JOBSET_JOB > & GetJobs()
Definition: jobset.h:111
bool m_dirty
Definition: jobset.h:144
std::vector< JOBSET_OUTPUT > & GetOutputs()
Definition: jobset.h:118
wxString GetFullName() const
Definition: jobset.h:127
virtual ~JOBSET()
Definition: jobset.h:109
An simple container class that lets us dispatch output jobs to kifaces.
Definition: job.h:182
A pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:72
#define APIVISIBLE
Definition: import_export.h:55
KICOMMON_API std::map< JOBSET_OUTPUT_TYPE, JOBSET_OUTPUT_TYPE_INFO > JobsetOutputTypeInfos
Definition: jobset.cpp:39
KICOMMON_API void from_json(const nlohmann::json &j, JOBSET_JOB &f)
Definition: jobset.cpp:65
FOLDER
Definition: jobset.h:60
enum KICOMMON_API JOBSET_OUTPUT_TYPE
Definition: jobset.h:59
KICOMMON_API void to_json(nlohmann::json &j, const JOBSET_JOB &f)
#define KICOMMON_API
Definition: kicommon.h:28
wxString m_id
Definition: jobset.h:46
std::shared_ptr< JOB > m_job
Definition: jobset.h:49
wxString m_description
Definition: jobset.h:48
JOBSET_JOB(const wxString &id, const wxString &type, JOB *job)
Definition: jobset.h:40
wxString m_type
Definition: jobset.h:47
JOBSET_JOB()
Definition: jobset.h:36
wxString fileWildcard
Definition: jobset.h:69
std::vector< wxString > m_only
Definition: jobset.h:89
wxString m_id
Definition: jobset.h:85
wxString m_description
Definition: jobset.h:87
JOBS_OUTPUT_HANDLER * m_outputHandler
Definition: jobset.h:88
std::unordered_map< wxString, std::optional< bool > > m_lastRunSuccessMap
Definition: jobset.h:96
std::optional< bool > m_lastRunSuccess
Definition: jobset.h:95
std::unordered_map< wxString, REPORTER * > m_lastRunReporters
Definition: jobset.h:97
JOBSET_OUTPUT_TYPE m_type
Definition: jobset.h:86