Leosac  0.8.0
Open Source Access Control
Savepoint.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 <odb/database.hxx>
23 
24 namespace Leosac
25 {
26 namespace db
27 {
28 
40 class Savepoint
41 {
42  public:
46  Savepoint(odb::database &db);
47 
51  Savepoint(odb::database &db, const std::string &name);
52 
53 
54  Savepoint(const Savepoint &) = delete;
55  Savepoint(Savepoint &&o) = delete;
56 
57  ~Savepoint();
58 
63  void release();
64 
71  bool rollback_to();
72 
73  private:
74  odb::database &db_;
75  bool released_{false};
76  std::string name_;
77 };
78 }
79 }
Leosac::db::Savepoint::Savepoint
Savepoint(odb::database &db)
Construct a Savepoint with a random name.
Definition: Savepoint.cpp:38
Leosac::db::Savepoint::rollback_to
bool rollback_to()
Rollback to the Savepoint, unless the Savepoint was already released.
Definition: Savepoint.cpp:64
Leosac::db::Savepoint::released_
bool released_
Definition: Savepoint.hpp:75
Leosac::db::Savepoint
Provide a lightweight abstraction around the SAVEPOINT SQL concept.
Definition: Savepoint.hpp:40
Leosac
This is the header file for a generated source file, GitSHA1.cpp.
Definition: APIStatusCode.hpp:22
Leosac::db::Savepoint::db_
odb::database & db_
Definition: Savepoint.hpp:74
Leosac::db::Savepoint::~Savepoint
~Savepoint()
Definition: Savepoint.cpp:50
Leosac::db::Savepoint::name_
std::string name_
Definition: Savepoint.hpp:76
Leosac::db::Savepoint::release
void release()
Release the Savepoint if it wasn't released already, otherwise does nothing.
Definition: Savepoint.cpp:55