Loading...
Searching...
No Matches
patch_manager.hpp
1/*---------------------------------------------------------------------------*\
2 *
3 * bitpit
4 *
5 * Copyright (C) 2015-2021 OPTIMAD engineering Srl
6 *
7 * -------------------------------------------------------------------------
8 * License
9 * This file is part of bitpit.
10 *
11 * bitpit is free software: you can redistribute it and/or modify it
12 * under the terms of the GNU Lesser General Public License v3 (LGPL)
13 * as published by the Free Software Foundation.
14 *
15 * bitpit is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public
18 * License for more details.
19 *
20 * You should have received a copy of the GNU Lesser General Public License
21 * along with bitpit. If not, see <http://www.gnu.org/licenses/>.
22 *
23\*---------------------------------------------------------------------------*/
24
25#ifndef __BITPIT_PATCH_MANAGER_HPP__
26#define __BITPIT_PATCH_MANAGER_HPP__
27
28#include <memory>
29#include <iostream>
30#include <unordered_map>
31
32#include "bitpit_common.hpp"
33
34namespace bitpit {
35
37
38friend class PatchKernel;
39
40public:
41 BITPIT_PUBLIC_API static const int AUTOMATIC_ID;
42
43 static PatchManager & manager();
44
45 PatchKernel * get(int id);
46
47 void dump(std::ostream &stream);
48 void restore(std::istream &stream);
49
50 void dumpAll(std::ostream &stream);
51 void restoreAll(std::istream &stream);
52
53private:
54 static std::unique_ptr<PatchManager> m_manager;
55
56 IndexGenerator<int> m_idGenerator;
57 std::vector<PatchKernel *> m_patchOrder;
58 std::unordered_map<PatchKernel *, int> m_patchIds;
59
61
62 PatchManager(PatchManager const&) = delete;
63 PatchManager& operator=(PatchManager const&) = delete;
64
65 int registerPatch(PatchKernel *patch, int id = AUTOMATIC_ID);
66 void unregisterPatch(PatchKernel *patch);
67
68};
69
76namespace patch {
77
78 // Generic global functions
80
81}
82
83}
84
85#endif
The IndexGenerator class allows to generate unique ids.
The PatchKernel class provides an interface for defining patches.
The PatchManager oversee the handling of the patches.
void dumpAll(std::ostream &stream)
void restoreAll(std::istream &stream)
void dump(std::ostream &stream)
PatchKernel * get(int id)
static PatchManager & manager()
void restore(std::istream &stream)
PatchManager & manager()
--- layout: doxygen_footer ---