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
73std::map<JOBSET_DESTINATION_T, JOBSET_DESTINATION_T_INFO> JobsetDestinationTypeInfos;
74
75
77{
79
80 JOBSET_DESTINATION( const wxString& id, JOBSET_DESTINATION_T type );
81
83
84 void InitOutputHandler();
85
86 wxString m_id;
88 wxString m_description;
89 std::shared_ptr<JOBS_OUTPUT_HANDLER> m_outputHandler;
90 std::vector<wxString> m_only;
91
92 wxString GetDescription() const;
93 void SetDescription( const wxString& aDescription );
94
95 wxString GetPathInfo() const;
96
98 std::optional<bool> m_lastRunSuccess;
99 std::unordered_map<wxString, std::optional<bool>> m_lastRunSuccessMap;
100 std::unordered_map<wxString, REPORTER*> m_lastRunReporters;
101
102 bool operator==( const JOBSET_DESTINATION& rhs ) const;
103
104};
105
106
108{
109public:
110 JOBSET( const wxString& aFilename );
111
112 virtual ~JOBSET() {}
113
114 std::vector<JOBSET_JOB>& GetJobs()
115 {
116 return m_jobs;
117 }
118
119 std::vector<JOBSET_JOB> GetJobsForDestination( JOBSET_DESTINATION* aDestination );
120
121 std::vector<JOBSET_DESTINATION>& GetDestinations() { return m_destinations; }
122
127 JOBSET_DESTINATION* FindDestination( wxString& aDestinationStr );
128
129 bool SaveToFile( const wxString& aDirectory = "", bool aForce = false ) override;
130
131 void SetDirty( bool aFlag = true ) { m_dirty = aFlag; }
132 bool GetDirty() const { return m_dirty; }
133
134 wxString GetFullName() const { return m_fileNameWithoutPath; }
135
136 void AddNewJob( wxString aType, JOB* aJob );
137 JOBSET_DESTINATION* AddNewDestination( JOBSET_DESTINATION_T aType );
138
139 void RemoveDestination( JOBSET_DESTINATION* aDestination );
140 void MoveJobUp( size_t aJobIdx );
141 void MoveJobDown( size_t aJobIdx );
142 void RemoveJob( size_t aJobIdx );
143
144protected:
145 wxString getFileExt() const override;
146
147private:
148 std::vector<JOBSET_JOB> m_jobs;
149 std::vector<JOBSET_DESTINATION> m_destinations;
150
153};
154
155
156KICOMMON_API void to_json( nlohmann::json& j, const JOBSET_JOB& f );
157KICOMMON_API void from_json( const nlohmann::json& j, JOBSET_JOB& f );
158
159KICOMMON_API void to_json( nlohmann::json& j, const JOBSET_DESTINATION& f );
160KICOMMON_API void from_json( const nlohmann::json& j, JOBSET_DESTINATION& f );
161
162#if defined( __MINGW32__ )
165#else
166extern template class APIVISIBLE PARAM_LIST<JOBSET_JOB>;
167extern template class APIVISIBLE PARAM_LIST<JOBSET_DESTINATION>;
168#endif
169
170#endif
bool operator==(const wxAuiPaneInfo &aLhs, const wxAuiPaneInfo &aRhs)
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
Definition: jobset.h:108
std::vector< JOBSET_DESTINATION > & GetDestinations()
Definition: jobset.h:121
wxString m_fileNameWithoutPath
Definition: jobset.h:152
bool GetDirty() const
Definition: jobset.h:132
void SetDirty(bool aFlag=true)
Definition: jobset.h:131
std::vector< JOBSET_DESTINATION > m_destinations
Definition: jobset.h:149
std::vector< JOBSET_JOB > m_jobs
Definition: jobset.h:148
std::vector< JOBSET_JOB > & GetJobs()
Definition: jobset.h:114
bool m_dirty
Definition: jobset.h:151
wxString GetFullName() const
Definition: jobset.h:134
virtual ~JOBSET()
Definition: jobset.h:112
An simple container class that lets us dispatch output jobs to kifaces.
Definition: job.h:183
A pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:73
#define APIVISIBLE
Definition: import_export.h:55
enum KICOMMON_API JOBSET_DESTINATION_T
Definition: jobset.h:59
KICOMMON_API void from_json(const nlohmann::json &j, JOBSET_JOB &f)
Definition: jobset.cpp:67
FOLDER
Definition: jobset.h:60
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
std::unordered_map< wxString, REPORTER * > m_lastRunReporters
Definition: jobset.h:100
std::shared_ptr< JOBS_OUTPUT_HANDLER > m_outputHandler
Definition: jobset.h:89
JOBSET_DESTINATION_T m_type
Definition: jobset.h:87
wxString m_description
Definition: jobset.h:88
std::vector< wxString > m_only
Definition: jobset.h:90
std::optional< bool > m_lastRunSuccess
Definition: jobset.h:98
std::unordered_map< wxString, std::optional< bool > > m_lastRunSuccessMap
Definition: jobset.h:99
wxString m_id
Definition: jobset.h:86
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