]> vaikene.ee Git - evaf/blob - src/libs/Common/globals.cpp
Mac OS changes and switched to c++11.
[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-2019 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 "prop.h"
24 #include "logger.h"
25 #include "version.h"
26 #include "ilogger.h"
27 #include "iregistry.h"
28
29 #include <QCoreApplication>
30
31
32 //-------------------------------------------------------------------
33
34 bool eVaf::Common::init()
35 {
36 if (QCoreApplication::instance() == nullptr) {
37 EVAF_FATAL_ERROR("QApplication is not instantiated");
38 return false;
39 }
40
41 EVAF_INFO("Initializing %s-Globals", VER_MODULE_NAME_STR);
42
43 // Initialize all the common interface implementations in the proper sequence
44
45 eVaf::Common::Internal::App * app =
46 qobject_cast<eVaf::Common::Internal::App *>(eVaf::Common::iApp::instance());
47 if (app) {
48 if (!app->init())
49 return false;
50 }
51 eVaf::Common::Internal::Config * config =
52 qobject_cast<eVaf::Common::Internal::Config *>(eVaf::Common::iConfig::instance());
53 if (config) {
54 if (!config->init())
55 return false;
56 }
57 eVaf::Common::Internal::Prop * prop =
58 qobject_cast<eVaf::Common::Internal::Prop *>(eVaf::Common::iProp::instance());
59 if (prop) {
60 if (!prop->init())
61 return false;
62 }
63 eVaf::Common::Internal::Logger * logger =
64 qobject_cast<eVaf::Common::Internal::Logger *>(eVaf::Common::iLogger::instance());
65 if (logger) {
66 if (!logger->init())
67 return false;
68 }
69
70 EVAF_INFO("%s-Globals initialized", VER_MODULE_NAME_STR);
71
72 return true;
73 }
74
75 void eVaf::Common::done()
76 {
77 EVAF_INFO("Finalizing %s-Globals", VER_MODULE_NAME_STR);
78
79 //eVaf::Common::Internal::Logger::destroyInstance();
80 eVaf::Common::Internal::Prop::destroyInstance();
81 eVaf::Common::Internal::Config::destroyInstance();
82 eVaf::Common::Internal::App::destroyInstance();
83
84 EVAF_INFO("%s-Globals finalized", VER_MODULE_NAME_STR);
85 }