RStudio Launcher Plugin SDK  1.1.3
A software development kit for creating plugins that work the the RStudio Launcher.
LocalJobRepository.hpp
1 /*
2  * LocalJobRepository.hpp
3  *
4  * Copyright (C) 2020 by RStudio, PBC
5  *
6  * Unless you have received this program directly from RStudio pursuant to the terms of a commercial license agreement
7  * with RStudio, then this program is licensed to you under the following terms:
8  *
9  * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
10  * documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
11  * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to
12  * permit persons to whom the Software is furnished to do so, subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the
15  * Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
18  * WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21  *
22  */
23 
24 #ifndef LAUNCHER_PLUGINS_LOCAL_JOB_REPOSITORY_HPP
25 #define LAUNCHER_PLUGINS_LOCAL_JOB_REPOSITORY_HPP
26 
27 #include <jobs/AbstractJobRepository.hpp>
28 
29 #include <memory>
30 
31 #include <api/Job.hpp>
32 #include <jobs/JobStatusNotifier.hpp>
33 #include <system/FilePath.hpp>
34 
35 namespace rstudio {
36 namespace launcher_plugins {
37 
38 class Error;
39 
40 } // namespace launcher_plugins
41 } // namespace rstudio
42 
43 namespace rstudio {
44 namespace launcher_plugins {
45 namespace local {
46 
51 {
52 public:
59  LocalJobRepository(const std::string& in_hostname, jobs::JobStatusNotifierPtr in_notifier);
60 
66  void saveJob(api::JobPtr in_job) const;
67 
73  Error setJobOutputPaths(api::JobPtr io_job) const;
74 
75 private:
83  Error loadJobs(api::JobList& out_jobs) const override;
84 
90  void onJobAdded(const api::JobPtr& in_job) override;
91 
97  virtual void onJobRemoved(const api::JobPtr& in_job) override;
98 
104  Error onInitialize() override;
105 
107  const std::string& m_hostname;
108 
110  const system::FilePath m_jobsRootPath;
111 
113  const system::FilePath m_jobsPath;
114 
116  const bool m_saveUnspecifiedOutput;
117 
119  const system::FilePath m_outputRootPath;
120 };
121 
122 } // namespace local
123 } // namespace launcher_plugins
124 } // namespace rstudio
125 
126 #endif
rstudio::launcher_plugins::local::LocalJobRepository::saveJob
void saveJob(api::JobPtr in_job) const
Saves a job to disk.
rstudio::launcher_plugins::system::FilePath
Class which represents a path on the system. May be any type of file (e.g. directory,...
Definition: FilePath.hpp:77
rstudio::launcher_plugins::jobs::AbstractJobRepository
Stores any jobs currently in the job scheduling system.
Definition: AbstractJobRepository.hpp:50
rstudio::launcher_plugins::local::LocalJobRepository
Responsible for job persistence.
Definition: LocalJobRepository.hpp:50
rstudio::launcher_plugins::Error
Class which represents an error.
Definition: Error.hpp:174
rstudio::launcher_plugins::local::LocalJobRepository::setJobOutputPaths
Error setJobOutputPaths(api::JobPtr io_job) const
Sets the default output paths for the specified job.
rstudio::launcher_plugins::local::LocalJobRepository::LocalJobRepository
LocalJobRepository(const std::string &in_hostname, jobs::JobStatusNotifierPtr in_notifier)
Constructor.