2 * Copyright(c) 2017 Samsung Electronics Co., Ltd.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
22 using System.Runtime.InteropServices;
25 internal class ObjectRegistry : BaseHandle
27 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
29 internal ObjectRegistry(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.ObjectRegistry_SWIGUpcast(cPtr), cMemoryOwn)
31 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
34 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ObjectRegistry obj)
36 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
39 protected override void Dispose(DisposeTypes type)
46 if (type == DisposeTypes.Explicit)
49 //Release your own managed resources here.
50 //You should release all of your own disposable objects here.
54 //Release your own unmanaged resources here.
55 //You should not access any managed member here except static instance.
56 //because the execution order of Finalizes is non-deterministic.
58 if (swigCPtr.Handle != global::System.IntPtr.Zero)
63 NDalicPINVOKE.delete_ObjectRegistry(swigCPtr);
65 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
72 public class ObjectCreatedEventArgs : EventArgs
74 private BaseHandle _baseHandle;
76 public BaseHandle BaseHandle
89 public class ObjectDestroyedEventArgs : EventArgs
91 private RefObject _refObject;
93 public RefObject RefObject
107 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
108 private delegate void ObjectCreatedEventCallbackDelegate(IntPtr baseHandle);
109 private DaliEventHandler<object, ObjectCreatedEventArgs> _objectRegistryObjectCreatedEventHandler;
110 private ObjectCreatedEventCallbackDelegate _objectRegistryObjectCreatedEventCallbackDelegate;
112 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
113 private delegate void ObjectDestroyedEventCallbackDelegate(IntPtr fefObject);
114 private DaliEventHandler<object, ObjectDestroyedEventArgs> _objectRegistryObjectDestroyedEventHandler;
115 private ObjectDestroyedEventCallbackDelegate _objectRegistryObjectDestroyedEventCallbackDelegate;
117 public event DaliEventHandler<object, ObjectCreatedEventArgs> ObjectCreated
123 // Restricted to only one listener
124 if (_objectRegistryObjectCreatedEventHandler == null)
126 _objectRegistryObjectCreatedEventHandler += value;
128 _objectRegistryObjectCreatedEventCallbackDelegate = new ObjectCreatedEventCallbackDelegate(OnObjectCreated);
129 this.ObjectCreatedSignal().Connect(_objectRegistryObjectCreatedEventCallbackDelegate);
138 if (_objectRegistryObjectCreatedEventHandler != null)
140 this.ObjectCreatedSignal().Disconnect(_objectRegistryObjectCreatedEventCallbackDelegate);
143 _objectRegistryObjectCreatedEventHandler -= value;
148 // Callback for ObjectRegistry ObjectCreatedSignal
149 private void OnObjectCreated(IntPtr baseHandle)
151 ObjectCreatedEventArgs e = new ObjectCreatedEventArgs();
153 // Populate all members of "e" (ObjectCreatedEventArgs) with real data
154 //e.BaseHandle = BaseHandle.GetBaseHandleFromPtr(baseHandle); //GetBaseHandleFromPtr() is not present in BaseHandle.cs. Not sure what is the reason?
156 if (_objectRegistryObjectCreatedEventHandler != null)
158 //here we send all data to user event handlers
159 _objectRegistryObjectCreatedEventHandler(this, e);
163 public event DaliEventHandler<object, ObjectDestroyedEventArgs> ObjectDestroyed
169 // Restricted to only one listener
170 if (_objectRegistryObjectDestroyedEventHandler == null)
172 _objectRegistryObjectDestroyedEventHandler += value;
174 _objectRegistryObjectDestroyedEventCallbackDelegate = new ObjectDestroyedEventCallbackDelegate(OnObjectDestroyed);
175 this.ObjectDestroyedSignal().Connect(_objectRegistryObjectDestroyedEventCallbackDelegate);
184 if (_objectRegistryObjectDestroyedEventHandler != null)
186 this.ObjectDestroyedSignal().Disconnect(_objectRegistryObjectDestroyedEventCallbackDelegate);
189 _objectRegistryObjectDestroyedEventHandler -= value;
194 // Callback for ObjectRegistry ObjectDestroyedSignal
195 private void OnObjectDestroyed(IntPtr refObject)
197 ObjectDestroyedEventArgs e = new ObjectDestroyedEventArgs();
199 // Populate all members of "e" (ObjectDestroyedEventArgs) with real data
200 e.RefObject = RefObject.GetRefObjectFromPtr(refObject);
202 if (_objectRegistryObjectDestroyedEventHandler != null)
204 //here we send all data to user event handlers
205 _objectRegistryObjectDestroyedEventHandler(this, e);
210 public ObjectRegistry() : this(NDalicPINVOKE.new_ObjectRegistry__SWIG_0(), true)
212 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
215 public ObjectRegistry(ObjectRegistry handle) : this(NDalicPINVOKE.new_ObjectRegistry__SWIG_1(ObjectRegistry.getCPtr(handle)), true)
217 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
220 public ObjectRegistry Assign(ObjectRegistry rhs)
222 ObjectRegistry ret = new ObjectRegistry(NDalicPINVOKE.ObjectRegistry_Assign(swigCPtr, ObjectRegistry.getCPtr(rhs)), false);
223 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
227 public ObjectCreatedSignal ObjectCreatedSignal()
229 ObjectCreatedSignal ret = new ObjectCreatedSignal(NDalicPINVOKE.ObjectRegistry_ObjectCreatedSignal(swigCPtr), false);
230 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
234 public ObjectDestroyedSignal ObjectDestroyedSignal()
236 ObjectDestroyedSignal ret = new ObjectDestroyedSignal(NDalicPINVOKE.ObjectRegistry_ObjectDestroyedSignal(swigCPtr), false);
237 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();