1 /**
2  * UGENE - Integrated Bioinformatics Tools.
3  * Copyright (C) 2008-2021 UniPro <ugene@unipro.ru>
4  * http://ugene.net
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
19  * MA 02110-1301, USA.
20  */
21 
22 #ifndef _U2_COREAPI_H_
23 #define _U2_COREAPI_H_
24 
25 #include <assert.h>
26 
27 #include <QObject>
28 #include <QVariantMap>
29 #include <QtGlobal>
30 
31 #include <U2Core/U2IdTypes.h>
32 
33 #ifdef _DEBUG
34 #    define U2_PRODUCT_NAME "UGENED"
35 #else
36 #    define U2_PRODUCT_NAME "UGENE"
37 #endif
38 
39 /** used to store settings with a project name in a key, etc. Same in debug and release */
40 #define U2_PRODUCT_KEY "ugene"
41 #define U2_APP_TITLE "UGENE"
42 
43 #define U2_ORGANIZATION_NAME "Unipro"
44 #define U2_USER_INI "UGENE_USER_INI"
45 #define U2_SYSTEM_INI "UGENE_SYSTEM_INI"
46 #define U2_PRINT_TO_FILE "UGENE_PRINT_TO_FILE"
47 
48 #define U2_VFS_URL_PREFIX "VFS"
49 #define U2_VFS_FILE_SEPARATOR "!@#$"
50 
51 #ifdef BUILDING_U2CORE_DLL
52 #    define U2CORE_EXPORT Q_DECL_EXPORT
53 #else
54 #    define U2CORE_EXPORT Q_DECL_IMPORT
55 #endif
56 #ifdef BUILDING_U2FORMATS_DLL
57 #    define U2FORMATS_EXPORT Q_DECL_EXPORT
58 #else
59 #    define U2FORMATS_EXPORT Q_DECL_IMPORT
60 #endif
61 #ifdef BUILDING_U2ALGORITHM_DLL
62 #    define U2ALGORITHM_EXPORT Q_DECL_EXPORT
63 #else
64 #    define U2ALGORITHM_EXPORT Q_DECL_IMPORT
65 #endif
66 #ifdef BUILDING_U2TEST_DLL
67 #    define U2TEST_EXPORT Q_DECL_EXPORT
68 #else
69 #    define U2TEST_EXPORT Q_DECL_IMPORT
70 #endif
71 #ifdef BUILDING_U2LANG_DLL
72 #    define U2LANG_EXPORT Q_DECL_EXPORT
73 #else
74 #    define U2LANG_EXPORT Q_DECL_IMPORT
75 #endif
76 #ifdef BUILDING_U2GUI_DLL
77 #    define U2GUI_EXPORT Q_DECL_EXPORT
78 #else
79 #    define U2GUI_EXPORT Q_DECL_IMPORT
80 #endif
81 #ifdef BUILDING_U2VIEW_DLL
82 #    define U2VIEW_EXPORT Q_DECL_EXPORT
83 #else
84 #    define U2VIEW_EXPORT Q_DECL_IMPORT
85 #endif
86 #ifdef BUILDING_U2DESIGNER_DLL
87 #    define U2DESIGNER_EXPORT Q_DECL_EXPORT
88 #else
89 #    define U2DESIGNER_EXPORT Q_DECL_IMPORT
90 #endif
91 #ifdef BUILDING_U2PRIVATE_DLL
92 #    define U2PRIVATE_EXPORT Q_DECL_EXPORT
93 #else
94 #    define U2PRIVATE_EXPORT Q_DECL_IMPORT
95 #endif
96 
97 // UGENE_VERSION must be supplied as a preprocessor directive
98 #ifndef UGENE_VERSION
99 #    error UGENE_VERSION is not set!
100 #else
101 #    define U2_APP_VERSION UGENE_VERSION
102 #endif
103 
104 // global
105 #define GLOBAL_SETTINGS QString("global/")
106 
107 #define ENV_USE_CRASH_HANDLER "UGENE_USE_CRASH_HANDLER"
108 #define ENV_TEST_CRASH_HANDLER "UGENE_TEST_CRASH_HANDLER"
109 #define ENV_SEND_CRASH_REPORTS "UGENE_SEND_CRASH_REPORTS"
110 #define ENV_UGENE_DEV "UGENE_DEV"
111 #define ENV_GUI_TEST "UGENE_GUI_TEST"
112 #define ENV_USE_NATIVE_DIALOGS "UGENE_USE_NATIVE_DIALOGS"
113 
114 #ifdef __GNUC__
115 #    define ATTR_UNUSED __attribute__((unused))
116 #else
117 #    define ATTR_UNUSED
118 #endif
119 
120 #define PATH_PREFIX_DATA "data"
121 #define PATH_PREFIX_SCRIPTS "scripts"
122 
123 namespace U2 {
124 
125 enum TriState {
126     TriState_Unknown,
127     TriState_Yes,
128     TriState_No
129 };
130 
131 enum UnloadedObjectFilter {  // used as a separate type but not 'bool' to improve readability
132     UOF_LoadedAndUnloaded,
133     UOF_LoadedOnly
134 };
135 
136 enum NavigationDirection {
137     Forward,
138     Backward
139 };
140 
141 }  // namespace U2
142 
143 enum DNAAlphabetType {
144     DNAAlphabet_UNDEFINED = 0x0,
145     DNAAlphabet_RAW = 0x1,
146     DNAAlphabet_NUCL = 0x2,
147     DNAAlphabet_AMINO = 0x4
148 };
149 
Q_DECLARE_FLAGS(AlphabetFlags,DNAAlphabetType)150 Q_DECLARE_FLAGS(AlphabetFlags, DNAAlphabetType)
151 Q_DECLARE_OPERATORS_FOR_FLAGS(AlphabetFlags)
152 
153 #define UGENE_ARCH_X86_64 8664
154 #define UGENE_ARCH_X86_32 8632
155 #define UGENE_ARCH_UNKNOWN -1
156 
157 /** Returns UGENE binary (build) architecture. */
158 inline int getUgeneBinaryArch() {
159 #if defined Q_PROCESSOR_X86_64
160     return UGENE_ARCH_X86_64;
161 #elif defined Q_PROCESSOR_X86_32
162     return UGENE_ARCH_X86_32;
163 #else
164     return UGENE_ARCH_UNKNOWN;
165 #endif
166 }
167 
168 /** Returns true if the current OS is Windows (Q_OS_WINDOWS). */
isOsWindows()169 inline bool isOsWindows() {
170 #ifdef Q_OS_WIN
171     return true;
172 #else
173     return false;
174 #endif
175 }
176 
177 /** Returns true if the current OS is MacOS (Q_OS_DARWIN). */
isOsMac()178 inline bool isOsMac() {
179 #ifdef Q_OS_DARWIN
180     return true;
181 #else
182     return false;
183 #endif
184 }
185 
186 /** Returns true if the current OS is Linux (Q_OS_LINUX). */
isOsLinux()187 inline bool isOsLinux() {
188 #ifdef Q_OS_LINUX
189     return true;
190 #else
191     return false;
192 #endif
193 }
194 
195 /** Returns true if the current OS is a variant of Unix (Q_OS_UNIX). */
isOsUnix()196 inline bool isOsUnix() {
197 #ifdef Q_OS_UNIX
198     return true;
199 #else
200     return false;
201 #endif
202 }
203 
204 /** Backport of qAsConst for QT < 5.7.0. */
205 #if (QT_VERSION < QT_VERSION_CHECK(5, 7, 0))
206 template<typename T>
qAsConst(T & t)207 Q_DECL_CONSTEXPR typename std::add_const<T>::type &qAsConst(T &t) noexcept {
208     return t;
209 }
210 template<typename T>
211 void qAsConst(const T &&) = delete;
212 #endif
213 
214 #endif
215