Tizen 2.1 base
[sdk/ide/native-sample.git] / samples / native / cpp / Template / Tizen C++ / Empty Application / empty / project / src / AppEntry.cpp
1 /**
2  * This file contains the Tizen application entry point.
3  */
4 #include "$(projectName).h"
5
6 using namespace Osp::Base;
7 using namespace Osp::Base::Collection;
8
9 #ifdef __cplusplus
10 extern "C"
11 {
12 #endif // __cplusplus
13
14 _EXPORT_ int OspMain(int argc, char *pArgv[]);
15 #ifdef _PROFILE
16 extern void start_profile (void);
17 extern void end_profile (void);
18 #else
19 #define start_profile()
20 #define end_profile()
21 #endif
22
23
24 /**
25  * The entry function of Tizen application called by the operating system.
26  */
27 int
28 OspMain(int argc, char *pArgv[])
29 {
30         result r = E_SUCCESS;
31
32         AppLog("Application started.");
33         ArrayList* pArgs = new ArrayList();
34         pArgs->Construct();
35         for (int i = 0; i < argc; i++)
36         {
37                 pArgs->Add(*(new String(pArgv[i])));
38         }
39
40         start_profile();
41         r = Osp::App::UiApp::Execute($(projectName)App::CreateInstance, pArgs);
42         if (IsFailed(r))
43         {
44                 AppLogException("Application execution failed-[%s].", GetErrorMessage(r));
45                 r &= 0x0000FFFF;
46         }
47         end_profile();
48
49         pArgs->RemoveAll(true);
50         delete pArgs;
51         AppLog("Application finished.");
52
53         return static_cast<int>(r);
54 }
55 #ifdef __cplusplus
56 }
57 #endif // __cplusplus