Leosac  0.7.0
OpenSourceAccessControl
Update.cpp
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 #include "Update.hpp"
21 
22 namespace Leosac
23 {
24 namespace update
25 {
26 
28  : id_(0)
29  , generated_at_(std::chrono::system_clock::now())
30  , status_(Status::TRANSIENT)
31  , odb_version_(0)
32 {
33 }
34 
36 {
37  return id_;
38 }
39 
41 {
42  return generated_at_;
43 }
44 
45 
47 {
48  return status_;
49 }
50 
52 {
53  status_updated_at_ = std::chrono::system_clock::now();
54  status_ = st;
55 }
56 
58 {
59  return status_updated_at_;
60 }
61 
63 {
64  checkpoint_.last(audit);
65 }
66 
68 {
69  return checkpoint_.last_id();
70 }
71 
72 const std::string &Update::source_module() const
73 {
74  return source_module_;
75 }
76 
77 void Update::source_module(const std::string &s)
78 {
79  source_module_ = s;
80 }
81 
82 const std::string &Update::description() const
83 {
84  return description_;
85 }
86 void Update::description(const std::string &d)
87 {
88  description_ = d;
89 }
90 }
91 }
unsigned long UpdateId
Definition: UpdateFwd.hpp:56
virtual Status status() const override
Definition: Update.cpp:46
This is the header file for a generated source file, GitSHA1.cpp.
STL namespace.
virtual AuditEntryId last_id() const
unsigned long AuditEntryId
Definition: AuditFwd.hpp:31
std::string source_module_
The name (as returned by get_module_name()) that created this update.
Definition: Update.hpp:89
TimePoint generated_at_
Definition: Update.hpp:68
virtual void set_checkpoint(Audit::AuditEntryPtr) override
Set the checkpoint for the update object.
Definition: Update.cpp:62
std::shared_ptr< AuditEntry > AuditEntryPtr
Definition: AuditFwd.hpp:81
virtual const std::string & description() const override
Definition: Update.cpp:82
virtual const TimePoint & generated_at() const override
Definition: Update.cpp:40
virtual UpdateId id() const override
Definition: Update.cpp:35
void last(AuditEntryLPtr)
Set the last tracked audit entry.
std::chrono::system_clock::time_point TimePoint
Definition: IUpdate.hpp:33
TimePoint status_updated_at_
Last timepoint when status was updated.
Definition: Update.hpp:81
virtual const std::string & source_module() const override
Definition: Update.cpp:72
std::string description_
Optional description for the update.
Definition: Update.hpp:94
virtual Audit::AuditEntryId get_checkpoint() const override
Definition: Update.cpp:67
Audit::AuditTracker checkpoint_
Tracks the audit entry that represents the point in time of this update.
Definition: Update.hpp:74
virtual const TimePoint & status_updated_at() const override
Definition: Update.cpp:57