8#ifndef META_OCEAN_INTERACTION_JS_EXTERNAL_H
9#define META_OCEAN_INTERACTION_JS_EXTERNAL_H
116 template <
typename TNative>
117 inline TNative&
value();
124 template <
typename TNative>
147 template <
typename TNative>
148 static inline void setValue(v8::Local<v8::Object>&
object, TNative&&
value);
156 template <
typename TNative>
157 static inline void setValue(v8::Local<v8::Object>&
object,
const TNative&
value);
166 template <
typename TNative>
167 static JSExternal*
create(TNative* data, v8::Local<v8::Object>& owner, v8::Isolate* isolate);
209template <
typename TNative>
223 ocean_assert(
data_ !=
nullptr);
232 ocean_assert(
data_ !=
nullptr);
241 ocean_assert(
data_ !=
nullptr);
250 ocean_assert(
data_ !=
nullptr);
259 ocean_assert(
data_ !=
nullptr);
268 ocean_assert(
data_ !=
nullptr);
277 ocean_assert(
data_ !=
nullptr);
286 ocean_assert(
data_ !=
nullptr);
295 ocean_assert(
data_ !=
nullptr);
304 ocean_assert(
data_ !=
nullptr);
313 ocean_assert(
data_ !=
nullptr);
322 ocean_assert(
data_ !=
nullptr);
331 ocean_assert(
data_ !=
nullptr);
340 ocean_assert(
data_ !=
nullptr);
349 ocean_assert(
data_ !=
nullptr);
358 ocean_assert(
data_ !=
nullptr);
367 ocean_assert(
data_ !=
nullptr);
376 ocean_assert(
data_ !=
nullptr);
382template <
typename TNative>
391 return TYPE_DEVICE_SAMPLE;
427 return TYPE_RENDERING_ENGINE;
433 return TYPE_RENDERING_OBJECT;
440 return TYPE_MEDIA_OBJECT;
446 return TYPE_SCENE_DESCRIPTION_NODE;
497template <
typename TNative>
504template <
typename TNative>
508 ocean_assert(externalObject !=
nullptr);
510 externalObject->
value<TNative>() = std::move(
value);
513template <
typename TNative>
517 ocean_assert(externalObject !=
nullptr);
ObjectRef< Sample > SampleRef
Definition of an object reference for samples.
Definition Measurement.h:144
This class is a lightweight helper class for device objects to allow event callback handling.
Definition JSDevice.h:35
Type type() const
Returns the type of the wrapped C++ object.
Definition JSExternal.h:215
static void destructorCallback(const v8::WeakCallbackInfo< JSExternal > &info)
The callback function which will be called from v8 once the wrapped object is not used anymore.
JSExternal & operator=(JSExternal &)=delete
Disabled assign operator.
~JSExternal()
Destructs this object.
v8::Persistent< v8::Object > persistent_
The v8 Persistent object ensuring that we get informed when the JS object is not needed anymore.
Definition JSExternal.h:206
static JSExternal * create(TNative *data, v8::Local< v8::Object > &owner, v8::Isolate *isolate)
Creates a new type-safe wrapper object for a specific native C++ object.
Definition JSExternal.h:210
TNative & value()
Returns the wrapped C++ object.
Definition JSExternal.h:383
static void setValue(v8::Local< v8::Object > &object, TNative &&value)
Sets or changes the native C++ object of an external JavaScript object.
Definition JSExternal.h:505
void * data_
The pointer to the actual native object.
Definition JSExternal.h:200
static JSExternal * external(const v8::Local< v8::Object > &object)
Returns the external object from a given JavaScript object.
Type type_
The type of the native object.
Definition JSExternal.h:203
JSExternal(const JSExternal &)=delete
Disabled copy constructor.
JSExternal(void *data, const Type type, v8::Local< v8::Object > &owner, v8::Isolate *isolate)
Creates a new type-safe wrapper object for a specific native C++ object.
Type
Definition of different external object types.
Definition JSExternal.h:57
@ TYPE_RENDERING_OBJECT
Rendering object object.
Definition JSExternal.h:81
@ TYPE_SQUARE_MATRIX_3
SquareMatrix3 object.
Definition JSExternal.h:87
@ TYPE_ROTATION
Rotation object.
Definition JSExternal.h:83
@ TYPE_DEVICE_SAMPLE
Device sample object.
Definition JSExternal.h:65
@ TYPE_VECTOR_2
Vector2 object.
Definition JSExternal.h:91
@ TYPE_SQUARE_MATRIX_4
SquareMatrix4 object.
Definition JSExternal.h:89
@ TYPE_SCENE_DESCRIPTION_NODE
Scene description node.
Definition JSExternal.h:85
@ TYPE_VECTOR_4
Vector4 object.
Definition JSExternal.h:95
@ TYPE_EULER
Euler object.
Definition JSExternal.h:67
@ TYPE_VECTOR_3
Vector3 object.
Definition JSExternal.h:93
@ TYPE_DEVICE_OBJECT
Device object object.
Definition JSExternal.h:63
@ TYPE_QUATERNION
Quaternion object.
Definition JSExternal.h:77
@ TYPE_RENDERING_ENGINE
Rendering engine object.
Definition JSExternal.h:79
@ TYPE_UNDEFINED
Undefined object.
Definition JSExternal.h:59
@ TYPE_PLANE_3
Plane3 object.
Definition JSExternal.h:75
@ TYPE_COLOR
Color object.
Definition JSExternal.h:61
@ TYPE_MEDIA_OBJECT
Media object object.
Definition JSExternal.h:73
@ TYPE_LINE_3
Line3 object.
Definition JSExternal.h:71
@ TYPE_HOMOGENOUS_MATRIX_4
HomogenousMatrix4 object.
Definition JSExternal.h:69
static JSExternal * external(const v8::Local< v8::Value > &value)
Returns the external object from a given JavaScript object.
This class implements a color defined by red, green, blue and alpha parameters.
Definition RGBAColor.h:41
constexpr bool oceanFalse()
This function is a helper function returning false any time.
Definition Base.h:590
QuaternionT< Scalar > Quaternion
Definition of the Quaternion object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION either with sin...
Definition Quaternion.h:40
PlaneT3< Scalar > Plane3
Definition of the Plane3 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION either with single ...
Definition Plane3.h:31
EulerT< Scalar > Euler
Definition of the Euler object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION either with single o...
Definition Euler.h:38
HomogenousMatrixT4< Scalar > HomogenousMatrix4
Definition of the HomogenousMatrix4 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION flag eit...
Definition HomogenousMatrix4.h:44
VectorT2< Scalar > Vector2
Definition of a 2D vector.
Definition Vector2.h:28
VectorT4< Scalar > Vector4
Definition of a 4D vector.
Definition Vector4.h:29
VectorT3< Scalar > Vector3
Definition of a 3D vector.
Definition Vector3.h:29
RotationT< Scalar > Rotation
Definition of the Rotation object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION flag either with ...
Definition Rotation.h:32
SquareMatrixT3< Scalar > SquareMatrix3
Definition of the SquareMatrix3 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION either with ...
Definition SquareMatrix3.h:43
LineT3< Scalar > Line3
Definition of the Line3 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION either with single o...
Definition Line3.h:27
SquareMatrixT4< Scalar > SquareMatrix4
Definition of the SquareMatrix4 object, depending on the OCEAN_MATH_USE_SINGLE_PRECISION either with ...
Definition SquareMatrix4.h:39
Ocean::ObjectRef< Engine > EngineRef
Definition of an engine reference object.
Definition Engine.h:30
Ocean::ObjectRef< Object > ObjectRef
Definition of a rendering object reference with an internal reference counter.
Definition Object.h:34
Ocean::ObjectRef< Node > NodeRef
Definition of a scene description node reference with an internal reference counter.
Definition scenedescription/Node.h:36
Namespace of the Interaction JavaScript library.
Definition JavaScript.h:24
Namespace of the Interaction library.
Definition Empty.h:19
The namespace covering the entire Ocean framework.
Definition Accessor.h:15