1 /** Copyright (c) 2017 Samsung Electronics Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
21 using System.Runtime.InteropServices;
24 internal class ObjectRegistry : BaseHandle
26 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
28 internal ObjectRegistry(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.ObjectRegistry_SWIGUpcast(cPtr), cMemoryOwn)
30 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
33 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ObjectRegistry obj)
35 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
38 protected override void Dispose(DisposeTypes type)
45 if (type == DisposeTypes.Explicit)
48 //Release your own managed resources here.
49 //You should release all of your own disposable objects here.
53 //Release your own unmanaged resources here.
54 //You should not access any managed member here except static instance.
55 //because the execution order of Finalizes is non-deterministic.
57 if (swigCPtr.Handle != global::System.IntPtr.Zero)
63 //Unreference this instance from Registry.
64 Registry.Unregister(this);
66 NDalicPINVOKE.delete_ObjectRegistry(swigCPtr);
68 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
75 public class ObjectCreatedEventArgs : EventArgs
77 private BaseHandle _baseHandle;
79 public BaseHandle BaseHandle
92 public class ObjectDestroyedEventArgs : EventArgs
94 private RefObject _refObject;
96 public RefObject RefObject
110 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
111 private delegate void ObjectCreatedEventCallbackDelegate(IntPtr baseHandle);
112 private DaliEventHandler<object, ObjectCreatedEventArgs> _objectRegistryObjectCreatedEventHandler;
113 private ObjectCreatedEventCallbackDelegate _objectRegistryObjectCreatedEventCallbackDelegate;
115 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
116 private delegate void ObjectDestroyedEventCallbackDelegate(IntPtr fefObject);
117 private DaliEventHandler<object, ObjectDestroyedEventArgs> _objectRegistryObjectDestroyedEventHandler;
118 private ObjectDestroyedEventCallbackDelegate _objectRegistryObjectDestroyedEventCallbackDelegate;
120 public event DaliEventHandler<object, ObjectCreatedEventArgs> ObjectCreated
126 // Restricted to only one listener
127 if (_objectRegistryObjectCreatedEventHandler == null)
129 _objectRegistryObjectCreatedEventHandler += value;
131 _objectRegistryObjectCreatedEventCallbackDelegate = new ObjectCreatedEventCallbackDelegate(OnObjectCreated);
132 this.ObjectCreatedSignal().Connect(_objectRegistryObjectCreatedEventCallbackDelegate);
141 if (_objectRegistryObjectCreatedEventHandler != null)
143 this.ObjectCreatedSignal().Disconnect(_objectRegistryObjectCreatedEventCallbackDelegate);
146 _objectRegistryObjectCreatedEventHandler -= value;
151 // Callback for ObjectRegistry ObjectCreatedSignal
152 private void OnObjectCreated(IntPtr baseHandle)
154 ObjectCreatedEventArgs e = new ObjectCreatedEventArgs();
156 // Populate all members of "e" (ObjectCreatedEventArgs) with real data
157 //e.BaseHandle = BaseHandle.GetBaseHandleFromPtr(baseHandle); //GetBaseHandleFromPtr() is not present in BaseHandle.cs. Not sure what is the reason?
159 if (_objectRegistryObjectCreatedEventHandler != null)
161 //here we send all data to user event handlers
162 _objectRegistryObjectCreatedEventHandler(this, e);
166 public event DaliEventHandler<object, ObjectDestroyedEventArgs> ObjectDestroyed
172 // Restricted to only one listener
173 if (_objectRegistryObjectDestroyedEventHandler == null)
175 _objectRegistryObjectDestroyedEventHandler += value;
177 _objectRegistryObjectDestroyedEventCallbackDelegate = new ObjectDestroyedEventCallbackDelegate(OnObjectDestroyed);
178 this.ObjectDestroyedSignal().Connect(_objectRegistryObjectDestroyedEventCallbackDelegate);
187 if (_objectRegistryObjectDestroyedEventHandler != null)
189 this.ObjectDestroyedSignal().Disconnect(_objectRegistryObjectDestroyedEventCallbackDelegate);
192 _objectRegistryObjectDestroyedEventHandler -= value;
197 // Callback for ObjectRegistry ObjectDestroyedSignal
198 private void OnObjectDestroyed(IntPtr refObject)
200 ObjectDestroyedEventArgs e = new ObjectDestroyedEventArgs();
202 // Populate all members of "e" (ObjectDestroyedEventArgs) with real data
203 e.RefObject = RefObject.GetRefObjectFromPtr(refObject);
205 if (_objectRegistryObjectDestroyedEventHandler != null)
207 //here we send all data to user event handlers
208 _objectRegistryObjectDestroyedEventHandler(this, e);
213 public ObjectRegistry() : this(NDalicPINVOKE.new_ObjectRegistry__SWIG_0(), true)
215 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
218 public ObjectRegistry(ObjectRegistry handle) : this(NDalicPINVOKE.new_ObjectRegistry__SWIG_1(ObjectRegistry.getCPtr(handle)), true)
220 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
223 public ObjectRegistry Assign(ObjectRegistry rhs)
225 ObjectRegistry ret = new ObjectRegistry(NDalicPINVOKE.ObjectRegistry_Assign(swigCPtr, ObjectRegistry.getCPtr(rhs)), false);
226 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
230 public ObjectCreatedSignal ObjectCreatedSignal()
232 ObjectCreatedSignal ret = new ObjectCreatedSignal(NDalicPINVOKE.ObjectRegistry_ObjectCreatedSignal(swigCPtr), false);
233 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
237 public ObjectDestroyedSignal ObjectDestroyedSignal()
239 ObjectDestroyedSignal ret = new ObjectDestroyedSignal(NDalicPINVOKE.ObjectRegistry_ObjectDestroyedSignal(swigCPtr), false);
240 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();