Ocean
JSDeviceObject.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_OBJECT_H
9 #define META_OCEAN_INTERACTION_JS_DEVICE_OBJECT_H
10 
14 
15 namespace Ocean
16 {
17 
18 namespace Interaction
19 {
20 
21 namespace JavaScript
22 {
23 
24 /**
25  * This class implements a wrapper for a JavaScript DeviceObject object.
26  * @ingroup interactionjs
27  */
28 class OCEAN_INTERACTION_JS_EXPORT JSDeviceObject : public JSObject<JSDeviceObject, JSDevice>
29 {
30  friend class JSObject<JSDeviceObject, JSDevice>;
31  friend class JSLibrary;
32 
33  public:
34 
35  /**
36  * Definition of ids for individual accessors.
37  */
38  enum AccessorId : unsigned int
39  {
41  AI_LIBRARY
42  };
43 
44  /**
45  * Definition of ids for individual functions.
46  */
47  enum FunctionId : unsigned int
48  {
52 
56 
59 
63 
67  FI_INVALID_OBJECT_ID
68  };
69 
70  public:
71 
72  /**
73  * Returns the JavaScript name of this object.
74  * @return The object's JavaScript name
75  */
76  static inline const char* objectName();
77 
78  /**
79  * Translates a string holding a device major type into the major type value.
80  * @param majorType Major type to translate
81  * @return Major type as value
82  */
83  static Devices::Device::MajorType translateMajorType(const std::string& majorType);
84 
85  /**
86  * Translates a major type value into a string holding the major type.
87  * @param majorType Major type to translate
88  * @return Major type as string
89  */
90  static std::string translateMajorType(const Devices::Device::MajorType majorType);
91 
92  /**
93  * Translates a string holding a device minor type into the minor type value.
94  * @param majorType Major type of the minor type to translate
95  * @param minorType Mintor type to translate
96  * @return Minor type as value
97  */
98  static int translateMinorType(const Devices::Device::MajorType majorType, const std::string& minorType);
99 
100  /**
101  * Translates a minor type into a string holding the minor type.
102  * @param majorType Major type of the minor type to translate
103  * @param minorType Minor type to translate
104  * @return Minor type as string
105  */
106  static std::string translateMinorType(const Devices::Device::MajorType majorType, const int minorType);
107 
108  protected:
109 
110  /**
111  * Creates the function template and object template for this object.
112  */
113  static void createFunctionTemplate();
114 };
115 
116 inline const char* JSDeviceObject::objectName()
117 {
118  return "DeviceObject";
119 }
120 
121 }
122 
123 }
124 
125 }
126 
127 #endif // META_OCEAN_INTERACTION_JS_DEVICE_OBJECT_H
MajorType
Definition of all major device types.
Definition: devices/Device.h:38
This class is a lightweight helper class for device objects to allow event callback handling.
Definition: JSDevice.h:35
This class implements a wrapper for a JavaScript DeviceObject object.
Definition: JSDeviceObject.h:29
AccessorId
Definition of ids for individual accessors.
Definition: JSDeviceObject.h:39
@ AI_NAME
Definition: JSDeviceObject.h:40
static std::string translateMajorType(const Devices::Device::MajorType majorType)
Translates a major type value into a string holding the major type.
static int translateMinorType(const Devices::Device::MajorType majorType, const std::string &minorType)
Translates a string holding a device minor type into the minor type value.
FunctionId
Definition of ids for individual functions.
Definition: JSDeviceObject.h:48
@ FI_IS_INVALID
Definition: JSDeviceObject.h:58
@ FI_SET_FOUND_OBJECT_EVENT_FUNCTION
Definition: JSDeviceObject.h:53
@ FI_START
Definition: JSDeviceObject.h:60
@ FI_SET_LOST_OBJECT_EVENT_FUNCTION
Definition: JSDeviceObject.h:54
@ FI_PAUSE
Definition: JSDeviceObject.h:61
@ FI_INPUT
Definition: JSDeviceObject.h:50
@ FI_SAMPLE
Definition: JSDeviceObject.h:51
@ FI_IS_VALID
Definition: JSDeviceObject.h:57
@ FI_FREQUENCY
Definition: JSDeviceObject.h:49
@ FI_OBJECT_ID
Definition: JSDeviceObject.h:66
@ FI_OBJECT_DESCRIPTIONS
Definition: JSDeviceObject.h:65
@ FI_STOP
Definition: JSDeviceObject.h:62
@ FI_SET_INPUT
Definition: JSDeviceObject.h:55
@ FI_REGISTER_OBJECT
Definition: JSDeviceObject.h:64
static void createFunctionTemplate()
Creates the function template and object template for this object.
static std::string translateMinorType(const Devices::Device::MajorType majorType, const int minorType)
Translates a minor type into a string holding the minor type.
static Devices::Device::MajorType translateMajorType(const std::string &majorType)
Translates a string holding a device major type into the major type value.
static const char * objectName()
Returns the JavaScript name of this object.
Definition: JSDeviceObject.h:116
This class implements the java script interaction library object.
Definition: JSLibrary.h:32
This class implements the base class for all native wrapper of JavaScript objects.
Definition: JSObject.h:31
The namespace covering the entire Ocean framework.
Definition: Accessor.h:15