Mercurial > hg > orthanc-stone
comparison Framework/Toolbox/GenericToolbox.h @ 1331:ab81ee8fce1f broker
- Viewport is not passed and stored as a shared_ptr instead
of raw reference.
- ViewportController can now be injected with an undo
stack (not a ctor param anymore, as a preparation for the
move of the undo stack to an interactor)
- Added (temp) flag to disable emscripten events registration
in the WebAssemblyViewport (because legacy client code
deals with them directly)
- Added emscripten_clear_timeout in ~WebGLViewportsRegistry
- Removed GenericToolbox::HoldingRef whose responsibility is
better served with proper callback un-registration.
author | Benjamin Golinvaux <bgo@osimis.io> |
---|---|
date | Mon, 30 Mar 2020 14:23:46 +0200 |
parents | fd616c4a5904 |
children | 30deba7bc8e2 |
comparison
equal
deleted
inserted
replaced
1329:8d3e669f01a2 | 1331:ab81ee8fce1f |
---|---|
19 **/ | 19 **/ |
20 | 20 |
21 #pragma once | 21 #pragma once |
22 | 22 |
23 #include <Core/Compatibility.h> | 23 #include <Core/Compatibility.h> |
24 #include <Core/OrthancException.h> | |
24 | 25 |
25 #include <boost/shared_ptr.hpp> | 26 #include <boost/shared_ptr.hpp> |
26 | 27 |
27 #include <string> | 28 #include <string> |
28 #include <stdint.h> | 29 #include <stdint.h> |
301 uint8_t& alpha, | 302 uint8_t& alpha, |
302 const std::string& text) | 303 const std::string& text) |
303 { | 304 { |
304 return GetRgbaValuesFromString(red, green, blue, alpha, text.c_str()); | 305 return GetRgbaValuesFromString(red, green, blue, alpha, text.c_str()); |
305 } | 306 } |
306 | |
307 | |
308 template<typename Wrappee> | |
309 struct HoldingRef | |
310 { | |
311 HoldingRef(Wrappee* object) | |
312 { | |
313 // a crash here means that the object is not stored in a shared_ptr | |
314 // using shared_ptr is mandatory for this | |
315 object_ = object->shared_from_this(); | |
316 } | |
317 boost::shared_ptr<Wrappee> object_; | |
318 | |
319 static void* Wrap(Wrappee* object) | |
320 { | |
321 std::unique_ptr<HoldingRef<Wrappee > > up(new HoldingRef<Wrappee>(object)); | |
322 void* userData = reinterpret_cast<void*>(up.release()); | |
323 return userData; | |
324 } | |
325 | |
326 static boost::shared_ptr<Wrappee> Unwrap(void* userData) | |
327 { | |
328 // the stored shared_ptr will be deleted because of wrapping | |
329 // the data in a RAII | |
330 std::unique_ptr<HoldingRef<Wrappee > > | |
331 up(reinterpret_cast<HoldingRef<Wrappee>*>(userData)); | |
332 boost::shared_ptr<Wrappee> object = up->object_; | |
333 return object; | |
334 } | |
335 }; | |
336 } | 307 } |
337 } | 308 } |