Example #1
0
 public MouseDeviceManager(
     IMixedRealityServiceRegistrar registrar,
     IMixedRealityInputSystem inputSystem,
     string name   = null,
     uint priority = DefaultPriority,
     BaseMixedRealityProfile profile = null) : this(inputSystem, name, priority, profile)
 {
     Registrar = registrar;
 }
 public WindowsDictationInputProvider(
     IMixedRealityServiceRegistrar registrar,
     IMixedRealityInputSystem inputSystem,
     string name   = null,
     uint priority = DefaultPriority,
     BaseMixedRealityProfile profile = null) : this(inputSystem, name, priority, profile)
 {
     Registrar = registrar;
 }
Example #3
0
 protected BaseSpatialObserver(
     IMixedRealityServiceRegistrar registrar,
     IMixedRealitySpatialAwarenessSystem spatialAwarenessSystem,
     string name   = null,
     uint priority = DefaultPriority,
     BaseMixedRealityProfile profile = null) : this(spatialAwarenessSystem, name, priority, profile)
 {
     Registrar = registrar;
 }
 public MixedRealitySpatialAwarenessSystem(
     IMixedRealityServiceRegistrar registrar,
     MixedRealitySpatialAwarenessSystemProfile profile) : base(registrar, profile)
 {
     if (registrar == null)
     {
         Debug.LogError("The MixedRealitySpatialAwarenessSystem object requires a valid IMixedRealityServiceRegistrar instance.");
     }
 }
