/****************************************************************************
* Copyright 2019 Nreal Techonology Limited. All rights reserved.
*
* This file is part of NRSDK.
*
* https://www.nreal.ai/
*
*****************************************************************************/
namespace NRKernal
{
using System.Collections.Generic;
///
/// Gives access to subsystems.
/// Provides the ability to query for SubsystemDescriptors which enumerate features.
/// Given an SubsystemDescriptor, you can create an Subsystem to utilize the subsystem.
///
public static class NRSubsystemManager
{
private static List supportedDescriptors = new List()
{
new NRTrackingSubsystemDescriptor(),
new NRTrackableSubsystemDescriptor(),
new NRTrackableImageSubsystemDescriptor(),
new NRPlaneSubsystemDescriptor(),
new NRDeviceSubsystemDescriptor(),
new NRDisplaySubsystemDescriptor(),
};
///
/// Gets all of the currently known subsystem descriptors regardless of specific subsystem type.
///
/// subsystem descriptor type.
public static void GetAllSubsystemDescriptors(List descriptors)
{
if (descriptors == null)
{
descriptors = new List();
}
descriptors.Clear();
descriptors.AddRange(supportedDescriptors);
}
///
/// Get Active Subsystems of a specific instance type.
///
/// subsystem type.
///
public static void GetSubsystems(List subsystems) where TSubSystem : ISubsystem
{
if (subsystems == null)
{
subsystems = new List();
}
subsystems.Clear();
foreach (var des in supportedDescriptors)
{
var subsystem = ((IntegratedSubsystemDescriptor)des).subsystem;
if (subsystem != null && subsystem.GetType().Equals(typeof(TSubSystem)))
{
subsystems.Add((TSubSystem)subsystem);
}
}
}
///
/// Gets A list of ISubsystemDescriptor which describe additional functionality that can be enabled.
///
/// descriptor type.
///
public static void GetSubsystemDescriptors(List descriptors) where TDescriptor : ISubsystemDescriptor
{
if (descriptors == null)
{
descriptors = new List();
}
descriptors.Clear();
foreach (var descriptor in supportedDescriptors)
{
if (typeof(TDescriptor).Equals(descriptor.GetType()))
{
descriptors.Add((TDescriptor)descriptor);
}
}
}
}
}