Tanoda
DeviceList.cs
Go to the documentation of this file.
1/******************************************************************************
2 * Copyright (C) Ultraleap, Inc. 2011-2020. *
3 * *
4 * Use subject to the terms of the Apache License 2.0 available at *
5 * http://www.apache.org/licenses/LICENSE-2.0, or another agreement *
6 * between Ultraleap and you, your company or other organization. *
7 ******************************************************************************/
8
9namespace Leap {
10 using System;
11 using System.Collections.Generic;
12
19 public class DeviceList :
20 List<Device> {
21
26 public DeviceList() { }
27
31 public Device FindDeviceByHandle(IntPtr deviceHandle) {
32 for (int d = 0; d < this.Count; d++) {
33 if (this[d].Handle == deviceHandle)
34 return this[d];
35 }
36 return null;
37 }
38
44 get {
45 if (Count == 1) {
46 return this[0];
47 }
48
49 for (int d = 0; d < Count; d++) {
50 if (this[d].IsStreaming) {
51 return this[d];
52 }
53 }
54
55 return null;
56 }
57 }
58
62 public void AddOrUpdate(Device device) {
63 Device existingDevice = FindDeviceByHandle(device.Handle);
64 if (existingDevice != null) {
65 existingDevice.Update(device);
66 } else {
67 Add(device);
68 }
69 }
70
75 public bool IsEmpty {
76 get { return Count == 0; }
77 }
78 }
79}
The Device class represents a physically connected device.
Definition: Device.cs:29
void Update(float horizontalViewAngle, float verticalViewAngle, float range, float baseline, uint status, string serialNumber)
For internal use only.
Definition: Device.cs:64
IntPtr Handle
For internal use only.
Definition: Device.cs:117
The DeviceList class represents a list of Device objects.
Definition: DeviceList.cs:20
bool IsEmpty
Reports whether the list is empty.
Definition: DeviceList.cs:75
Device FindDeviceByHandle(IntPtr deviceHandle)
For internal use only.
Definition: DeviceList.cs:31
DeviceList()
Constructs an empty list of devices.
Definition: DeviceList.cs:26
void AddOrUpdate(Device device)
For internal use only.
Definition: DeviceList.cs:62
Device ActiveDevice
The device that is currently streaming tracking data. If no streaming devices are found,...
Definition: DeviceList.cs:43