Refactor Lifecycles
[platform/core/csapi/tizenfx.git] / Tizen.Applications / Tizen.Applications / Controller.cs
1 /// Copyright 2016 by Samsung Electronics, Inc.,
2 ///
3 /// This software is the confidential and proprietary information
4 /// of Samsung Electronics, Inc. ("Confidential Information"). You
5 /// shall not disclose such Confidential Information and shall use
6 /// it only in accordance with the terms of the license agreement
7 /// you entered into with Samsung.
8
9
10 using System;
11
12 namespace Tizen.Applications
13 {
14     /// <summary>
15     /// 
16     /// </summary>
17     public abstract class Controller : Context
18     {
19         /// <summary>
20         /// 
21         /// </summary>
22         [Flags]
23         public enum ControlFlags
24         {
25             NewInstance = 1,
26             ClearTop = 2,
27             MoveToTop = 4,
28         }
29
30         /// <summary>
31         /// 
32         /// </summary>
33         protected AppControl AppControl { get; private set; }
34
35         internal virtual void SendCreate()
36         {
37             AppControl = null;
38             OnCreate();
39         }
40
41         internal virtual void SendStart(AppControl control)
42         {
43             AppControl = control;
44             OnStart();
45         }
46
47         internal virtual void SendDestroy()
48         {
49             OnDestroy();
50         }
51
52         /// <summary>
53         /// 
54         /// </summary>
55         protected virtual void OnCreate()
56         {
57         }
58
59         /// <summary>
60         /// 
61         /// </summary>
62         protected virtual void OnStart()
63         {
64         }
65
66         /// <summary>
67         /// 
68         /// </summary>
69         protected virtual void OnDestroy()
70         {
71         }
72
73         /// <summary>
74         /// 
75         /// </summary>
76         /// <param name="control"></param>
77         /// <param name="flags"></param>
78         protected void StartController(AppControl control, ControlFlags flags = ControlFlags.NewInstance)
79         {
80             Application.StartController(this, null, control, flags);
81         }
82
83         /// <summary>
84         /// 
85         /// </summary>
86         /// <param name="controllerType"></param>
87         /// <param name="control"></param>
88         /// <param name="flags"></param>
89         protected void StartController(Type controllerType, AppControl control, ControlFlags flags = ControlFlags.NewInstance)
90         {
91             Application.StartController(this, controllerType, control, flags);
92         }
93
94         protected void StopController(Type controllerType)
95         {
96             Application.StopController(controllerType);
97         }
98
99         /// <summary>
100         /// 
101         /// </summary>
102         protected virtual void Finish()
103         {
104             Application.StopController(GetType());
105         }
106
107         /// <summary>
108         /// 
109         /// </summary>
110         /// <param name="control"></param>
111         /// <param name="destination"></param>
112         protected void SendAppControl(AppControl control, string destination)
113         {
114             throw new NotImplementedException();
115         }
116     }
117 }