2 * Copyright (c) 2016 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 %define OBJECT_REGISTRY_EVENTHANDLER_TYPEMAP_EVENTARG(NameSpace, ClassName)
19 %typemap(csimports) NameSpace::ClassName %{
21 using System.Runtime.InteropServices;
28 %define OBJECT_REGISTRY_EVENTHANDLER_TYPEMAP_HELPER(NameSpace, ClassName)
29 %typemap(cscode) NameSpace::ClassName %{
32 public class ObjectCreatedEventArgs : EventArgs
34 private BaseHandle _baseHandle;
36 public BaseHandle BaseHandle
49 public class ObjectDestroyedEventArgs : EventArgs
51 private RefObject _refObject;
53 public RefObject RefObject
67 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
68 private delegate void ObjectCreatedEventCallbackDelegate(IntPtr baseHandle);
69 private DaliEventHandler<object,ObjectCreatedEventArgs> _objectRegistryObjectCreatedEventHandler;
70 private ObjectCreatedEventCallbackDelegate _objectRegistryObjectCreatedEventCallbackDelegate;
72 [UnmanagedFunctionPointer(CallingConvention.StdCall)]
73 private delegate void ObjectDestroyedEventCallbackDelegate(IntPtr fefObject);
74 private DaliEventHandler<object,ObjectDestroyedEventArgs> _objectRegistryObjectDestroyedEventHandler;
75 private ObjectDestroyedEventCallbackDelegate _objectRegistryObjectDestroyedEventCallbackDelegate;
77 public event DaliEventHandler<object,ObjectCreatedEventArgs> ObjectCreated
83 // Restricted to only one listener
84 if (_objectRegistryObjectCreatedEventHandler == null)
86 _objectRegistryObjectCreatedEventHandler += value;
88 _objectRegistryObjectCreatedEventCallbackDelegate = new ObjectCreatedEventCallbackDelegate(OnObjectCreated);
89 this.ObjectCreatedSignal().Connect(_objectRegistryObjectCreatedEventCallbackDelegate);
98 if (_objectRegistryObjectCreatedEventHandler != null)
100 this.ObjectCreatedSignal().Disconnect(_objectRegistryObjectCreatedEventCallbackDelegate);
103 _objectRegistryObjectCreatedEventHandler -= value;
108 // Callback for ObjectRegistry ObjectCreatedSignal
109 private void OnObjectCreated(IntPtr baseHandle)
111 ObjectCreatedEventArgs e = new ObjectCreatedEventArgs();
113 // Populate all members of "e" (ObjectCreatedEventArgs) with real data
114 //e.BaseHandle = BaseHandle.GetBaseHandleFromPtr(baseHandle); //GetBaseHandleFromPtr() is not present in BaseHandle.cs. Not sure what is the reason?
116 if (_objectRegistryObjectCreatedEventHandler != null)
118 //here we send all data to user event handlers
119 _objectRegistryObjectCreatedEventHandler(this, e);
123 public event DaliEventHandler<object,ObjectDestroyedEventArgs> ObjectDestroyed
129 // Restricted to only one listener
130 if (_objectRegistryObjectDestroyedEventHandler == null)
132 _objectRegistryObjectDestroyedEventHandler += value;
134 _objectRegistryObjectDestroyedEventCallbackDelegate = new ObjectDestroyedEventCallbackDelegate(OnObjectDestroyed);
135 this.ObjectDestroyedSignal().Connect(_objectRegistryObjectDestroyedEventCallbackDelegate);
144 if (_objectRegistryObjectDestroyedEventHandler != null)
146 this.ObjectDestroyedSignal().Disconnect(_objectRegistryObjectDestroyedEventCallbackDelegate);
149 _objectRegistryObjectDestroyedEventHandler -= value;
154 // Callback for ObjectRegistry ObjectDestroyedSignal
155 private void OnObjectDestroyed(IntPtr refObject)
157 ObjectDestroyedEventArgs e = new ObjectDestroyedEventArgs();
159 // Populate all members of "e" (ObjectDestroyedEventArgs) with real data
160 e.RefObject = RefObject.GetRefObjectFromPtr(refObject);
162 if (_objectRegistryObjectDestroyedEventHandler != null)
164 //here we send all data to user event handlers
165 _objectRegistryObjectDestroyedEventHandler(this, e);
172 %typemap(cscode) Dali::BaseHandle %{
173 public static BaseHandle GetBaseHandleFromPtr(global::System.IntPtr cPtr) {
174 BaseHandle ret = new BaseHandle(cPtr, false);
175 if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
181 %define DALI_OBJECT_REGISTRY_EVENTHANDLER_PARAM( NameSpace, ClassName)
182 OBJECT_REGISTRY_EVENTHANDLER_TYPEMAP_EVENTARG( NameSpace, ClassName);
183 OBJECT_REGISTRY_EVENTHANDLER_TYPEMAP_HELPER( NameSpace, ClassName);
188 DALI_OBJECT_REGISTRY_EVENTHANDLER_PARAM( Dali, ObjectRegistry);