Skip to content

Commit

Permalink
Added Dummy Systems.
Browse files Browse the repository at this point in the history
• Added dummy systems for conditional compilation.
• Updated some GUIDs.
  • Loading branch information
JohnBaracuda committed Aug 5, 2022
1 parent bca01ed commit 4a48d35
Show file tree
Hide file tree
Showing 15 changed files with 1,541 additions and 722 deletions.
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ private void DrawEnableMonitoring()
#if DISABLE_MONITORING
EditorGUILayout.HelpBox("The symbol 'DISABLE_MONITORING' is active!", MessageType.Info);
GUI.enabled = false;
EditorGUILayout.PropertyField(_enableMonitoring);
EditorGUILayout.Toggle("Enable Monitoring", false);
GUI.enabled = true;
#else
EditorGUILayout.PropertyField(_enableMonitoring);
Expand Down
1,632 changes: 993 additions & 639 deletions Assets/Baracuda/Monitoring.Example/Scenes/MonitoringExampleScene.unity

Large diffs are not rendered by default.

12 changes: 12 additions & 0 deletions Assets/Baracuda/Monitoring.Example/Scripts/FilterController.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright (c) 2022 Jonathan Lang

using System;
using UnityEngine;

namespace Baracuda.Monitoring.Example.Scripts
{
[Obsolete("This file can be removed!")]
public class FilterController : MonoBehaviour
{
}
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions Assets/Baracuda/Monitoring.Example/Scripts/MonitorInput.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright (c) 2022 Jonathan Lang

using System;
using UnityEngine;

namespace Baracuda.Monitoring.Example.Scripts
{
[Obsolete("This file can be removed!")]
public class MonitorInput : MonoBehaviour
{
}
}
11 changes: 11 additions & 0 deletions Assets/Baracuda/Monitoring.Example/Scripts/MonitorInput.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

68 changes: 42 additions & 26 deletions Assets/Baracuda/Monitoring/API/MonitoringSystems.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,21 @@ public SystemNotRegisteredException(string systemName) : base(
/// </summary>
static MonitoringSystems()
{
#if !DISABLE_MONITORING
InstallCoreSystems();
#else
InstallDummySystems();
#endif
}

/*
* Install Systems
*/

#if !DISABLE_MONITORING

private static void InstallCoreSystems()
{
var manager = new Baracuda.Monitoring.Source.Systems.MonitoringManager();
Register<IMonitoringManager>(manager);
Register<IMonitoringManagerInternal>(manager);
Expand All @@ -76,42 +91,43 @@ static MonitoringSystems()
Register<IMonitoringSettings>(settings);
Register<IMonitoringLogger>(new MonitoringLogging(settings));

#if !UNITY_EDITOR
var ticker = new MonitoringTicker(manager);
Register<IMonitoringTicker>(ticker);
Register<IMonitoringUI>(new MonitoringUISystem(manager, settings, ticker));
Register<IValueProcessorFactory>(new ValueProcessorFactory(settings));
Register<IValidatorFactory>(new ValidatorFactory());
Register<IMonitoringProfiler>(new MonitoringProfiler()).BeginProfiling(Dispatcher.RuntimeToken);
#endif
}

#if UNITY_EDITOR
/// <summary>
/// Install runtime systems. (Ticker etc.)
/// </summary>
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.SubsystemRegistration)]
private static void InstallSubsystems()
{
var manager = Resolve<IMonitoringManager>();
var settings = Resolve<IMonitoringSettings>();
if (!Application.isPlaying)
{
return;
}
#endif
var ticker = new MonitoringTicker(manager);

Register<IMonitoringTicker>(ticker);
Register<IMonitoringUI>(new MonitoringUISystem(manager, settings, ticker));
Register<IValueProcessorFactory>(new ValueProcessorFactory(settings));
Register<IValidatorFactory>(new ValidatorFactory());
Register<IMonitoringProfiler>(new MonitoringProfiler()).BeginProfiling(Dispatcher.RuntimeToken);
}

/// <summary>
/// Begin assembly profiling.
/// </summary>
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.AfterAssembliesLoaded)]
private static void InstallReflectionSubsystems()

#else // DISABLE_MONITORING

private static void InstallDummySystems()
{
Register<IMonitoringProfiler>(new MonitoringProfiler()).BeginProfiling(Dispatcher.RuntimeToken);
Register<IMonitoringPlugin>(new MonitoringPluginData());
var settings = MonitoringSettings.FindOrCreateSettingsAsset();
var dummy = new MonitoringSystemDummy();
Register<IMonitoringSettings>(settings);
Register<IMonitoringManager>(dummy);
Register<IMonitoringUI>(dummy);
Register<IMonitoringUtility>(dummy);

Register<IMonitoringManagerInternal>(dummy);
Register<IMonitoringUtilityInternal>(dummy);
Register<IMonitoringLogger>(dummy);
Register<IMonitoringTicker>(dummy);
Register<IValueProcessorFactory>(dummy);
Register<IValidatorFactory>(dummy);
Register<IMonitoringProfiler>(dummy);
}
#endif



#endregion
}
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 1 addition & 11 deletions Assets/Baracuda/Monitoring/Source/Systems/MonitoringManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,17 +64,13 @@ public event ProfilingCompletedListener ProfilingCompleted
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void RegisterTarget<T>(T target) where T : class
{
#if !DISABLE_MONITORING
RegisterTargetInternal(target);
#endif
}

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public void UnregisterTarget<T>(T target) where T : class
{
#if !DISABLE_MONITORING
UnregisterTargetInternal(target);
#endif
}

/*
Expand All @@ -90,7 +86,6 @@ public void UnregisterTarget<T>(T target) where T : class
[Pure]
public IReadOnlyList<IMonitorUnit> GetAllMonitoringUnits() => _monitoringUnitCache;

public bool ValidationTickEnabled { get; set; } = true;

#endregion

Expand All @@ -112,7 +107,6 @@ public void UnregisterTarget<T>(T target) where T : class
private volatile bool _isInitialized = false;
private ProfilingCompletedListener _profilingCompleted;


#if DEBUG
private readonly HashSet<object> _registeredObjects = new HashSet<object>();
#endif
Expand Down Expand Up @@ -148,9 +142,7 @@ private void RaiseUnitDisposed(IMonitorUnit monitorUnit)
/*
* Conditional Compilation
*/

#if !DISABLE_MONITORING


#region --- Target Registration ---

[MethodImpl(MethodImplOptions.AggressiveInlining)]
Expand Down Expand Up @@ -331,7 +323,5 @@ private void CreateStaticUnit(MonitorProfile staticProfile)
}

#endregion

#endif //DISABLE_MONITORING
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@

namespace Baracuda.Monitoring.Source.Systems
{
#if !DISABLE_MONITORING

/// <summary>
/// Class responsible for creating <see cref="MonitorProfile"/>s for member found in custom assemblies that were
/// flagged to be monitored by the use of a <see cref="MonitorAttribute"/>.
Expand Down Expand Up @@ -1160,5 +1158,4 @@ private void PostProfileGenericTypeMethodInfo(Type type)
#endregion

}
#endif // !DISABLE_MONITORING
}
Loading

0 comments on commit 4a48d35

Please sign in to comment.