1using Datalayer.Internal;
3using System.Collections.Generic;
12 private unsafe
void* _nativePtr;
17 private readonly
string _ipcPath;
19 private bool _disposedValue;
20 private bool _isStarted;
22 private readonly List<Client> _clients =
new List<Client>();
23 private readonly List<Provider> _providers =
new List<Provider>();
32 _ipcPath = ipcPath ??
throw new ArgumentNullException(nameof(ipcPath));
34 var ipcPathBuffer = StringBuffer.FromString(_ipcPath);
37 _nativePtr = NativeMethods.Datalayer.DLR_systemCreate(ipcPathBuffer.ToNativePtr());
44 unsafe
void* INative.NativePtr => _nativePtr;
49 internal List<Client> Clients => _clients;
54 internal List<Provider> Providers => _providers;
67 protected virtual void Dispose(
bool disposing)
79 _disposedValue =
true;
100 GC.SuppressFinalize(
this);
106 private void Delete()
110 if (_nativePtr ==
null)
121 NativeMethods.Datalayer.DLR_systemDelete(_nativePtr);
124 _disposedValue =
true;
131 private void DeleteChildren()
134 foreach (var client
in _clients)
141 foreach (var provider
in _providers)
149 #region Public Consts
175 #region Public Properties
187 throw new ObjectDisposedException(Utils.Strings.ErrorObjectDisposed);
204 throw new ObjectDisposedException(Utils.Strings.ErrorObjectDisposed);
222 throw new ObjectDisposedException(Utils.Strings.ErrorObjectDisposed);
227 throw new ArgumentNullException(nameof(value));
230 var valueBuffer = StringBuffer.FromString(value);
234 NativeMethods.Datalayer.DLR_systemSetBfbsPath(_nativePtr, valueBuffer.ToNativePtr());
241 #region Public Methods
255 public void Start(
bool startBroker =
false)
259 throw new ObjectDisposedException(Utils.Strings.ErrorObjectDisposed);
264 NativeMethods.Datalayer.DLR_systemStart(_nativePtr, Convert.ToByte(startBroker));
279 throw new ObjectDisposedException(Utils.Strings.ErrorObjectDisposed);
287 NativeMethods.Datalayer.DLR_systemStop(_nativePtr, Convert.ToByte(
true));
303 throw new ObjectDisposedException(Utils.Strings.ErrorObjectDisposed);
306 if (_factory ==
null)
311 throw new InvalidOperationException(
"DatalayerSystem not started");
316 void* factoryPtr = NativeMethods.Datalayer.DLR_systemFactory(_nativePtr);
317 _factory =
new Factory(
this, factoryPtr);
334 throw new ObjectDisposedException(Utils.Strings.ErrorObjectDisposed);
337 if (_converter ==
null)
341 void* converterPtr = NativeMethods.Datalayer.DLR_systemJsonConverter(_nativePtr);
342 _converter =
new Converter(converterPtr);
Provides the implementation for IDatalayerSystem.
string IpcPath
Gets the path for interprocess communication.
DatalayerSystem(string ipcPath="")
Initializes a new instance of the DatalayerSystem class.
void Stop()
Stops the DatalayerSystem.
static readonly string ProtocolSchemeTcp
Gets the protocol scheme for TCP communication. Recommended to connect to a DatalayerSystem not runni...
static readonly int DefaultProviderPort
Gets the default Provider port.
void Dispose()
Dispose the instance.
string BfbsPath
Sets the binary Flatbuffer path, which contains *.bfbs files.
static readonly int DefaultClientPort
Gets the default Client port.
virtual void Dispose(bool disposing)
Disposes the instance.
bool IsStarted
Gets a value that indicates whether the DatalayerSystem is started.
static readonly string ProtocolSchemeIpc
Gets the protocol scheme for IPC communication. Recommended to connect to a DatalayerSystem running o...
IConverter Converter
Gets the Converter for Variant to JSON conversions.
bool IsDisposed
Gets a value that indicates whether the instance is already disposed and useless.
IFactory Factory
Gets the Factory to create Clients and Providers.
void Start(bool startBroker=false)
Starts the DatalayerSystem.
The IConverter interface.
The IDatalayerSystem interface.