comparison Platforms/Wasm/Defaults.cpp @ 242:092db46c6291 am

improved SDL/Wasm unification
author am@osimis.io
date Wed, 20 Jun 2018 14:20:55 +0200
parents f73d722d98c8
children 8ff70c04c6df
comparison
equal deleted inserted replaced
241:a4197519eb55 242:092db46c6291
4 #include <Framework/dev.h> 4 #include <Framework/dev.h>
5 #include "Framework/Widgets/TestCairoWidget.h" 5 #include "Framework/Widgets/TestCairoWidget.h"
6 #include <Framework/Viewport/WidgetViewport.h> 6 #include <Framework/Viewport/WidgetViewport.h>
7 #include <Framework/Widgets/LayerWidget.h> 7 #include <Framework/Widgets/LayerWidget.h>
8 #include <algorithm> 8 #include <algorithm>
9 #include "Applications/Wasm/StartupParametersBuilder.h"
9 10
10 static unsigned int width_ = 0; 11 static unsigned int width_ = 0;
11 static unsigned int height_ = 0; 12 static unsigned int height_ = 0;
12 13
13 /**********************************/ 14 /**********************************/
14 15
15 static std::auto_ptr<OrthancStone::BasicWasmApplication> application; 16 static std::unique_ptr<OrthancStone::IBasicApplication> application;
17 static std::unique_ptr<OrthancStone::BasicApplicationContext> context;
18 static OrthancStone::StartupParametersBuilder startupParametersBuilder;
19
16 static OrthancStone::ChangeObserver changeObserver_; 20 static OrthancStone::ChangeObserver changeObserver_;
17 static OrthancStone::StatusBar statusBar_; 21 static OrthancStone::StatusBar statusBar_;
18 22
19 23
20 static std::list<std::shared_ptr<OrthancStone::WidgetViewport>> viewports_; 24 static std::list<std::shared_ptr<OrthancStone::WidgetViewport>> viewports_;
62 66
63 printf("CreateWasmApplication\n"); 67 printf("CreateWasmApplication\n");
64 68
65 application.reset(CreateUserApplication()); 69 application.reset(CreateUserApplication());
66 70
71 startupParametersBuilder.Clear();
72 }
73
74 void EMSCRIPTEN_KEEPALIVE SetStartupParameter(const char* keyc,
75 const char* value) {
76 startupParametersBuilder.SetStartupParameter(keyc, value);
77 }
78
79 void EMSCRIPTEN_KEEPALIVE StartWasmApplication() {
80
81 printf("StartWasmApplication\n");
82
83 // recreate a command line from uri arguments and parse it
84 boost::program_options::variables_map parameters;
67 boost::program_options::options_description options; 85 boost::program_options::options_description options;
68 application->DeclareStartupOptions(options); 86 application->DeclareStartupOptions(options);
69 } 87 startupParametersBuilder.GetStartupParameters(parameters, options);
70 88
71 void EMSCRIPTEN_KEEPALIVE SetStartupParameter(const char* keyc, 89 context.reset(new OrthancStone::BasicApplicationContext(OrthancStone::WasmWebService::GetInstance()));
72 const char* value) { 90 application->Initialize(context.get(), statusBar_, parameters);
73 application->SetStartupParameter(keyc, value); 91 application->InitializeWasm();
74 }
75
76 void EMSCRIPTEN_KEEPALIVE StartWasmApplication() {
77
78 printf("StartWasmApplication\n");
79
80 // recreate a command line from uri arguments and parse it
81 boost::program_options::variables_map parameters;
82 application->GetStartupParameters(parameters);
83
84 BasicWasmApplicationContext& context = dynamic_cast<BasicWasmApplicationContext&>(application->CreateApplicationContext(OrthancStone::WasmWebService::GetInstance(), NULL));
85 application->Initialize(statusBar_, parameters);
86 92
87 // viewport->SetSize(width_, height_); 93 // viewport->SetSize(width_, height_);
88 printf("StartWasmApplication - completed\n"); 94 printf("StartWasmApplication - completed\n");
89 } 95 }
90 96