Changes after adaptor integration-api folder move
[platform/core/uifw/dali-csharp-binder.git] / dali-csharp-binder / src / layout-controller.cpp
1 /*
2  * Copyright (c) 2019 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
18 #include "layout-controller.h"
19 #include <dali/integration-api/adaptor-framework/adaptor.h>
20
21 #ifdef __cplusplus
22 extern "C" {
23 #endif
24
25 namespace
26 {
27 static int gLayoutControllerId = 1;
28 } // unnamed namespace
29
30 LayoutController::LayoutController() : handler(NULL), mId( gLayoutControllerId++ )
31 {
32   Dali::Adaptor::Get().RegisterProcessor(*this);
33 }
34
35
36 LayoutController::~LayoutController()
37 {
38   Dali::Adaptor::Get().UnregisterProcessor(*this);
39 }
40
41
42 int LayoutController::GetId() const
43 {
44   return mId;
45 }
46
47 void LayoutController::Process()
48 {
49   if( handler )
50   {
51     handler( mId );
52   }
53 }
54
55 void LayoutController::SetCallback(  LayoutControllerProcessCallback callback )
56 {
57   handler = callback;
58 }
59
60 // LayoutController Bindings
61
62 SWIGEXPORT void * SWIGSTDCALL CSharp_Dali_new_LayoutController() {
63
64   LayoutController *result = 0 ;
65
66   {
67     try {
68       result = (LayoutController *)new LayoutController();
69     } catch (std::out_of_range& e) {
70       {
71         SWIG_CSharpException(SWIG_IndexError, const_cast<char*>(e.what())); return 0;
72       };
73     } catch (std::exception& e) {
74       {
75         SWIG_CSharpException(SWIG_RuntimeError, const_cast<char*>(e.what())); return 0;
76       };
77     } catch (Dali::DaliException e) {
78       {
79         SWIG_CSharpException(SWIG_UnknownError, e.condition); return 0;
80       };
81     } catch (...) {
82       {
83         SWIG_CSharpException(SWIG_UnknownError, "unknown error"); return 0;
84       };
85     }
86   }
87
88   return (void *)result;
89 }
90
91 SWIGEXPORT void SWIGSTDCALL CSharp_Dali_delete_LayoutController(void * jarg1) {
92
93   LayoutController * arg1 = (LayoutController *)jarg1;
94   {
95     try {
96       delete arg1;
97     } catch (std::out_of_range& e) {
98       {
99         SWIG_CSharpException(SWIG_IndexError, const_cast<char*>(e.what())); return ;
100       };
101     } catch (std::exception& e) {
102       {
103         SWIG_CSharpException(SWIG_RuntimeError, const_cast<char*>(e.what())); return ;
104       };
105     } catch (...) {
106       {
107         SWIG_CSharpException(SWIG_UnknownError, "unknown error"); return ;
108       };
109     }
110   }
111 }
112
113 SWIGEXPORT void SWIGSTDCALL CSharp_Dali_LayoutController_SetCallback( void* jarg1, LayoutController::LayoutControllerProcessCallback callback )
114 {
115   LayoutController* layoutController = (LayoutController *) jarg1;
116
117   if( layoutController )
118   {
119     layoutController->SetCallback( callback );
120   }
121 }
122
123 SWIGEXPORT int SWIGSTDCALL CSharp_Dali_LayoutController_GetId( void* jarg1 )
124 {
125   LayoutController * layoutController = (LayoutController *)jarg1;
126   int ret = 0;
127   if( layoutController )
128   {
129     ret = layoutController->GetId();
130   }
131   return ret;
132 }
133
134 #ifdef __cplusplus
135 }
136 #endif