Mercurial > hg > orthanc-stone
annotate Applications/Samples/Common/SampleHelpers.h @ 1851:739a69562826
cppcheck
author | Sebastien Jodogne <s.jodogne@gmail.com> |
---|---|
date | Tue, 29 Jun 2021 14:25:58 +0200 |
parents | 9ac2a65d4172 |
children | 3889ae96d2e9 |
rev | line source |
---|---|
1458
828a9b4ee1b7
added missing copyright
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1457
diff
changeset
|
1 /** |
828a9b4ee1b7
added missing copyright
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1457
diff
changeset
|
2 * Stone of Orthanc |
828a9b4ee1b7
added missing copyright
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1457
diff
changeset
|
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics |
828a9b4ee1b7
added missing copyright
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1457
diff
changeset
|
4 * Department, University Hospital of Liege, Belgium |
1739
9ac2a65d4172
upgrade to year 2021
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1596
diff
changeset
|
5 * Copyright (C) 2017-2021 Osimis S.A., Belgium |
1458
828a9b4ee1b7
added missing copyright
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1457
diff
changeset
|
6 * |
828a9b4ee1b7
added missing copyright
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1457
diff
changeset
|
7 * This program is free software: you can redistribute it and/or |
828a9b4ee1b7
added missing copyright
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1457
diff
changeset
|
8 * modify it under the terms of the GNU Affero General Public License |
828a9b4ee1b7
added missing copyright
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1457
diff
changeset
|
9 * as published by the Free Software Foundation, either version 3 of |
828a9b4ee1b7
added missing copyright
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1457
diff
changeset
|
10 * the License, or (at your option) any later version. |
828a9b4ee1b7
added missing copyright
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1457
diff
changeset
|
11 * |
828a9b4ee1b7
added missing copyright
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1457
diff
changeset
|
12 * This program is distributed in the hope that it will be useful, but |
828a9b4ee1b7
added missing copyright
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1457
diff
changeset
|
13 * WITHOUT ANY WARRANTY; without even the implied warranty of |
828a9b4ee1b7
added missing copyright
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1457
diff
changeset
|
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
828a9b4ee1b7
added missing copyright
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1457
diff
changeset
|
15 * Affero General Public License for more details. |
1596
4fb8fdf03314
removed annoying whitespace
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1538
diff
changeset
|
16 * |
1458
828a9b4ee1b7
added missing copyright
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1457
diff
changeset
|
17 * You should have received a copy of the GNU Affero General Public License |
828a9b4ee1b7
added missing copyright
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1457
diff
changeset
|
18 * along with this program. If not, see <http://www.gnu.org/licenses/>. |
828a9b4ee1b7
added missing copyright
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1457
diff
changeset
|
19 **/ |
828a9b4ee1b7
added missing copyright
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1457
diff
changeset
|
20 |
828a9b4ee1b7
added missing copyright
Sebastien Jodogne <s.jodogne@gmail.com>
parents:
1457
diff
changeset
|
21 |
1382
9d138883be66
Proper command-line parameter management for SDL sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
22 #pragma once |
9d138883be66
Proper command-line parameter management for SDL sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
23 |
1457 | 24 #include <Logging.h> |
1386
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1383
diff
changeset
|
25 |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1383
diff
changeset
|
26 #include <boost/algorithm/string.hpp> |
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1383
diff
changeset
|
27 |
1382
9d138883be66
Proper command-line parameter management for SDL sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
28 #include <string> |
9d138883be66
Proper command-line parameter management for SDL sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
29 #include <iostream> |
9d138883be66
Proper command-line parameter management for SDL sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
30 |
9d138883be66
Proper command-line parameter management for SDL sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
31 namespace OrthancStoneHelpers |
9d138883be66
Proper command-line parameter management for SDL sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
32 { |
9d138883be66
Proper command-line parameter management for SDL sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
33 inline void SetLogLevel(std::string logLevel) |
9d138883be66
Proper command-line parameter management for SDL sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
34 { |
9d138883be66
Proper command-line parameter management for SDL sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
35 boost::to_lower(logLevel); |
9d138883be66
Proper command-line parameter management for SDL sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
36 if (logLevel == "warning") |
9d138883be66
Proper command-line parameter management for SDL sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
37 { |
9d138883be66
Proper command-line parameter management for SDL sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
38 Orthanc::Logging::EnableInfoLevel(false); |
9d138883be66
Proper command-line parameter management for SDL sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
39 Orthanc::Logging::EnableTraceLevel(false); |
9d138883be66
Proper command-line parameter management for SDL sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
40 } |
9d138883be66
Proper command-line parameter management for SDL sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
41 else if (logLevel == "info") |
9d138883be66
Proper command-line parameter management for SDL sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
42 { |
9d138883be66
Proper command-line parameter management for SDL sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
43 Orthanc::Logging::EnableInfoLevel(true); |
9d138883be66
Proper command-line parameter management for SDL sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
44 Orthanc::Logging::EnableTraceLevel(false); |
9d138883be66
Proper command-line parameter management for SDL sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
45 } |
9d138883be66
Proper command-line parameter management for SDL sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
46 else if (logLevel == "trace") |
9d138883be66
Proper command-line parameter management for SDL sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
47 { |
9d138883be66
Proper command-line parameter management for SDL sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
48 Orthanc::Logging::EnableInfoLevel(true); |
9d138883be66
Proper command-line parameter management for SDL sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
49 Orthanc::Logging::EnableTraceLevel(true); |
9d138883be66
Proper command-line parameter management for SDL sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
50 } |
9d138883be66
Proper command-line parameter management for SDL sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
51 else |
9d138883be66
Proper command-line parameter management for SDL sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
52 { |
9d138883be66
Proper command-line parameter management for SDL sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
53 std::cerr << "Unknown log level \"" << logLevel << "\". Will use TRACE as default!"; |
9d138883be66
Proper command-line parameter management for SDL sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
54 Orthanc::Logging::EnableInfoLevel(true); |
9d138883be66
Proper command-line parameter management for SDL sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
55 Orthanc::Logging::EnableTraceLevel(true); |
9d138883be66
Proper command-line parameter management for SDL sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
56 } |
9d138883be66
Proper command-line parameter management for SDL sample
Benjamin Golinvaux <bgo@osimis.io>
parents:
diff
changeset
|
57 } |
1386
dfb48f0794b1
Ongoing splitting SDL vs WASM (preparing RtViewer WASM)
Benjamin Golinvaux <bgo@osimis.io>
parents:
1383
diff
changeset
|
58 } |