Tizen WASM Player
Tizen WASM Player: Tizen TV WebAssembly Media Player extension allowing for a low-level elementary media stream playback.
common.h
Go to the documentation of this file.
1 // Copyright 2020 Samsung Electronics
2 // TizenTV Emscripten extensions are available under two separate licenses, the
3 // MIT license and the University of Illinois/NCSA Open Source License. Both
4 // these licenses can be found in the LICENSE file.
5 
6 #ifndef INCLUDE_SAMSUNG_WASM_COMMON_H_
7 #define INCLUDE_SAMSUNG_WASM_COMMON_H_
8 
9 #include <chrono>
10 
12 
13 namespace samsung {
14 namespace wasm {
15 
17 template <class T>
18 struct Result {
22  T value;
23 
26 
28  explicit operator bool() const noexcept;
29 
32  T& operator*();
33 
35  const T& operator*() const;
36 
39  T* operator->();
40 
42  const T* operator->() const;
43 };
44 
46 template <>
47 struct Result<void> {
49 
50  explicit operator bool() const noexcept;
51 };
53 
55 using Seconds = std::chrono::duration<double>;
56 
57 template <class T>
58 Result<T>::operator bool() const noexcept {
59  return static_cast<bool>(Result<void>{operation_result});
60 }
61 
62 inline Result<void>::operator bool() const noexcept {
64 }
65 
66 template <class T>
68  return const_cast<T&>(static_cast<const Result<T>*>(this)->operator*());
69 }
70 
71 template <class T>
72 const T& Result<T>::operator*() const {
73  return value;
74 }
75 
76 template <class T>
78  return const_cast<T*>(static_cast<const Result<T>*>(this)->operator->());
79 }
80 
81 template <class T>
82 const T* Result<T>::operator->() const {
83  return &value;
84 }
85 
86 } // namespace wasm
87 } // namespace samsung
88 
89 #endif // INCLUDE_SAMSUNG_WASM_COMMON_H_
samsung::wasm::Result::operator*
T & operator*()
Definition: common.h:67
operation_result.h
samsung::wasm::Result::operator->
T * operator->()
Definition: common.h:77
samsung::wasm::Seconds
std::chrono::duration< double > Seconds
Default duration type used throughout the API.
Definition: common.h:55
samsung::wasm::Result::operation_result
OperationResult operation_result
Operation result.
Definition: common.h:25
samsung::wasm::Result
Helper type to carry both an error code and return value.
Definition: common.h:18
samsung::wasm::Result::value
T value
Definition: common.h:22
samsung::wasm::OperationResult::kSuccess
@ kSuccess
Operation ended with success.
samsung::wasm::OperationResult
OperationResult
Enumerates possible outcomes of WASM function calls.
Definition: operation_result.h:13
samsung
Definition: html_media_element.h:15