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 (C) 2024 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 <jobs/job.h>
25#include <jobs/jobs_output.h>
27#include <settings/parameters.h>
28#include <ctime>
29#include <memory>
30
32{
33 JOBSET_JOB() : m_job( nullptr ) {}
34
35 JOBSET_JOB( wxString id, wxString type, JOB* job ) : m_id( id ), m_type( type ), m_job( job ) {}
36
37 wxString m_id;
38 wxString m_type;
39 std::shared_ptr<JOB> m_job;
40
41 bool operator==( const JOBSET_JOB& rhs ) const;
42};
43
45{
46 FOLDER,
48};
49
51{
53
54 JOBSET_OUTPUT( wxString id, JOBSET_OUTPUT_TYPE type );
55
56 void InitOutputHandler();
57
58 wxString m_id;
61 std::vector<wxString> m_only;
62
64 std::optional<bool> m_lastRunSuccess;
65 std::unordered_map<wxString, std::optional<bool>> m_lastRunSuccessMap;
66
67 bool operator==( const JOBSET_OUTPUT& rhs ) const;
68
69};
70
72{
73public:
74 JOBSET( const wxString& aFilename );
75
76 virtual ~JOBSET() {}
77
78 std::vector<JOBSET_JOB>& GetJobs()
79 {
80 return m_jobs;
81 }
82
83 std::vector<JOBSET_JOB> GetJobsForOutput( JOBSET_OUTPUT* aOutput );
84
85 std::vector<JOBSET_OUTPUT>& GetOutputs() { return m_outputs; }
86
87 JOBSET_OUTPUT* GetOutput( wxString& aOutput );
88
89 bool SaveToFile( const wxString& aDirectory = "", bool aForce = false ) override;
90
91 void SetDirty() { m_dirty = true; }
92 bool GetDirty() const { return m_dirty; }
93
94 wxString GetFullName() const { return m_fileNameWithoutPath; }
95
96 void AddNewJob( wxString aType, JOB* aJob );
97 JOBSET_OUTPUT* AddNewJobOutput( JOBSET_OUTPUT_TYPE aType );
98
99 void RemoveOutput( JOBSET_OUTPUT* aOutput );
100 void MoveJobUp( size_t aJobIdx );
101 void MoveJobDown( size_t aJobIdx );
102 void RemoveJob( size_t aJobIdx );
103
104protected:
105 wxString getFileExt() const override;
106
107private:
108 std::vector<JOBSET_JOB> m_jobs;
109 std::vector<JOBSET_OUTPUT> m_outputs;
110
113};
114
115KICOMMON_API void to_json( nlohmann::json& j, const JOBSET_JOB& f );
116KICOMMON_API void from_json( const nlohmann::json& j, JOBSET_JOB& f );
117
118KICOMMON_API void to_json( nlohmann::json& j, const JOBSET_OUTPUT& f );
119KICOMMON_API void from_json( const nlohmann::json& j, JOBSET_OUTPUT& f );
120
121#if defined( __MINGW32__ )
124#else
125extern template class APIVISIBLE PARAM_LIST<JOBSET_JOB>;
126extern template class APIVISIBLE PARAM_LIST<JOBSET_OUTPUT>;
127#endif
128
129#endif
bool operator==(const wxAuiPaneInfo &aLhs, const wxAuiPaneInfo &aRhs)
Definition: jobset.h:72
wxString m_fileNameWithoutPath
Definition: jobset.h:112
bool GetDirty() const
Definition: jobset.h:92
void SetDirty()
Definition: jobset.h:91
std::vector< JOBSET_JOB > m_jobs
Definition: jobset.h:108
std::vector< JOBSET_OUTPUT > m_outputs
Definition: jobset.h:109
std::vector< JOBSET_JOB > & GetJobs()
Definition: jobset.h:78
bool m_dirty
Definition: jobset.h:111
std::vector< JOBSET_OUTPUT > & GetOutputs()
Definition: jobset.h:85
wxString GetFullName() const
Definition: jobset.h:94
virtual ~JOBSET()
Definition: jobset.h:76
An simple container class that lets us dispatch output jobs to kifaces.
Definition: job.h:79
#define APIVISIBLE
Definition: import_export.h:55
JOBSET_OUTPUT_TYPE
Definition: jobset.h:45
KICOMMON_API void from_json(const nlohmann::json &j, JOBSET_JOB &f)
Definition: jobset.cpp:53
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:37
std::shared_ptr< JOB > m_job
Definition: jobset.h:39
JOBSET_JOB(wxString id, wxString type, JOB *job)
Definition: jobset.h:35
wxString m_type
Definition: jobset.h:38
JOBSET_JOB()
Definition: jobset.h:33
std::vector< wxString > m_only
Transient property, not stored for now.
Definition: jobset.h:61
wxString m_id
Definition: jobset.h:58
JOBS_OUTPUT_HANDLER * m_outputHandler
Definition: jobset.h:60
std::unordered_map< wxString, std::optional< bool > > m_lastRunSuccessMap
Definition: jobset.h:65
std::optional< bool > m_lastRunSuccess
Definition: jobset.h:64
JOBSET_OUTPUT_TYPE m_type
Definition: jobset.h:59