/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 | 2.43k | : m_active() |
17 | 2.43k | , m_saved() |
18 | 2.43k | { |
19 | 2.43k | push(); |
20 | 2.43k | } |
21 | | |
22 | | IWORKOutputManager::~IWORKOutputManager() |
23 | 2.43k | { |
24 | 2.43k | pop(); |
25 | 2.43k | assert(m_active.empty()); |
26 | 2.43k | } |
27 | | |
28 | | void IWORKOutputManager::push() |
29 | 8.82k | { |
30 | 8.82k | m_active.push(IWORKOutputElements()); |
31 | 8.82k | } |
32 | | |
33 | | void IWORKOutputManager::pop() |
34 | 8.37k | { |
35 | 8.37k | assert(!m_active.empty()); |
36 | 8.37k | m_active.pop(); |
37 | 8.37k | } |
38 | | |
39 | | IWORKOutputID_t IWORKOutputManager::save() |
40 | 5.94k | { |
41 | 5.94k | assert(!m_active.empty()); |
42 | 5.94k | m_saved.push_back(m_active.top()); |
43 | 5.94k | return IWORKOutputID_t(m_saved.size() - 1); |
44 | 5.94k | } |
45 | | |
46 | | IWORKOutputElements &IWORKOutputManager::get(IWORKOutputID_t id) |
47 | 5.94k | { |
48 | 5.94k | assert(m_saved.size() > id); |
49 | 5.94k | return m_saved.at(id); |
50 | 5.94k | } |
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 | 8.06k | { |
59 | 8.06k | assert(!m_active.empty()); |
60 | 8.06k | return m_active.top(); |
61 | 8.06k | } |
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: */ |