RStudio Launcher Plugin SDK  1.1.3
A software development kit for creating plugins that work the the RStudio Launcher.
AbstractJobRepository.hpp
1 /*
2  * AbstractJobRepository.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_JOB_REPOSITORY_HPP
25 #define LAUNCHER_PLUGINS_JOB_REPOSITORY_HPP
26 
27 #include <Noncopyable.hpp>
28 
29 #include <PImpl.hpp>
30 #include <api/Job.hpp>
31 #include <jobs/JobStatusNotifier.hpp>
32 
33 namespace rstudio {
34 namespace launcher_plugins {
35 namespace system {
36 
37 class User;
38 
39 } // namespace system
40 } // namespace launcher_plugins
41 } // namespace rstudio
42 
43 namespace rstudio {
44 namespace launcher_plugins {
45 namespace jobs {
46 
50 class AbstractJobRepository : public Noncopyable, public std::enable_shared_from_this<AbstractJobRepository>
51 {
52 public:
58  explicit AbstractJobRepository(JobStatusNotifierPtr in_jobStatusNotifier);
59 
63  virtual ~AbstractJobRepository() = default;
64 
72  void addJob(const api::JobPtr& in_job);
73 
85  api::JobPtr getJob(const std::string& in_jobId, const system::User& in_user = system::User()) const;
86 
96  api::JobList getJobs(const system::User& in_use = system::User()) const;
97 
103  Error initialize();
104 
112  void removeJob(const std::string& in_jobId);
113 
114 private:
124  virtual Error loadJobs(api::JobList& out_jobs) const = 0;
125 
131  virtual void onJobAdded(const api::JobPtr& in_job);
132 
138  virtual void onJobRemoved(const api::JobPtr& in_job);
139 
145  virtual Error onInitialize();
146 
147  // The private implementation of AbstractJobRepository.
148  PRIVATE_IMPL(m_impl);
149 };
150 
152 typedef std::shared_ptr<AbstractJobRepository> JobRepositoryPtr;
153 
154 } // namespace jobs
155 } // namespace launcher_plugins
156 } // namespace rstudio
157 
158 #endif
rstudio::launcher_plugins::system::User
Class which represents a system user.
Definition: User.hpp:55
rstudio::launcher_plugins::jobs::AbstractJobRepository::initialize
Error initialize()
Initializes the AbstractJobRepository.
rstudio::launcher_plugins::jobs::AbstractJobRepository
Stores any jobs currently in the job scheduling system.
Definition: AbstractJobRepository.hpp:50
rstudio::launcher_plugins::jobs::AbstractJobRepository::removeJob
void removeJob(const std::string &in_jobId)
Removes a job from the repository.
rstudio::launcher_plugins::jobs::AbstractJobRepository::~AbstractJobRepository
virtual ~AbstractJobRepository()=default
Virtual Destructor, to allow for inheritance, if necessary.
rstudio::launcher_plugins::jobs::AbstractJobRepository::addJob
void addJob(const api::JobPtr &in_job)
Adds the job to the repository.
rstudio::launcher_plugins::Error
Class which represents an error.
Definition: Error.hpp:174
rstudio::launcher_plugins::jobs::AbstractJobRepository::AbstractJobRepository
AbstractJobRepository(JobStatusNotifierPtr in_jobStatusNotifier)
Constructor.
rstudio::launcher_plugins::jobs::AbstractJobRepository::getJobs
api::JobList getJobs(const system::User &in_use=system::User()) const
Gets all jobs belonging to the specified user.
rstudio::launcher_plugins::Noncopyable
Class which can be inherited from to disallow copying of its child classes.
Definition: Noncopyable.hpp:34
rstudio::launcher_plugins::jobs::AbstractJobRepository::getJob
api::JobPtr getJob(const std::string &in_jobId, const system::User &in_user=system::User()) const
Gets the specified job for the specified user from the repository.