/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* Licensed under the Oculus SDK License Agreement (the "License");
* you may not use the Oculus SDK except in compliance with the License,
* which is provided at the time of installation or download, or which
* otherwise accompanies this software in either electronic or hard copy form.
*
* You may obtain a copy of the License at
*
* https://developer.oculus.com/licenses/oculussdk/
*
* Unless required by applicable law or agreed to in writing, the Oculus SDK
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace Oculus.Interaction.PoseDetection.Debug
{
///
/// Defines a model for managing hierarchical relationships between active states in the Interaction SDK.
/// This interface is primarily used for debugging and visualization of active state hierarchies.
///
///
/// This interface is used in conjunction with the pose detection and debugging systems to:
///
/// - Expose parent-child relationships between active states
/// - Enable debugging visualization of state hierarchies
/// - Support different types of active state implementations through the generic ActiveStateModel
///
/// See for the base implementation.
///
public interface IActiveStateModel
{
///
/// Retrieves all child active states associated with the given parent active state.
///
/// The parent to get children for.
/// An enumerable collection of child active states. Returns empty if no children exist or if the activeState is not of the expected type.
[Obsolete("Use async version of this method", true)]
IEnumerable GetChildren(IActiveState activeState) => throw new System.NotImplementedException();
///
/// Retrieves all child active states associated with the given parent active state.
///
/// The parent to get children for.
/// An enumerable collection of child active states. Returns empty if no children exist or if the activeState is not of the expected type.
Task> GetChildrenAsync(IActiveState activeState);
}
public abstract class ActiveStateModel : IActiveStateModel
where TActiveState : class, IActiveState
{
public async Task> GetChildrenAsync(IActiveState activeState)
{
if (activeState is TActiveState type)
{
var result = await GetChildrenAsync(type);
return result;
}
return Enumerable.Empty();
}
protected abstract Task> GetChildrenAsync(TActiveState instance);
[Obsolete("Use async version of this method", true)]
public IEnumerable GetChildren(IActiveState activeState)
{
throw new System.NotImplementedException();
}
[Obsolete("Use async version of this method", true)]
protected virtual IEnumerable GetChildren(TActiveState activeState)
{
throw new System.NotImplementedException();
}
}
}