Debian Codegraph @

Logger/LoggerServer.cpp

raw symbols SCIP
1 /*
2 RailControl - Model Railway Control Software
3
4 Copyright (c) 2017-2025 by Teddy / Dominik Mahrer - www.railcontrol.org
5
6 RailControl is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 3, or (at your option) any
9 later version.
10
11 RailControl is distributed in the hope that it will be useful, but
12 WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 See the GNU General Public License for more details.
15
16 You should have received a copy of the GNU General Public License
17 along with RailControl; see the file LICENCE. If not see
18 <http://www.gnu.org/licenses/>.
19 */
20
21 #include <iostream>
22
23 #include "Logger/Logger.h"
24 #include "Logger/LoggerServer.h"
25 #include "Utils/Utils.h"
26
27 using std::string;
28
29 namespace Logger
30 {
31 LoggerServer::~LoggerServer()
32 {
33 // delete all client memory
34 while (clients.size() > 0)
35 {
36 LoggerClient* client = clients.back();
37 clients.pop_back();
38 delete client;
39 }
40
41 // delete all logger memory
42 while (loggers.size() > 0)
43 {
44 Logger* logger = loggers.back();
45 loggers.pop_back();
46 delete logger;
47 }
48 }
49
50 Logger* LoggerServer::GetLogger(const std::string& component)
51 {
52 for (auto logger : loggers)
53 {
54 if (logger->IsComponent(component))
55 {
56 return logger;
57 }
58 }
59 Logger* logger = new Logger(*this, component);
60 loggers.push_back(logger);
61 return logger;
62 }
63
64 void LoggerServer::Send(const std::string& text)
65 {
66 for (auto client : clients)
67 {
68 client->Send(text);
69 }
70 }
71 }