tizen 2.4 release
[framework/web/wrt-commons.git] / modules / 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 <atomic>
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   protected:
44     int m_argc;
45     char **m_argv;
46     std::string m_applicationName;
47
48     bool m_mainWindowVisible;
49
50     static bool app_create(void *data);
51     static void app_terminate(void *data);
52     static void app_pause(void *data);
53     static void app_resume(void *data);
54     static void app_control(app_control_h app_control, void *data);
55
56     virtual void OnCreate();
57     virtual void OnStart();
58     virtual void OnStop();
59     virtual void OnResume();
60     virtual void OnPause();
61     virtual void OnRelaunch();
62     virtual void OnReset(bundle *b);
63     virtual void OnTerminate();
64     virtual void OnLowMemory();
65     virtual void OnLowBattery();
66     virtual void OnLanguageChanged();
67
68   public:
69     Application(int argc,
70                 char **argv,
71                 const std::string &applicationName,
72                 bool showMainWindow = true);
73     virtual ~Application();
74
75     /**
76      * @brief Execute application and start message processing
77      */
78     virtual int Exec();
79
80     /*
81      * @brief Sends quit message to application message loop
82      */
83     virtual void Quit();
84 };
85
86 class ApplicationExt : public Application
87 {
88   public:
89     ApplicationExt(int argc,
90                    char **argv,
91                    const std::string &applicationName,
92                    bool showMainWindow = true);
93     virtual ~ApplicationExt();
94
95     /**
96      * @brief Execute application and start message processing
97      */
98     virtual int Exec();
99
100     /*
101      * @brief Sends quit message to application message loop
102      */
103     virtual void Quit();
104
105   private:
106     static std::atomic<int> m_useCount;
107 };
108 } // namespace DPL
109
110 #endif // DPL_APPLICATION_H