Ocean
JSDeviceManager.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) Meta Platforms, Inc. and affiliates.
3  *
4  * This source code is licensed under the MIT license found in the
5  * LICENSE file in the root directory of this source tree.
6  */
7 
8 #ifndef META_OCEAN_INTERACTION_JS_DEVICE_MANAGER_H
9 #define META_OCEAN_INTERACTION_JS_DEVICE_MANAGER_H
10 
13 
14 namespace Ocean
15 {
16 
17 namespace Interaction
18 {
19 
20 namespace JavaScript
21 {
22 
23 /**
24  * This class implements a wrapper for a JavaScript DeviceManager object.
25  * @ingroup interactionjs
26  */
27 class OCEAN_INTERACTION_JS_EXPORT JSDeviceManager : public JSBase
28 {
29  friend class JSLibrary;
30 
31  public:
32 
33  /**
34  * Returns the JavaScript name of this object.
35  * @return The object's JavaScript name
36  */
37  static inline const char* objectName();
38 
39  /**
40  * Returns the object template for this object.
41  * @return The object template
42  */
43  static inline v8::Local<v8::ObjectTemplate> objectTemplate();
44 
45  /**
46  * Releases the function and object template for this object.
47  */
48  static void release();
49 
50  protected:
51 
52  /**
53  * Creates the function object template for this object.
54  */
55  static void createObjectTemplate();
56 
57  /**
58  * Callback function for 'create()' function.
59  * @param info The function callback info
60  */
61  static void functionCreate(const v8::FunctionCallbackInfo<v8::Value>& info);
62 
63  /**
64  * Callback function for 'devices()' function.
65  * @param info The function callback info
66  */
67  static void functionDevices(const v8::FunctionCallbackInfo<v8::Value>& info);
68 
69  protected:
70 
71  /// Object template for the Vector2 object.
72  static v8::Persistent<v8::ObjectTemplate> objectTemplate_;
73 };
74 
75 inline const char* JSDeviceManager::objectName()
76 {
77  return "DeviceManager";
78 }
79 
80 inline v8::Local<v8::ObjectTemplate> JSDeviceManager::objectTemplate()
81 {
82  if (objectTemplate_.IsEmpty())
83  {
85  }
86 
87  ocean_assert(objectTemplate_.IsEmpty() == false);
88  return objectTemplate_.Get(v8::Isolate::GetCurrent());
89 }
90 
92 {
93  ocean_assert(!objectTemplate_.IsEmpty());
94  objectTemplate_.Reset();
95 }
96 
97 }
98 
99 }
100 
101 }
102 
103 #endif // META_OCEAN_INTERACTION_JS_DEVICE_MANAGER_H
This class implements the base class for all JavaScript wrappers.
Definition: JSBase.h:34
This class implements a wrapper for a JavaScript DeviceManager object.
Definition: JSDeviceManager.h:28
static void functionCreate(const v8::FunctionCallbackInfo< v8::Value > &info)
Callback function for 'create()' function.
static const char * objectName()
Returns the JavaScript name of this object.
Definition: JSDeviceManager.h:75
static v8::Persistent< v8::ObjectTemplate > objectTemplate_
Object template for the Vector2 object.
Definition: JSDeviceManager.h:72
static v8::Local< v8::ObjectTemplate > objectTemplate()
Returns the object template for this object.
Definition: JSDeviceManager.h:80
static void functionDevices(const v8::FunctionCallbackInfo< v8::Value > &info)
Callback function for 'devices()' function.
static void release()
Releases the function and object template for this object.
Definition: JSDeviceManager.h:91
static void createObjectTemplate()
Creates the function object template for this object.
This class implements the java script interaction library object.
Definition: JSLibrary.h:32
void release(T *object)
This functions allows to release a DirectShow object if it does exist.
Definition: DSObject.h:266
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15