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
25 internal ObjectRegistry(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.ObjectRegistry.ObjectRegistry_SWIGUpcast(cPtr), cMemoryOwn)
29 internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ObjectRegistry obj)
31 return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
34 protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
36 Interop.ObjectRegistry.delete_ObjectRegistry(swigCPtr);
39 /// <since_tizen> 3 </since_tizen>
40 public class ObjectCreatedEventArgs : EventArgs
42 private BaseHandle _baseHandle;
44 /// <since_tizen> 3 </since_tizen>
45 public BaseHandle BaseHandle
58 /// <since_tizen> 3 </since_tizen>
59 public class ObjectDestroyedEventArgs : EventArgs
61 private RefObject _refObject;
63 /// <since_tizen> 3 </since_tizen>
64 public RefObject RefObject
77 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
78 private delegate void ObjectCreatedEventCallbackDelegate(IntPtr baseHandle);
79 private DaliEventHandler<object, ObjectCreatedEventArgs> _objectRegistryObjectCreatedEventHandler;
80 private ObjectCreatedEventCallbackDelegate _objectRegistryObjectCreatedEventCallbackDelegate;
82 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
83 private delegate void ObjectDestroyedEventCallbackDelegate(IntPtr fefObject);
84 private DaliEventHandler<object, ObjectDestroyedEventArgs> _objectRegistryObjectDestroyedEventHandler;
85 private ObjectDestroyedEventCallbackDelegate _objectRegistryObjectDestroyedEventCallbackDelegate;
87 public event DaliEventHandler<object, ObjectCreatedEventArgs> ObjectCreated
93 // Restricted to only one listener
94 if (_objectRegistryObjectCreatedEventHandler == null)
96 _objectRegistryObjectCreatedEventHandler += value;
98 _objectRegistryObjectCreatedEventCallbackDelegate = new ObjectCreatedEventCallbackDelegate(OnObjectCreated);
99 this.ObjectCreatedSignal().Connect(_objectRegistryObjectCreatedEventCallbackDelegate);
108 if (_objectRegistryObjectCreatedEventHandler != null)
110 this.ObjectCreatedSignal().Disconnect(_objectRegistryObjectCreatedEventCallbackDelegate);
113 _objectRegistryObjectCreatedEventHandler -= value;
118 // Callback for ObjectRegistry ObjectCreatedSignal
119 private void OnObjectCreated(IntPtr baseHandle)
121 ObjectCreatedEventArgs e = new ObjectCreatedEventArgs();
123 // Populate all members of "e" (ObjectCreatedEventArgs) with real data
124 //e.BaseHandle = BaseHandle.GetBaseHandleFromPtr(baseHandle); //GetBaseHandleFromPtr() is not present in BaseHandle.cs. Not sure what is the reason?
126 if (_objectRegistryObjectCreatedEventHandler != null)
128 //here we send all data to user event handlers
129 _objectRegistryObjectCreatedEventHandler(this, e);
133 public event DaliEventHandler<object, ObjectDestroyedEventArgs> ObjectDestroyed
139 // Restricted to only one listener
140 if (_objectRegistryObjectDestroyedEventHandler == null)
142 _objectRegistryObjectDestroyedEventHandler += value;
144 _objectRegistryObjectDestroyedEventCallbackDelegate = new ObjectDestroyedEventCallbackDelegate(OnObjectDestroyed);
145 this.ObjectDestroyedSignal().Connect(_objectRegistryObjectDestroyedEventCallbackDelegate);
154 if (_objectRegistryObjectDestroyedEventHandler != null)
156 this.ObjectDestroyedSignal().Disconnect(_objectRegistryObjectDestroyedEventCallbackDelegate);
159 _objectRegistryObjectDestroyedEventHandler -= value;
164 // Callback for ObjectRegistry ObjectDestroyedSignal
165 private void OnObjectDestroyed(IntPtr refObject)
167 ObjectDestroyedEventArgs e = new ObjectDestroyedEventArgs();
169 // Populate all members of "e" (ObjectDestroyedEventArgs) with real data
170 e.RefObject = RefObject.GetRefObjectFromPtr(refObject);
172 if (_objectRegistryObjectDestroyedEventHandler != null)
174 //here we send all data to user event handlers
175 _objectRegistryObjectDestroyedEventHandler(this, e);
180 public ObjectRegistry() : this(Interop.ObjectRegistry.new_ObjectRegistry__SWIG_0(), true)
182 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
185 public ObjectRegistry(ObjectRegistry handle) : this(Interop.ObjectRegistry.new_ObjectRegistry__SWIG_1(ObjectRegistry.getCPtr(handle)), true)
187 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
190 public ObjectRegistry Assign(ObjectRegistry rhs)
192 ObjectRegistry ret = new ObjectRegistry(Interop.ObjectRegistry.ObjectRegistry_Assign(swigCPtr, ObjectRegistry.getCPtr(rhs)), false);
193 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
197 public ObjectCreatedSignal ObjectCreatedSignal()
199 ObjectCreatedSignal ret = new ObjectCreatedSignal(Interop.ObjectRegistry.ObjectRegistry_ObjectCreatedSignal(swigCPtr), false);
200 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
204 public ObjectDestroyedSignal ObjectDestroyedSignal()
206 ObjectDestroyedSignal ret = new ObjectDestroyedSignal(Interop.ObjectRegistry.ObjectRegistry_ObjectDestroyedSignal(swigCPtr), false);
207 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();