OSDN Git Service

2369b9c7255b9673e54c5188ef72acba583b95b2
[x264-launcher/x264-launcher.git] / src / model_sysinfo.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Simple x264 Launcher
3 // Copyright (C) 2004-2019 LoRd_MuldeR <MuldeR2@GMX.de>
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 2 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13 // GNU General Public License for more details.
14 //
15 // You should have received a copy of the GNU General Public License along
16 // with this program; if not, write to the Free Software Foundation, Inc.,
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 //
19 // http://www.gnu.org/licenses/gpl-2.0.txt
20 ///////////////////////////////////////////////////////////////////////////////
21
22 #pragma once
23
24 #include <QMutex>
25 #include <QMutexLocker>
26 #include <QString>
27 #include <QFlags>
28
29 ///////////////////////////////////////////////////////////////////////////////
30
31 #define SYSINFO_MAKE_FLAG(NAME) \
32         protected: \
33                 QFlags<NAME##_t> m_flag##NAME; \
34         public: \
35                 inline void set##NAME(const NAME##_t &flag, const bool &enable) \
36                 { \
37                         QMutexLocker lock(&m_mutex); \
38                         if(enable) m_flag##NAME |= flag; else m_flag##NAME &= (~flag); \
39                 } \
40                 inline bool get##NAME(const NAME##_t &flag) const \
41                 { \
42                         QMutexLocker lock(&m_mutex); \
43                         return m_flag##NAME.testFlag(flag); \
44                 } \
45                 inline bool has##NAME(void) const \
46                 { \
47                         QMutexLocker lock(&m_mutex); \
48                         return !!m_flag##NAME; \
49                 } \
50                 inline void clear##NAME(void) \
51                 { \
52                         QMutexLocker lock(&m_mutex); \
53                         m_flag##NAME &= 0; \
54                 }
55
56 #define SYSINFO_MAKE_PATH(NAME) \
57         protected: \
58                 QString m_path##NAME; \
59         public: \
60                 inline void set##NAME##Path(const QString &path) \
61                 { \
62                         QMutexLocker lock(&m_mutex); \
63                         m_path##NAME = path; \
64                 } \
65                 inline const QString get##NAME##Path(void) const \
66                 { \
67                         QMutexLocker lock(&m_mutex); \
68                         const QString path = m_path##NAME; \
69                         return path; \
70                 } \
71                 inline void clear##NAME##Path(void) \
72                 { \
73                         QMutexLocker lock(&m_mutex); \
74                         m_path##NAME.clear(); \
75                 }
76
77 ///////////////////////////////////////////////////////////////////////////////
78
79 class SysinfoModel
80 {
81 public:
82         SysinfoModel(void) {}
83         
84         typedef enum _CPUFeatures_t
85         {
86                 CPUFeatures_MMX = 0x1,
87                 CPUFeatures_SSE = 0x2,
88                 CPUFeatures_X64 = 0x4,
89         }
90         CPUFeatures_t;
91
92         typedef enum _Avisynth_t
93         {
94                 Avisynth_X86 = 0x1,
95                 Avisynth_X64 = 0x2,
96         }
97         Avisynth_t;
98
99         typedef enum _VapourSynth_t
100         {
101                 VapourSynth_X86 = 0x1,
102                 VapourSynth_X64 = 0x2,
103         }
104         VapourSynth_t;
105
106         SYSINFO_MAKE_FLAG(CPUFeatures)
107         SYSINFO_MAKE_FLAG(Avisynth)
108         SYSINFO_MAKE_FLAG(VapourSynth)
109
110         SYSINFO_MAKE_PATH(AVS)
111         SYSINFO_MAKE_PATH(VPS32)
112         SYSINFO_MAKE_PATH(VPS64)
113         SYSINFO_MAKE_PATH(App)
114
115 protected:
116         mutable QMutex m_mutex;
117 };
118
119 #undef SYSINFO_MAKE_FLAG
120 #undef SYSINFO_MAKE_PATH