[NUI] Re-structuring NUI by classifying modules
[platform/core/csapi/tizenfx.git] / src / Tizen.NUI / src / public / Common / TypeRegistry.cs
1 /*
2  * Copyright(c) 2017 Samsung Electronics Co., Ltd.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  *
16  */
17 using System.ComponentModel;
18
19 namespace Tizen.NUI
20 {
21     /// <summary>
22     /// The TypeRegistry allows registration of type instance creation functions.
23     /// These can then be created later by name and down cast to the appropriate type.
24     /// </summary>
25     /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
26     [EditorBrowsable(EditorBrowsableState.Never)]
27     public class TypeRegistry : BaseHandle
28     {
29
30         internal TypeRegistry(global::System.IntPtr cPtr, bool cMemoryOwn) : base(Interop.TypeRegistry.Upcast(cPtr), cMemoryOwn)
31         {
32         }
33
34         internal static global::System.Runtime.InteropServices.HandleRef getCPtr(TypeRegistry obj)
35         {
36             return (obj == null) ? new global::System.Runtime.InteropServices.HandleRef(null, global::System.IntPtr.Zero) : obj.SwigCPtr;
37         }
38
39         /// This will not be public opened.
40         [EditorBrowsable(EditorBrowsableState.Never)]
41         protected override void ReleaseSwigCPtr(System.Runtime.InteropServices.HandleRef swigCPtr)
42         {
43             Interop.TypeRegistry.DeleteTypeRegistry(swigCPtr);
44         }
45
46         /// <summary>
47         /// Gets Type Registry handle.
48         /// </summary>
49         /// <returns>TypeRegistry handle.</returns>
50         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
51         [EditorBrowsable(EditorBrowsableState.Never)]
52         public static TypeRegistry Get()
53         {
54             TypeRegistry ret = new TypeRegistry(Interop.TypeRegistry.Get(), true);
55             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
56             return ret;
57         }
58
59         /// <summary>
60         /// Allows the creation of an empty typeRegistry handle.
61         /// </summary>
62         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
63         [EditorBrowsable(EditorBrowsableState.Never)]
64         public TypeRegistry() : this(Interop.TypeRegistry.NewTypeRegistry(), true)
65         {
66             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
67         }
68
69         internal TypeRegistry(TypeRegistry handle) : this(Interop.TypeRegistry.NewTypeRegistry(TypeRegistry.getCPtr(handle)), true)
70         {
71             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
72         }
73
74         internal TypeRegistry Assign(TypeRegistry rhs)
75         {
76             TypeRegistry ret = new TypeRegistry(Interop.TypeRegistry.Assign(SwigCPtr, TypeRegistry.getCPtr(rhs)), false);
77             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
78             return ret;
79         }
80
81         /// <summary>
82         /// Gets TypeInfo for a registered type.
83         /// </summary>
84         /// <param name="uniqueTypeName">A unique type name.</param>
85         /// <returns>TypeInfo if the type exists, otherwise an empty handle.</returns>
86         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
87         [EditorBrowsable(EditorBrowsableState.Never)]
88         public Tizen.NUI.TypeInfo GetTypeInfo(string uniqueTypeName)
89         {
90             Tizen.NUI.TypeInfo ret = new Tizen.NUI.TypeInfo(Interop.TypeRegistry.GetTypeInfo(SwigCPtr, uniqueTypeName), true);
91             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
92             return ret;
93         }
94
95         internal Tizen.NUI.TypeInfo GetTypeInfo(SWIGTYPE_p_std__type_info registerType)
96         {
97             Tizen.NUI.TypeInfo ret = new Tizen.NUI.TypeInfo(Interop.TypeRegistry.GetTypeInfo(SwigCPtr, SWIGTYPE_p_std__type_info.getCPtr(registerType)), true);
98             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
99             return ret;
100         }
101
102         /// <summary>
103         /// Gets type name count.
104         /// </summary>
105         /// <returns>The counte.</returns>
106         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
107         [EditorBrowsable(EditorBrowsableState.Never)]
108         public uint GetTypeNameCount()
109         {
110             uint ret = Interop.TypeRegistry.GetTypeNameCount(SwigCPtr);
111             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
112             return ret;
113         }
114
115         /// <summary>
116         /// Gets type names by index.
117         /// </summary>
118         /// <param name="index">The index to get the type name.</param>
119         /// <returns>The type name or an empty string when index is not valid.</returns>
120         /// This will be public opened in next tizen after ACR done. Before ACR, need to be hidden as inhouse API.
121         [EditorBrowsable(EditorBrowsableState.Never)]
122         public string GetTypeName(uint index)
123         {
124             string ret = Interop.TypeRegistry.GetTypeName(SwigCPtr, index);
125             if (NDalicPINVOKE.SWIGPendingException.Pending) throw NDalicPINVOKE.SWIGPendingException.Retrieve();
126             return ret;
127         }
128     }
129 }