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.
18 using System.Runtime.InteropServices;
22 internal class ObjectRegistry : BaseHandle
24 private global::System.Runtime.InteropServices.HandleRef swigCPtr;
26 internal ObjectRegistry(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.ObjectRegistry.ObjectRegistry_SWIGUpcast(cPtr), cMemoryOwn)
28 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
31 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ObjectRegistry obj)
33 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
36 protected override void Dispose(DisposeTypes type)
43 //Release your own unmanaged resources here.
44 //You should not access any managed member here except static instance.
45 //because the execution order of Finalizes is non-deterministic.
47 if (swigCPtr.Handle != global::System.IntPtr.Zero)
52 Interop.ObjectRegistry.delete_ObjectRegistry(swigCPtr);
54 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
60 /// <since_tizen> 3 </since_tizen>
61 public class ObjectCreatedEventArgs : EventArgs
63 private BaseHandle _baseHandle;
65 /// <since_tizen> 3 </since_tizen>
66 public BaseHandle BaseHandle
79 /// <since_tizen> 3 </since_tizen>
80 public class ObjectDestroyedEventArgs : EventArgs
82 private RefObject _refObject;
84 /// <since_tizen> 3 </since_tizen>
85 public RefObject RefObject
98 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
99 private delegate void ObjectCreatedEventCallbackDelegate(IntPtr baseHandle);
100 private DaliEventHandler<object, ObjectCreatedEventArgs> _objectRegistryObjectCreatedEventHandler;
101 private ObjectCreatedEventCallbackDelegate _objectRegistryObjectCreatedEventCallbackDelegate;
103 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
104 private delegate void ObjectDestroyedEventCallbackDelegate(IntPtr fefObject);
105 private DaliEventHandler<object, ObjectDestroyedEventArgs> _objectRegistryObjectDestroyedEventHandler;
106 private ObjectDestroyedEventCallbackDelegate _objectRegistryObjectDestroyedEventCallbackDelegate;
108 public event DaliEventHandler<object, ObjectCreatedEventArgs> ObjectCreated
114 // Restricted to only one listener
115 if (_objectRegistryObjectCreatedEventHandler == null)
117 _objectRegistryObjectCreatedEventHandler += value;
119 _objectRegistryObjectCreatedEventCallbackDelegate = new ObjectCreatedEventCallbackDelegate(OnObjectCreated);
120 this.ObjectCreatedSignal().Connect(_objectRegistryObjectCreatedEventCallbackDelegate);
129 if (_objectRegistryObjectCreatedEventHandler != null)
131 this.ObjectCreatedSignal().Disconnect(_objectRegistryObjectCreatedEventCallbackDelegate);
134 _objectRegistryObjectCreatedEventHandler -= value;
139 // Callback for ObjectRegistry ObjectCreatedSignal
140 private void OnObjectCreated(IntPtr baseHandle)
142 ObjectCreatedEventArgs e = new ObjectCreatedEventArgs();
144 // Populate all members of "e" (ObjectCreatedEventArgs) with real data
145 //e.BaseHandle = BaseHandle.GetBaseHandleFromPtr(baseHandle); //GetBaseHandleFromPtr() is not present in BaseHandle.cs. Not sure what is the reason?
147 if (_objectRegistryObjectCreatedEventHandler != null)
149 //here we send all data to user event handlers
150 _objectRegistryObjectCreatedEventHandler(this, e);
154 public event DaliEventHandler<object, ObjectDestroyedEventArgs> ObjectDestroyed
160 // Restricted to only one listener
161 if (_objectRegistryObjectDestroyedEventHandler == null)
163 _objectRegistryObjectDestroyedEventHandler += value;
165 _objectRegistryObjectDestroyedEventCallbackDelegate = new ObjectDestroyedEventCallbackDelegate(OnObjectDestroyed);
166 this.ObjectDestroyedSignal().Connect(_objectRegistryObjectDestroyedEventCallbackDelegate);
175 if (_objectRegistryObjectDestroyedEventHandler != null)
177 this.ObjectDestroyedSignal().Disconnect(_objectRegistryObjectDestroyedEventCallbackDelegate);
180 _objectRegistryObjectDestroyedEventHandler -= value;
185 // Callback for ObjectRegistry ObjectDestroyedSignal
186 private void OnObjectDestroyed(IntPtr refObject)
188 ObjectDestroyedEventArgs e = new ObjectDestroyedEventArgs();
190 // Populate all members of "e" (ObjectDestroyedEventArgs) with real data
191 e.RefObject = RefObject.GetRefObjectFromPtr(refObject);
193 if (_objectRegistryObjectDestroyedEventHandler != null)
195 //here we send all data to user event handlers
196 _objectRegistryObjectDestroyedEventHandler(this, e);
201 public ObjectRegistry() : this(Interop.ObjectRegistry.new_ObjectRegistry__SWIG_0(), true)
203 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
206 public ObjectRegistry(ObjectRegistry handle) : this(Interop.ObjectRegistry.new_ObjectRegistry__SWIG_1(ObjectRegistry.getCPtr(handle)), true)
208 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
211 public ObjectRegistry Assign(ObjectRegistry rhs)
213 ObjectRegistry ret = new ObjectRegistry(Interop.ObjectRegistry.ObjectRegistry_Assign(swigCPtr, ObjectRegistry.getCPtr(rhs)), false);
214 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
218 public ObjectCreatedSignal ObjectCreatedSignal()
220 ObjectCreatedSignal ret = new ObjectCreatedSignal(Interop.ObjectRegistry.ObjectRegistry_ObjectCreatedSignal(swigCPtr), false);
221 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
225 public ObjectDestroyedSignal ObjectDestroyedSignal()
227 ObjectDestroyedSignal ret = new ObjectDestroyedSignal(Interop.ObjectRegistry.ObjectRegistry_ObjectDestroyedSignal(swigCPtr), false);
228 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();