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)
62 NDalicPINVOKE.delete_ObjectRegistry(swigCPtr);
64 swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
71 public class ObjectCreatedEventArgs : EventArgs
73 private BaseHandle _baseHandle;
75 public BaseHandle BaseHandle
88 public class ObjectDestroyedEventArgs : EventArgs
90 private RefObject _refObject;
92 public RefObject RefObject
106 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
107 private delegate void ObjectCreatedEventCallbackDelegate(IntPtr baseHandle);
108 private DaliEventHandler<object, ObjectCreatedEventArgs> _objectRegistryObjectCreatedEventHandler;
109 private ObjectCreatedEventCallbackDelegate _objectRegistryObjectCreatedEventCallbackDelegate;
111 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
112 private delegate void ObjectDestroyedEventCallbackDelegate(IntPtr fefObject);
113 private DaliEventHandler<object, ObjectDestroyedEventArgs> _objectRegistryObjectDestroyedEventHandler;
114 private ObjectDestroyedEventCallbackDelegate _objectRegistryObjectDestroyedEventCallbackDelegate;
116 public event DaliEventHandler<object, ObjectCreatedEventArgs> ObjectCreated
122 // Restricted to only one listener
123 if (_objectRegistryObjectCreatedEventHandler == null)
125 _objectRegistryObjectCreatedEventHandler += value;
127 _objectRegistryObjectCreatedEventCallbackDelegate = new ObjectCreatedEventCallbackDelegate(OnObjectCreated);
128 this.ObjectCreatedSignal().Connect(_objectRegistryObjectCreatedEventCallbackDelegate);
137 if (_objectRegistryObjectCreatedEventHandler != null)
139 this.ObjectCreatedSignal().Disconnect(_objectRegistryObjectCreatedEventCallbackDelegate);
142 _objectRegistryObjectCreatedEventHandler -= value;
147 // Callback for ObjectRegistry ObjectCreatedSignal
148 private void OnObjectCreated(IntPtr baseHandle)
150 ObjectCreatedEventArgs e = new ObjectCreatedEventArgs();
152 // Populate all members of "e" (ObjectCreatedEventArgs) with real data
153 //e.BaseHandle = BaseHandle.GetBaseHandleFromPtr(baseHandle); //GetBaseHandleFromPtr() is not present in BaseHandle.cs. Not sure what is the reason?
155 if (_objectRegistryObjectCreatedEventHandler != null)
157 //here we send all data to user event handlers
158 _objectRegistryObjectCreatedEventHandler(this, e);
162 public event DaliEventHandler<object, ObjectDestroyedEventArgs> ObjectDestroyed
168 // Restricted to only one listener
169 if (_objectRegistryObjectDestroyedEventHandler == null)
171 _objectRegistryObjectDestroyedEventHandler += value;
173 _objectRegistryObjectDestroyedEventCallbackDelegate = new ObjectDestroyedEventCallbackDelegate(OnObjectDestroyed);
174 this.ObjectDestroyedSignal().Connect(_objectRegistryObjectDestroyedEventCallbackDelegate);
183 if (_objectRegistryObjectDestroyedEventHandler != null)
185 this.ObjectDestroyedSignal().Disconnect(_objectRegistryObjectDestroyedEventCallbackDelegate);
188 _objectRegistryObjectDestroyedEventHandler -= value;
193 // Callback for ObjectRegistry ObjectDestroyedSignal
194 private void OnObjectDestroyed(IntPtr refObject)
196 ObjectDestroyedEventArgs e = new ObjectDestroyedEventArgs();
198 // Populate all members of "e" (ObjectDestroyedEventArgs) with real data
199 e.RefObject = RefObject.GetRefObjectFromPtr(refObject);
201 if (_objectRegistryObjectDestroyedEventHandler != null)
203 //here we send all data to user event handlers
204 _objectRegistryObjectDestroyedEventHandler(this, e);
209 public ObjectRegistry() : this(NDalicPINVOKE.new_ObjectRegistry__SWIG_0(), true)
211 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
214 public ObjectRegistry(ObjectRegistry handle) : this(NDalicPINVOKE.new_ObjectRegistry__SWIG_1(ObjectRegistry.getCPtr(handle)), true)
216 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
219 public ObjectRegistry Assign(ObjectRegistry rhs)
221 ObjectRegistry ret = new ObjectRegistry(NDalicPINVOKE.ObjectRegistry_Assign(swigCPtr, ObjectRegistry.getCPtr(rhs)), false);
222 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
226 public ObjectCreatedSignal ObjectCreatedSignal()
228 ObjectCreatedSignal ret = new ObjectCreatedSignal(NDalicPINVOKE.ObjectRegistry_ObjectCreatedSignal(swigCPtr), false);
229 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
233 public ObjectDestroyedSignal ObjectDestroyedSignal()
235 ObjectDestroyedSignal ret = new ObjectDestroyedSignal(NDalicPINVOKE.ObjectRegistry_ObjectDestroyedSignal(swigCPtr), false);
236 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();