/src/libetonyek/src/lib/IWORKOutputManager.cpp
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
2 | | /* |
3 | | * This file is part of the libetonyek project. |
4 | | * |
5 | | * This Source Code Form is subject to the terms of the Mozilla Public |
6 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
7 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
8 | | */ |
9 | | |
10 | | #include "IWORKOutputManager.h" |
11 | | |
12 | | namespace libetonyek |
13 | | { |
14 | | |
15 | | IWORKOutputManager::IWORKOutputManager() |
16 | 1.19k | : m_active() |
17 | 1.19k | , m_saved() |
18 | 1.19k | { |
19 | 1.19k | push(); |
20 | 1.19k | } |
21 | | |
22 | | IWORKOutputManager::~IWORKOutputManager() |
23 | 1.19k | { |
24 | 1.19k | pop(); |
25 | 1.19k | assert(m_active.empty()); |
26 | 1.19k | } |
27 | | |
28 | | void IWORKOutputManager::push() |
29 | 4.77k | { |
30 | 4.77k | m_active.push(IWORKOutputElements()); |
31 | 4.77k | } |
32 | | |
33 | | void IWORKOutputManager::pop() |
34 | 4.61k | { |
35 | 4.61k | assert(!m_active.empty()); |
36 | 4.61k | m_active.pop(); |
37 | 4.61k | } |
38 | | |
39 | | IWORKOutputID_t IWORKOutputManager::save() |
40 | 3.42k | { |
41 | 3.42k | assert(!m_active.empty()); |
42 | 3.42k | m_saved.push_back(m_active.top()); |
43 | 3.42k | return IWORKOutputID_t(m_saved.size() - 1); |
44 | 3.42k | } |
45 | | |
46 | | IWORKOutputElements &IWORKOutputManager::get(IWORKOutputID_t id) |
47 | 3.42k | { |
48 | 3.42k | assert(m_saved.size() > id); |
49 | 3.42k | return m_saved.at(id); |
50 | 3.42k | } |
51 | | |
52 | | const IWORKOutputElements &IWORKOutputManager::get(IWORKOutputID_t id) const |
53 | 0 | { |
54 | 0 | return const_cast<IWORKOutputManager *>(this)->get(id); |
55 | 0 | } |
56 | | |
57 | | IWORKOutputElements &IWORKOutputManager::getCurrent() |
58 | 4.05k | { |
59 | 4.05k | assert(!m_active.empty()); |
60 | 4.05k | return m_active.top(); |
61 | 4.05k | } |
62 | | |
63 | | const IWORKOutputElements &IWORKOutputManager::getCurrent() const |
64 | 0 | { |
65 | 0 | return const_cast<IWORKOutputManager *>(this)->getCurrent(); |
66 | 0 | } |
67 | | |
68 | | } |
69 | | |
70 | | /* vim:set shiftwidth=2 softtabstop=2 expandtab: */ |