Example #5
0
 protected BaseDataProvider(
     IMixedRealityServiceRegistrar registrar,
     IMixedRealityService service,
     string name   = null,
     uint priority = DefaultPriority,
     BaseMixedRealityProfile profile = null) : this(service, name, priority, profile)
 {
     Registrar = registrar;
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="registrar">The <see cref="IMixedRealityServiceRegistrar"/> instance that loaded the service.</param>
 /// <param name="name">Friendly name of the service.</param>
 /// <param name="priority">Service priority. Used to determine order of instantiation.</param>
 /// <param name="profile">The service's configuration profile.</param>
 public WindowsMixedRealitySpatialMeshObserver(
     IMixedRealityServiceRegistrar registrar,
     IMixedRealitySpatialAwarenessSystem spatialAwarenessSystem,
     string name   = null,
     uint priority = DefaultPriority,
     BaseMixedRealityProfile profile = null) : base(registrar, spatialAwarenessSystem, name, priority, profile)
 {
     ReadProfile();
 }
Example #7
0
 public WindowsMixedRealityEyeGazeDataProvider(
     IMixedRealityServiceRegistrar registrar,
     IMixedRealityInputSystem inputSystem,
     string name,
     uint priority,
     BaseMixedRealityProfile profile) : this(inputSystem, name, priority, profile)
 {
     Registrar = registrar;
 }
 public HandJointService(
     IMixedRealityServiceRegistrar registrar,
     IMixedRealityInputSystem inputSystem,
     string name,
     uint priority,
     BaseMixedRealityProfile profile) : this(inputSystem, name, priority, profile)
 {
     Registrar = registrar;
 }
Example #9
0
 public TestBaseDataProvider(
     IMixedRealityServiceRegistrar registrar,
     IMixedRealityService service,
     string name   = null,
     uint priority = DefaultPriority,
     BaseMixedRealityProfile profile = null)
     : base(registrar, service, name, priority, profile)
 {
 }
Example #10
0
 protected BaseInputSimulationService(
     IMixedRealityServiceRegistrar registrar,
     IMixedRealityInputSystem inputSystem,
     string name,
     uint priority,
     BaseMixedRealityProfile profile) : this(inputSystem, name, priority, profile)
 {
     Registrar = registrar;
 }
 public MixedRealityTeleportSystem(
     IMixedRealityServiceRegistrar registrar) : base(registrar, null) // Teleport system does not use a profile
 {
     if (registrar == null)
     {
         Debug.LogError("The MixedRealityTeleportSystem object requires a valid IMixedRealityServiceRegistrar instance.");
     }
     IsInputSystemEnabled = (registrar.GetService <IMixedRealityInputSystem>(showLogs: false) != null);
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="registrar">The <see cref="IMixedRealityServiceRegistrar"/> instance that loaded the service.</param>
 /// <param name="name">Friendly name of the service.</param>
 /// <param name="priority">Service priority. Used to determine order of instantiation.</param>
 /// <param name="profile">The service's configuration profile.</param>
 public WindowsSpeechInputProvider(
     IMixedRealityServiceRegistrar registrar,
     IMixedRealityInputSystem inputSystem,
     MixedRealityInputSystemProfile inputSystemProfile,
     Transform playspace,
     string name   = null,
     uint priority = DefaultPriority,
     BaseMixedRealityProfile profile = null) : base(registrar, inputSystem, inputSystemProfile, playspace, name, priority, profile)
 {
 }
 public InputSimulationService(
     IMixedRealityServiceRegistrar registrar,
     IMixedRealityInputSystem inputSystem,
     MixedRealityInputSystemProfile inputSystemProfile,
     Transform playspace,
     string name,
     uint priority,
     BaseMixedRealityProfile profile) : base(registrar, inputSystem, inputSystemProfile, playspace, name, priority, profile)
 {
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="registrar">The <see cref="IMixedRealityServiceRegistrar"/> instance that loaded the data provider.</param>
 /// <param name="inputSystem">The <see cref="Microsoft.MixedReality.Toolkit.Input.IMixedRealityInputSystem"/> instance that receives data from this provider.</param>
 /// <param name="inputSystemProfile">The input system configuration profile.</param>
 /// <param name="playspace">The <see href="https://docs.unity3d.com/ScriptReference/Transform.html">Transform</see> of the playspace object.</param>
 /// <param name="name">Friendly name of the service.</param>
 /// <param name="priority">Service priority. Used to determine order of instantiation.</param>
 /// <param name="profile">The service's configuration profile.</param>
 public CustomMouseDeviceManager(
     IMixedRealityServiceRegistrar registrar,
     IMixedRealityInputSystem inputSystem,
     MixedRealityInputSystemProfile inputSystemProfile,
     Transform playspace,
     string name   = null,
     uint priority = DefaultPriority,
     BaseMixedRealityProfile profile = null) : base(registrar, inputSystem, inputSystemProfile, playspace, name, priority, profile)
 {
 }
Example #15
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="name">Friendly name of the service.</param>
 /// <param name="priority">Service priority. Used to determine order of instantiation.</param>
 /// <param name="profile">The service's configuration profile.</param>
 public WindowsMixedRealityEyeGazeDataProvider(
     IMixedRealityServiceRegistrar registrar,
     IMixedRealityInputSystem inputSystem,
     MixedRealityInputSystemProfile inputSystemProfile,
     Transform playspace,
     string name,
     uint priority,
     BaseMixedRealityProfile profile) : base(registrar, inputSystem, inputSystemProfile, playspace, name, priority, profile)
 {
 }
        /// <summary>
        /// Gets the instance of the requested service from the registry.
        /// </summary>
        /// <typeparam name="T">The interface type of the service being requested.</typeparam>
        /// <param name="serviceInstance">Output parameter to receive the requested service instance.</param>
        /// <param name="registrar">Output parameter to receive the registrar that loaded the service instance.</param>
        /// <param name="name">Optional name of the service.</param>
        /// <returns>
        /// True if the requested service is being returned, false otherwise.
        /// </returns>
        public static bool TryGetService<T>(
            out T serviceInstance,
            out IMixedRealityServiceRegistrar registrar,
            string name = null)
        {
            Type interfaceType = typeof(T);

            if (!registry.ContainsKey(interfaceType))
            {
                serviceInstance = default(T);
                registrar = null;
                return false;
            }

            List<KeyValuePair<IMixedRealityService, IMixedRealityServiceRegistrar>> services = registry[interfaceType];
            
            int registryIndex = -1;
            if (!string.IsNullOrWhiteSpace(name))
            {
                // Find the desired service by it's name.
                for (int i = 0; i < services.Count; i++)
                {
                    if (services[i].Key.Name != name) { continue; }

                    registryIndex = i;
                    break;
                }

                if (registryIndex == -1)
                {
                    // Failed to find the requested service.
                    serviceInstance = default(T);
                    registrar = null;
                    return false;
                }
            }
            else
            {
                if (services.Count > 1)
                {
                    Debug.LogWarning("Multiple instances of the requested service were found. Please re-call this method and provide a value for the name parameter.");
                    serviceInstance = default(T);
                    registrar = null;
                    return false;
                }
                registryIndex = 0;
            }

            IMixedRealityService tempService = services[registryIndex].Key;
            Debug.Assert(tempService is T, "The service in the registry does not match the expected type.");

            serviceInstance = (T)tempService;
            registrar = services[registryIndex].Value;
            return true;
        }
Example #17
0
 public MixedRealityDiagnosticsSystem(
     IMixedRealityServiceRegistrar registrar,
     MixedRealityDiagnosticsProfile profile,
     Transform playspace) : base(registrar, profile)
 {
     if (playspace == null)
     {
         Debug.LogError("The MixedRealityDiagnosticSystem object requires a valid playspace Transform.");
     }
     Playspace = playspace;
 }
        /// <summary>
        /// Removes an <see cref="IMixedRealityService"/> instance from the registry.
        /// </summary>
        /// <param name="interfaceType">The interface type of the service being removed.</param>
        /// <param name="serviceInstance">Instance of the service to remove.</param>
        /// <param name="registrar">Instance of the registrar manages the service.</param>
        /// <returns>
        /// True if the service was successfully removed, false otherwise.
        /// </returns>
        private static bool RemoveServiceInternal(
            Type interfaceType,
            IMixedRealityService serviceInstance,
            IMixedRealityServiceRegistrar registrar)
        {
            if (!registry.ContainsKey(interfaceType)) { return false; }

            List<KeyValuePair<IMixedRealityService, IMixedRealityServiceRegistrar>> services = registry[interfaceType];

            return services.Remove(new KeyValuePair<IMixedRealityService, IMixedRealityServiceRegistrar>(serviceInstance, registrar));
        }
Example #19
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="registrar">The <see cref="IMixedRealityServiceRegistrar"/> instance that loaded the service.</param>
 /// <param name="name">The friendly name of the service.</param>
 /// <param name="priority">The registration priority of the service.</param>
 /// <param name="profile">The configuration profile for the service.</param>
 public BaseExtensionService(
     IMixedRealityServiceRegistrar registrar,
     string name   = null,
     uint priority = DefaultPriority,
     BaseMixedRealityProfile profile = null) : base()
 {
     Registrar            = registrar;
     Name                 = name;
     Priority             = priority;
     ConfigurationProfile = profile;
 }
        /// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="registrar">The <see cref="IMixedRealityServiceRegistrar"/> instance that loaded the observer.</param>
        /// <param name="spatialAwarenessSystem">The <see cref="SpatialAwareness.IMixedRealitySpatialAwarenessSystem"/> to which the observer is providing data.</param>
        /// <param name="name">The friendly name of the data provider.</param>
        /// <param name="priority">The registration priority of the data provider.</param>
        /// <param name="profile">The configuration profile for the data provider.</param>
        public BaseSpatialObserver(
            IMixedRealityServiceRegistrar registrar,
            IMixedRealitySpatialAwarenessSystem spatialAwarenessSystem,
            string name   = null,
            uint priority = DefaultPriority,
            BaseMixedRealityProfile profile = null) : base(registrar, spatialAwarenessSystem, name, priority, profile)
        {
            SpatialAwarenessSystem = spatialAwarenessSystem;

            SourceId   = (SpatialAwarenessSystem != null) ? SpatialAwarenessSystem.GenerateNewSourceId() : 0;
            SourceName = name;
        }
        private static bool TryGetServiceInternal(Type interfaceType,
                                                  out IMixedRealityService serviceInstance,
                                                  out IMixedRealityServiceRegistrar registrar,
                                                  string name = null)
        {
            // Assume failed to return null unless proven otherwise
            serviceInstance = null;
            registrar       = null;

            if (!registry.ContainsKey(interfaceType))
            {
                return(false);
            }

            List <KeyValuePair <IMixedRealityService, IMixedRealityServiceRegistrar> > services = registry[interfaceType];

            int registryIndex = -1;

            if (!string.IsNullOrWhiteSpace(name))
            {
                // Find the desired service by it's name.
                for (int i = 0; i < services.Count; i++)
                {
                    if (services[i].Key.Name != name)
                    {
                        continue;
                    }

                    registryIndex = i;
                    break;
                }

                if (registryIndex == -1)
                {
                    // Failed to find the requested service.
                    return(false);
                }
            }
            else
            {
                if (services.Count > 1)
                {
                    Debug.LogWarning("Multiple instances of the requested service were found. Please re-call this method and provide a value for the name parameter.");
                    return(false);
                }
                registryIndex = 0;
            }

            serviceInstance = services[registryIndex].Key;
            registrar       = services[registryIndex].Value;

            return(true);
        }
Example #22
0
 /// <summary>
 /// Returns readonly list of all services registered for given registrar
 /// </summary>
 /// <param name="registrar">Registrar object to filter services by</param>
 /// <remarks>
 /// The list is sorted in ascending priority order.
 /// </remarks>
 /// <returns>Readonly list of all services registered for given registrar, all services if parameter null.
 /// If given a registrar that the registry is not aware of, returns null.
 /// </returns>
 public static IReadOnlyCollection <IMixedRealityService> GetAllServices(IMixedRealityServiceRegistrar registrar)
 {
     if (registrar == null)
     {
         return(GetAllServices());
     }
     if (allServicesByRegistrar.TryGetValue(registrar, out List <IMixedRealityService> services))
     {
         return(services);
     }
     return(null);
 }
Example #23
0
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="registrar">The <see cref="IMixedRealityServiceRegistrar"/> instance that loaded the data provider.</param>
 /// <param name="service">The <see cref="IMixedRealityService"/> to which the provider is providing data.</param>
 /// <param name="name">The friendly name of the data provider.</param>
 /// <param name="priority">The registration priority of the data provider.</param>
 /// <param name="profile">The configuration profile for the data provider.</param>
 public BaseDataProvider(
     IMixedRealityServiceRegistrar registrar,
     IMixedRealityService service,
     string name   = null,
     uint priority = DefaultPriority,
     BaseMixedRealityProfile profile = null) : base()
 {
     Registrar            = registrar;
     Service              = service;
     Name                 = name;
     Priority             = priority;
     ConfigurationProfile = profile;
 }
 /// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="registrar">The <see cref="IMixedRealityServiceRegistrar"/> instance that loaded the data provider.</param>
 /// <param name="inputSystem">The <see cref="Microsoft.MixedReality.Toolkit.Input.IMixedRealityInputSystem"/> instance that receives data from this provider.</param>
 /// <param name="name">Friendly name of the service.</param>
 /// <param name="priority">Service priority. Used to determine order of instantiation.</param>
 /// <param name="profile">The service's configuration profile.</param>
 public BaseInputDeviceManager(
     IMixedRealityServiceRegistrar registrar,
     IMixedRealityInputSystem inputSystem,
     string name,
     uint priority,
     BaseMixedRealityProfile profile) : base(registrar, inputSystem, name, priority, profile)
 {
     if (inputSystem == null)
     {
         Debug.LogError($"{name} requires a valid input system instance.");
     }
     InputSystem = inputSystem;
 }
        public MixedRealityBoundarySystem(
            IMixedRealityServiceRegistrar registrar,
            MixedRealityBoundaryVisualizationProfile profile,
            Transform playspace,
            ExperienceScale scale) : base(registrar, profile)
        {
            Scale = scale;

            if (playspace == null)
            {
                Debug.LogError("The MixedRealityBoundarySystem object requires a valid playspace Transform.");
            }
            Playspace = playspace;
        }
Example #26
0
        /// <summary>
        /// Gets the first instance of the requested service from the registry that matches the given query.
        /// </summary>
        /// <param name="interfaceType">The interface type of the service being requested.</param>
        /// <param name="serviceInstance">Output parameter to receive the requested service instance.</param>
        /// <param name="registrar">Output parameter to receive the registrar that loaded the service instance.</param>
        /// <param name="name">Optional name of the service.</param>
        /// <returns>
        /// True if the requested service is being returned, false otherwise.
        /// </returns>
        public static bool TryGetService(Type interfaceType,
                                         out IMixedRealityService serviceInstance,
                                         out IMixedRealityServiceRegistrar registrar,
                                         string name = null)
        {
            if (!typeof(IMixedRealityService).IsAssignableFrom(interfaceType))
            {
                Debug.LogWarning($"Cannot find type {interfaceType.Name} since it does not extend IMixedRealityService");
                serviceInstance = null;
                registrar       = null;
                return(false);
            }

            return(TryGetServiceInternal(interfaceType, out serviceInstance, out registrar, name));
        }
Example #27
0
 /// <summary>
 /// Removes the given service/registrar combination from the GetAllServices cache
 /// </summary>
 private static void RemoveServiceFromCache(
     IMixedRealityService service,
     IMixedRealityServiceRegistrar registrar)
 {
     // Removing from the sorted list keeps sort order, so re-sorting isn't necessary
     allServices.Remove(service);
     if (allServicesByRegistrar.ContainsKey(registrar))
     {
         allServicesByRegistrar[registrar].Remove(service);
         if (allServicesByRegistrar[registrar].Count == 0)
         {
             allServicesByRegistrar.Remove(registrar);
         }
     }
 }
        /// <summary>
        /// Returns readonly list of all services registered for given registrar
        /// </summary>
        /// <param name="registrar">Registrar object to filter sevices by</param>
        /// <returns>readonly list of all services registered for given registrar, all services if parameter nul</returns>
        public static IReadOnlyCollection <IMixedRealityService> GetAllServices(IMixedRealityServiceRegistrar registrar)
        {
            List <IMixedRealityService> results = new List <IMixedRealityService>();

            foreach (var entry in registry.Values)
            {
                foreach (var tuple in entry)
                {
                    if (registrar == null || tuple.Value == registrar)
                    {
                        results.Add(tuple.Key);
                    }
                }
            }

            return(results.AsReadOnly());
        }
Example #29
0
        /// <summary>
        /// Gets the first instance of the requested service from the registry that matches the given query.
        /// </summary>
        /// <typeparam name="T">The interface type of the service being requested.</typeparam>
        /// <param name="serviceInstance">Output parameter to receive the requested service instance.</param>
        /// <param name="registrar">Output parameter to receive the registrar that loaded the service instance.</param>
        /// <param name="name">Optional name of the service.</param>
        /// <returns>
        /// True if the requested service is being returned, false otherwise.
        /// </returns>
        public static bool TryGetService <T>(
            out T serviceInstance,
            out IMixedRealityServiceRegistrar registrar,
            string name = null) where T : IMixedRealityService
        {
            Type interfaceType = typeof(T);

            if (TryGetServiceInternal(interfaceType, out IMixedRealityService tempService, out registrar, name))
            {
                Debug.Assert(tempService is T, "The service in the registry does not match the expected type.");
                serviceInstance = (T)tempService;
                return(true);
            }

            serviceInstance = default(T);
            registrar       = null;
            return(false);
        }
Example #30
0
        /// <summary>
        /// Adds the given service/registrar combination to the GetAllServices cache
        /// </summary>
        private static void AddServiceToCache(
            IMixedRealityService service,
            IMixedRealityServiceRegistrar registrar)
        {
            // Services are stored in ascending priority order - adding them to the
            // list requires that we re-enforce that order. This must happen
            // in both the allServices and allServicesByRegistrar data structures.
            allServices.Add(service);
            allServices.Sort(ascendingOrderComparer);

            if (!allServicesByRegistrar.ContainsKey(registrar))
            {
                allServicesByRegistrar.Add(registrar, new List <IMixedRealityService>());
            }

            allServicesByRegistrar[registrar].Add(service);
            allServicesByRegistrar[registrar].Sort(ascendingOrderComparer);
        }