VM2D 1.14
Vortex methods for 2D flows simulation
Loading...
Searching...
No Matches
LogStream.h
Go to the documentation of this file.
1/*--------------------------------*- VM2D -*-----------------*---------------*\
2| ## ## ## ## #### ##### | | Version 1.14 |
3| ## ## ### ### ## ## ## ## | VM2D: Vortex Method | 2026/03/06 |
4| ## ## ## # ## ## ## ## | for 2D Flow Simulation *----------------*
5| #### ## ## ## ## ## | Open Source Code |
6| ## ## ## ###### ##### | https://www.github.com/vortexmethods/VM2D |
7| |
8| Copyright (C) 2017-2026 I. Marchevsky, K. Sokol, E. Ryatina, A. Kolganova |
9*-----------------------------------------------------------------------------*
10| File name: LogStream.h |
11| Info: Source code of VM2D |
12| |
13| This file is part of VM2D. |
14| VM2D is free software: you can redistribute it and/or modify it |
15| under the terms of the GNU General Public License as published by |
16| the Free Software Foundation, either version 3 of the License, or |
17| (at your option) any later version. |
18| |
19| VM2D is distributed in the hope that it will be useful, but WITHOUT |
20| ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
21| FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
22| for more details. |
23| |
24| You should have received a copy of the GNU General Public License |
25| along with VM2D. If not, see <http://www.gnu.org/licenses/>. |
26\*---------------------------------------------------------------------------*/
27
28
40#ifndef LOGSTREAM_H
41#define LOGSTREAM_H
42
43#include <ostream>
44#include <string>
45
46namespace VMlib
47{
48
57 {
58 private:
60 std::ostream* pStr;
61
63 std::string label;
64
65 public:
66
71 : pStr(nullptr), label("") {};
72
73
80 void assignStream(std::ostream* pStr_, const std::string& label_)
81 {
82 pStr = pStr_;
83 label = label_;
84 }
85
86
93 void inheritStream(LogStream& infoStream_, const std::string& label_)
94 {
95 assignStream(infoStream_.pStr, infoStream_.label + "->" + label_);
96 }
97
100
101
103 void endl()
104 {
105 *pStr << std::endl;
106 }
107
108
121 std::ostream& operator() (char c)
122 {
123 if (pStr != nullptr)
124 {
125 switch (c)
126 {
127 case 'i':
128 *pStr << label << (label.length() > 0 ? " " : "") << "info: ";
129 break;
130
131 case 'e':
132 *pStr << label << (label.length() > 0 ? " " : "") << "ERROR: ";
133 break;
134
135 case 't':
136 *pStr << label << (label.length() > 0 ? " " : "") << "tele: ";
137 break;
138
139 case '-':
140 *pStr << " ";
141 break;
142
143 case '_':
144 *pStr << " ";
145 break;
146
147 }
148 return *pStr;
149 }
150 else
151 {
152 pStr = new std::ostream(NULL);
153 return *pStr;
154 }
155 }
156 };
157
158}//namespace VMlib;
159
160#endif
Класс, определяющий работу с потоком логов
Definition LogStream.h:57
void endl()
Вывод в поток логов пустой строки
Definition LogStream.h:103
LogStream()
Конструктор
Definition LogStream.h:70
void inheritStream(LogStream &infoStream_, const std::string &label_)
Связывание потока логов с потоком вывода от другого потока логов
Definition LogStream.h:93
std::ostream * pStr
Указатель на поток вывода
Definition LogStream.h:60
std::string label
Метка потока
Definition LogStream.h:63
void assignStream(std::ostream *pStr_, const std::string &label_)
Связывание потока логов с потоком вывода
Definition LogStream.h:80
std::ostream & operator()(char c)
Оператор вывода в поток логов
Definition LogStream.h:121
~LogStream()
Деструктор
Definition LogStream.h:99