Initialize Tizen 2.3
[framework/web/wrt-commons.git] / modules_mobile / core / include / dpl / application.h
1 /*
2  * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
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  * @file        application.h
18  * @author      Przemyslaw Dobrowolski (p.dobrowolsk@samsung.com)
19  * @version     1.0
20  * @brief       This file is the implementation file of MVC application support
21  */
22 #ifndef DPL_APPLICATION_H
23 #define DPL_APPLICATION_H
24
25 #include <dpl/exception.h>
26 #include <dpl/framework_efl.h>
27 #include <dpl/framework_appcore.h>
28 #include <dpl/atomic.h>
29 #include <string>
30
31 namespace DPL {
32 class Application
33 {
34   public:
35     class Exception
36     {
37       public:
38         DECLARE_EXCEPTION_TYPE(DPL::Exception, Base)
39         DECLARE_EXCEPTION_TYPE(Base, TooManyInstances)
40         DECLARE_EXCEPTION_TYPE(Base, FrameworkError)
41     };
42
43   private:
44     static int app_create(void *data);
45     static int app_terminate(void *data);
46     static int app_pause(void *data);
47     static int app_resume(void *data);
48     static int app_reset(bundle *b, void *data);
49
50   protected:
51     int m_argc;
52     char **m_argv;
53     std::string m_applicationName;
54
55     bool m_mainWindowVisible;
56
57     virtual void OnCreate();
58     virtual void OnStart();
59     virtual void OnStop();
60     virtual void OnResume();
61     virtual void OnPause();
62     virtual void OnRelaunch();
63     virtual void OnReset(bundle *b);
64     virtual void OnTerminate();
65     virtual void OnLowMemory();
66     virtual void OnLowBattery();
67     virtual void OnLanguageChanged();
68
69   public:
70     Application(int argc,
71                 char **argv,
72                 const std::string &applicationName,
73                 bool showMainWindow = true);
74     virtual ~Application();
75
76     /**
77      * @brief Execute application and start message processing
78      */
79     virtual int Exec();
80
81     /*
82      * @brief Sends quit message to application message loop
83      */
84     virtual void Quit();
85 };
86
87 class ApplicationExt : public Application
88 {
89   public:
90     ApplicationExt(int argc,
91                    char **argv,
92                    const std::string &applicationName,
93                    bool showMainWindow = true);
94     virtual ~ApplicationExt();
95
96     /**
97      * @brief Execute application and start message processing
98      */
99     virtual int Exec();
100
101     /*
102      * @brief Sends quit message to application message loop
103      */
104     virtual void Quit();
105
106   private:
107     static DPL::Atomic m_useCount;
108 };
109 } // namespace DPL
110
111 #endif // DPL_APPLICATION_H