Merge "change Dispose pattern" into tizen
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / internal / ObjectRegistry.cs
1 //------------------------------------------------------------------------------
2 // <auto-generated />
3 //
4 // This file was automatically generated by SWIG (http://www.swig.org).
5 // Version 3.0.9
6 //
7 // Do not make changes to this file unless you know what you are doing--modify
8 // the SWIG interface file instead.
9 //------------------------------------------------------------------------------
10
11 namespace Tizen.NUI {
12
13 using System;
14 using System.Runtime.InteropServices;
15
16
17     internal class ObjectRegistry : BaseHandle {
18   private global::System.Runtime.InteropServices.HandleRef swigCPtr;
19
20   internal ObjectRegistry(global::System.IntPtr cPtr, bool cMemoryOwn) : base(NDalicPINVOKE.ObjectRegistry_SWIGUpcast(cPtr), cMemoryOwn) {
21     swigCPtr = new global::System.Runtime.InteropServices.HandleRef(this, cPtr);
22   }
23
24   internal static global::System.Runtime.InteropServices.HandleRef getCPtr(ObjectRegistry obj) {
25     return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.swigCPtr;
26   }
27
28   public override void Dispose() {
29     if (!Stage.IsInstalled()) {
30       DisposeQueue.Instance.Add(this);
31       return;
32     }
33
34     lock(this) {
35       if (swigCPtr.Handle != global::System.IntPtr.Zero) {
36         if (swigCMemOwn) {
37           swigCMemOwn = false;
38           NDalicPINVOKE.delete_ObjectRegistry(swigCPtr);
39         }
40         swigCPtr = new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero);
41       }
42       global::System.GC.SuppressFinalize(this);
43       base.Dispose();
44     }
45   }
46
47
48
49
50 public class ObjectCreatedEventArgs : EventArgs
51 {
52    private BaseHandle _baseHandle;
53
54    public BaseHandle BaseHandle
55    {
56       get
57       {
58          return _baseHandle;
59       }
60       set
61       {
62          _baseHandle = value;
63       }
64    }
65 }
66
67 public class ObjectDestroyedEventArgs : EventArgs
68 {
69    private RefObject _refObject;
70
71    public RefObject RefObject
72    {
73       get
74       {
75          return _refObject;
76       }
77       set
78       {
79          _refObject = value;
80       }
81    }
82 }
83
84
85   [UnmanagedFunctionPointer(CallingConvention.StdCall)]
86   private delegate void ObjectCreatedEventCallbackDelegate(IntPtr baseHandle);
87   private DaliEventHandler<object,ObjectCreatedEventArgs> _objectRegistryObjectCreatedEventHandler;
88   private ObjectCreatedEventCallbackDelegate _objectRegistryObjectCreatedEventCallbackDelegate;
89
90   [UnmanagedFunctionPointer(CallingConvention.StdCall)]
91   private delegate void ObjectDestroyedEventCallbackDelegate(IntPtr fefObject);
92   private DaliEventHandler<object,ObjectDestroyedEventArgs> _objectRegistryObjectDestroyedEventHandler;
93   private ObjectDestroyedEventCallbackDelegate _objectRegistryObjectDestroyedEventCallbackDelegate;
94
95   public event DaliEventHandler<object,ObjectCreatedEventArgs> ObjectCreated
96   {
97      add
98      {
99         lock(this)
100         {
101            // Restricted to only one listener
102            if (_objectRegistryObjectCreatedEventHandler == null)
103            {
104               _objectRegistryObjectCreatedEventHandler += value;
105
106               _objectRegistryObjectCreatedEventCallbackDelegate = new ObjectCreatedEventCallbackDelegate(OnObjectCreated);
107               this.ObjectCreatedSignal().Connect(_objectRegistryObjectCreatedEventCallbackDelegate);
108            }
109         }
110      }
111
112      remove
113      {
114         lock(this)
115         {
116            if (_objectRegistryObjectCreatedEventHandler != null)
117            {
118               this.ObjectCreatedSignal().Disconnect(_objectRegistryObjectCreatedEventCallbackDelegate);
119            }
120
121            _objectRegistryObjectCreatedEventHandler -= value;
122         }
123      }
124   }
125
126   // Callback for ObjectRegistry ObjectCreatedSignal
127   private void OnObjectCreated(IntPtr baseHandle)
128   {
129      ObjectCreatedEventArgs e = new ObjectCreatedEventArgs();
130
131      // Populate all members of "e" (ObjectCreatedEventArgs) with real data
132      //e.BaseHandle = BaseHandle.GetBaseHandleFromPtr(baseHandle); //GetBaseHandleFromPtr() is not present in BaseHandle.cs. Not sure what is the reason?
133
134      if (_objectRegistryObjectCreatedEventHandler != null)
135      {
136         //here we send all data to user event handlers
137         _objectRegistryObjectCreatedEventHandler(this, e);
138      }
139   }
140
141   public event DaliEventHandler<object,ObjectDestroyedEventArgs> ObjectDestroyed
142   {
143      add
144      {
145         lock(this)
146         {
147            // Restricted to only one listener
148            if (_objectRegistryObjectDestroyedEventHandler == null)
149            {
150               _objectRegistryObjectDestroyedEventHandler += value;
151
152               _objectRegistryObjectDestroyedEventCallbackDelegate = new ObjectDestroyedEventCallbackDelegate(OnObjectDestroyed);
153               this.ObjectDestroyedSignal().Connect(_objectRegistryObjectDestroyedEventCallbackDelegate);
154            }
155         }
156      }
157
158      remove
159      {
160         lock(this)
161         {
162            if (_objectRegistryObjectDestroyedEventHandler != null)
163            {
164               this.ObjectDestroyedSignal().Disconnect(_objectRegistryObjectDestroyedEventCallbackDelegate);
165            }
166
167            _objectRegistryObjectDestroyedEventHandler -= value;
168         }
169      }
170   }
171
172   // Callback for ObjectRegistry ObjectDestroyedSignal
173   private void OnObjectDestroyed(IntPtr refObject)
174   {
175      ObjectDestroyedEventArgs e = new ObjectDestroyedEventArgs();
176
177      // Populate all members of "e" (ObjectDestroyedEventArgs) with real data
178      e.RefObject = RefObject.GetRefObjectFromPtr(refObject);
179
180      if (_objectRegistryObjectDestroyedEventHandler != null)
181      {
182         //here we send all data to user event handlers
183         _objectRegistryObjectDestroyedEventHandler(this, e);
184      }
185   }
186
187
188   public ObjectRegistry() : this(NDalicPINVOKE.new_ObjectRegistry__SWIG_0(), true) {
189     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
190   }
191
192   public ObjectRegistry(ObjectRegistry handle) : this(NDalicPINVOKE.new_ObjectRegistry__SWIG_1(ObjectRegistry.getCPtr(handle)), true) {
193     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
194   }
195
196   public ObjectRegistry Assign(ObjectRegistry rhs) {
197     ObjectRegistry ret = new ObjectRegistry(NDalicPINVOKE.ObjectRegistry_Assign(swigCPtr, ObjectRegistry.getCPtr(rhs)), false);
198     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
199     return ret;
200   }
201
202   public ObjectCreatedSignal ObjectCreatedSignal() {
203     ObjectCreatedSignal ret = new ObjectCreatedSignal(NDalicPINVOKE.ObjectRegistry_ObjectCreatedSignal(swigCPtr), false);
204     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
205     return ret;
206   }
207
208   public ObjectDestroyedSignal ObjectDestroyedSignal() {
209     ObjectDestroyedSignal ret = new ObjectDestroyedSignal(NDalicPINVOKE.ObjectRegistry_ObjectDestroyedSignal(swigCPtr), false);
210     if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
211     return ret;
212   }
213
214 }
215
216 }