comparison Applications/Samples/SampleApplicationContext.cpp @ 221:d7b2590744f8 am

wip: building applications reusable in SDL and WASM
author am@osimis.io
date Mon, 11 Jun 2018 14:01:02 +0200
parents
children ce4405d98b92
comparison
equal deleted inserted replaced
219:26e3bfe30e66 221:d7b2590744f8
1 /**
2 * Stone of Orthanc
3 * Copyright (C) 2012-2016 Sebastien Jodogne, Medical Physics
4 * Department, University Hospital of Liege, Belgium
5 * Copyright (C) 2017-2018 Osimis S.A., Belgium
6 *
7 * This program is free software: you can redistribute it and/or
8 * modify it under the terms of the GNU Affero General Public License
9 * as published by the Free Software Foundation, either version 3 of
10 * the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Affero General Public License for more details.
16 *
17 * You should have received a copy of the GNU Affero General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 **/
20
21
22 #include "SampleApplicationContext.h"
23
24 namespace OrthancStone
25 {
26 SampleApplicationContext::SampleApplicationContext(Orthanc::WebServiceParameters& orthanc) :
27 BaseApplicationContext(orthanc)
28 {
29 }
30
31
32 SampleApplicationContext::~SampleApplicationContext()
33 {
34 for (Interactors::iterator it = interactors_.begin(); it != interactors_.end(); ++it)
35 {
36 assert(*it != NULL);
37 delete *it;
38 }
39
40 for (SlicedVolumes::iterator it = slicedVolumes_.begin(); it != slicedVolumes_.end(); ++it)
41 {
42 assert(*it != NULL);
43 delete *it;
44 }
45
46 for (VolumeLoaders::iterator it = volumeLoaders_.begin(); it != volumeLoaders_.end(); ++it)
47 {
48 assert(*it != NULL);
49 delete *it;
50 }
51 }
52
53
54 ISlicedVolume& SampleApplicationContext::AddSlicedVolume(ISlicedVolume* volume)
55 {
56 if (volume == NULL)
57 {
58 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
59 }
60 else
61 {
62 slicedVolumes_.push_back(volume);
63 return *volume;
64 }
65 }
66
67
68 IVolumeLoader& SampleApplicationContext::AddVolumeLoader(IVolumeLoader* loader)
69 {
70 if (loader == NULL)
71 {
72 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
73 }
74 else
75 {
76 volumeLoaders_.push_back(loader);
77 return *loader;
78 }
79 }
80
81
82 IWorldSceneInteractor& SampleApplicationContext::AddInteractor(IWorldSceneInteractor* interactor)
83 {
84 if (interactor == NULL)
85 {
86 throw Orthanc::OrthancException(Orthanc::ErrorCode_NullPointer);
87 }
88
89 interactors_.push_back(interactor);
90
91 return *interactor;
92 }
93 }
94