Leosac  0.7.0
OpenSourceAccessControl
UpdateService.hpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2014-2016 Leosac
3 
4  This file is part of Leosac.
5 
6  Leosac is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Affero General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  Leosac is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Affero General Public License for more details.
15 
16  You should have received a copy of the GNU Affero General Public License
17  along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 #pragma once
21 
22 #include "UpdateFwd.hpp"
23 #include "core/SecurityContext.hpp"
24 #include "tools/JSONUtils.hpp"
25 #include "tools/bs2.hpp"
28 #include <mutex>
29 
30 namespace Leosac
31 {
32 namespace update
33 {
34 enum class Severity
35 {
36  LOW = 0,
37  NORMAL = 1,
38  HIGHT = 2,
39  CRITICAL = 3,
40 };
41 
54 {
56  virtual ~UpdateDescriptor() = default;
57 
58  std::string uuid;
60  std::string source_module;
61  std::string update_desc;
62 
63  private:
68  virtual void implement_me_() = 0;
69 };
70 
72 {
73  public:
84  virtual std::vector<UpdateDescriptorPtr> check_update() = 0;
85 
93  virtual IUpdatePtr create_update(const UpdateDescriptor &ud,
94  const ExecutionContext &) = 0;
95 
102  virtual void ack_update(IUpdatePtr u, const ExecutionContext &) = 0;
103 
110  virtual void cancel_update(IUpdatePtr u, const ExecutionContext &) = 0;
111 };
112 
127  : public ExtensibleSerializer<json, IUpdate, const SecurityContext &>
128 {
129  public:
130  std::vector<UpdateDescriptorPtr> check_update();
131 
142  IUpdatePtr create_update(const std::string &update_descriptor_uuid,
143  const ExecutionContext &ec);
144 
148  std::vector<IUpdatePtr> pending_updates();
149 
150  void ack_update(IUpdatePtr update, const ExecutionContext &ec);
151 
152  void cancel_update(IUpdatePtr update, const ExecutionContext &ec);
153 
160  void register_backend(UpdateBackendPtr backend);
161 
162  private:
163  mutable std::mutex mutex_;
164 
165  using CheckUpdateT =
166  boost::signals2::signal<std::vector<UpdateDescriptorPtr>(void),
168 
169  using CreateUpdateT =
170  boost::signals2::signal<IUpdatePtr(const UpdateDescriptor &,
171  const ExecutionContext &),
173 
174  using AckUpdateT =
175  boost::signals2::signal<void(IUpdatePtr, const ExecutionContext &)>;
176 
177  using CancelUpdateT =
178  boost::signals2::signal<void(IUpdatePtr, const ExecutionContext &)>;
179 
184 
185  std::map<std::string, UpdateDescriptorPtr> published_descriptors_;
186 };
187 }
188 }
boost::signals2::signal< void(IUpdatePtr, const ExecutionContext &)> AckUpdateT
This service provides various update management utilities.
This is the header file for a generated source file, GitSHA1.cpp.
Provides dynamic serializers management for a given object&#39;s hierarchy.
boost::signals2::signal< IUpdatePtr(const UpdateDescriptor &, const ExecutionContext &), AtMostOneCombiner< IUpdatePtr > > CreateUpdateT
A boost::signals2 combiner that makes sure that at most one slot returns a non-null pointer...
Definition: bs2.hpp:64
std::shared_ptr< IUpdate > IUpdatePtr
Definition: UpdateFwd.hpp:42
A shortname for the boost::signals2 namespace.
Definition: bs2.hpp:35
boost::signals2::signal< void(IUpdatePtr, const ExecutionContext &)> CancelUpdateT
boost::signals2::signal< std::vector< UpdateDescriptorPtr >(void), VectorAppenderCombiner< UpdateDescriptorPtr > > CheckUpdateT
std::shared_ptr< UpdateBackend > UpdateBackendPtr
Definition: UpdateFwd.hpp:49
Describe an update that has yet to be done.
std::map< std::string, UpdateDescriptorPtr > published_descriptors_
An ExecutionContext is passed around to service so they have context about who is making the call and...