]> vaikene.ee Git - evaf/blob - src/libs/Common/globals.cpp
Added the iConfig interface and default implementation in the common library.
[evaf] / src / libs / Common / globals.cpp
1 /**
2 * @file Common/globals.cpp
3 * @brief Global constants and macros for eVaf
4 * @author Enar Vaikene
5 *
6 * Copyright (c) 2011 Enar Vaikene
7 *
8 * This file is part of the eVaf C++ cross-platform application development framework.
9 *
10 * This file can be used under the terms of the GNU General Public License
11 * version 3.0 as published by the Free Software Foundation and appearing in
12 * the file LICENSE included in the packaging of this file. Please review the
13 * the following information to ensure the GNU General Public License version
14 * 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
15 *
16 * Alternatively, this file may be used in accordance with the Commercial License
17 * Agreement provided with the Software.
18 */
19
20 #include "globals.h"
21 #include "app.h"
22 #include "config.h"
23 #include "logger.h"
24 #include "version.h"
25 #include "ilogger.h"
26
27 #include <QCoreApplication>
28
29
30 //-------------------------------------------------------------------
31
32 bool eVaf::Common::init()
33 {
34 if (QCoreApplication::instance() == 0) {
35 EVAF_FATAL_ERROR("QApplication is not instantiated");
36 return false;
37 }
38
39 EVAF_INFO("Initializing %s-Globals", VER_MODULE_NAME_STR);
40
41 // Initialize all the common interface implementations in the proper sequence
42
43 eVaf::Common::Internal::App * app =
44 qobject_cast<eVaf::Common::Internal::App *>(eVaf::Common::iApp::instance());
45 if (app) {
46 if (!app->init())
47 return false;
48 }
49 eVaf::Common::Internal::Logger * logger =
50 qobject_cast<eVaf::Common::Internal::Logger *>(eVaf::Common::iLogger::instance());
51 if (logger) {
52 if (!logger->init())
53 return false;
54 }
55 eVaf::Common::Internal::Config * config =
56 qobject_cast<eVaf::Common::Internal::Config *>(eVaf::Common::iConfig::instance());
57 if (config) {
58 if (!config->init())
59 return false;
60 }
61
62 EVAF_INFO("%s-Globals initialized", VER_MODULE_NAME_STR);
63
64 return true;
65 }