##// END OF EJS Templates
Minor fixes...
Alexandre Leroux -
r32:8866878c2cb6
parent child
Show More
@@ -1,3 +1,5
1 1 build/
2 2 CMakeLists.txt.user
3 3 /.project
4 core/src/Version.cpp
5 core/include/Version.h
@@ -1,39 +1,38
1 1 /*------------------------------------------------------------------------------
2 2 -- This file is a part of the QLop Software
3 3 -- Copyright (C) 2015, Plasma Physics Laboratory - CNRS
4 4 --
5 5 -- This program is free software; you can redistribute it and/or modify
6 6 -- it under the terms of the GNU General Public License as published by
7 7 -- the Free Software Foundation; either version 2 of the License, or
8 8 -- (at your option) any later version.
9 9 --
10 10 -- This program is distributed in the hope that it will be useful,
11 11 -- but WITHOUT ANY WARRANTY; without even the implied warranty of
12 12 -- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 13 -- GNU General Public License for more details.
14 14 --
15 15 -- You should have received a copy of the GNU General Public License
16 16 -- along with this program; if not, write to the Free Software
17 17 -- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 18 -------------------------------------------------------------------------------*/
19 19 /*-- Author : Alexis Jeandet
20 20 -- Mail : alexis.jeandet@member.fsf.org
21 21 ----------------------------------------------------------------------------*/
22 22 #include "mainwindow.h"
23 23 #include <QProcessEnvironment>
24 24 #include <QThread>
25 25 #include <SqpApplication.h>
26 26 #include <qglobal.h>
27 27
28 28 int main(int argc, char *argv[])
29 29 {
30 int ad;
31 SqpApplication a(argc, argv);
30 SqpApplication a{argc, argv};
32 31 SqpApplication::setOrganizationName("LPP");
33 32 SqpApplication::setOrganizationDomain("lpp.fr");
34 33 SqpApplication::setApplicationName("SciQLop");
35 34 MainWindow w;
36 35 w.show();
37 36
38 37 return a.exec();
39 38 }
@@ -1,460 +1,462
1 1 /*
2 2 ====================================================================
3 3 A Smart Pointer to IMPLementation (i.e. Smart PIMPL or just SPIMPL).
4 4 ====================================================================
5 5
6 6 Version: 1.1
7 7
8 8 Latest version:
9 9 https://github.com/oliora/samples/blob/master/spimpl.h
10 10 Rationale and description:
11 11 http://oliora.github.io/2015/12/29/pimpl-and-rule-of-zero.html
12 12
13 13 Copyright (c) 2015 Andrey Upadyshev (oliora@gmail.com)
14 14
15 15 Distributed under the Boost Software License, Version 1.0.
16 16 See http://www.boost.org/LICENSE_1_0.txt
17 17
18 18 Changes history
19 19 ---------------
20 20 v1.1:
21 21 - auto_ptr support is disabled by default for C++17 compatibility
22 22 v1.0:
23 23 - Released
24 24 */
25 25
26 26 #ifndef SPIMPL_H_
27 27 #define SPIMPL_H_
28 28
29 29 #include <cassert>
30 30 #include <memory>
31 31 #include <type_traits>
32 32
33 33 #if defined _MSC_VER && _MSC_VER < 1900 // MS Visual Studio before VS2015
34 34 #define SPIMPL_NO_CPP11_NOEXCEPT
35 35 #define SPIMPL_NO_CPP11_CONSTEXPR
36 36 #define SPIMPL_NO_CPP11_DEFAULT_MOVE_SPEC_FUNC
37 37 #endif
38 38
39 39 #if !defined SPIMPL_NO_CPP11_NOEXCEPT
40 40 #define SPIMPL_NOEXCEPT noexcept
41 41 #else
42 42 #define SPIMPL_NOEXCEPT
43 43 #endif
44 44
45 45 #if !defined SPIMPL_NO_CPP11_CONSTEXPR
46 46 #define SPIMPL_CONSTEXPR constexpr
47 47 #else
48 48 #define SPIMPL_CONSTEXPR
49 49 #endif
50 50
51 51 // define SPIMPL_HAS_AUTO_PTR to enable constructor and assignment operator that accept
52 52 // std::auto_ptr
53 53 // TODO: auto detect std::auto_ptr support
54 54
55 55
56 56 namespace spimpl {
57 57 namespace details {
58 58 template <class T>
59 59 T *default_copy(T *src)
60 60 {
61 61 static_assert(sizeof(T) > 0, "default_copy cannot copy incomplete type");
62 62 static_assert(!std::is_void<T>::value, "default_copy cannot copy incomplete type");
63 63 return new T(*src);
64 64 }
65 65
66 66 template <class T>
67 67 void default_delete(T *p) SPIMPL_NOEXCEPT
68 68 {
69 69 static_assert(sizeof(T) > 0, "default_delete cannot delete incomplete type");
70 70 static_assert(!std::is_void<T>::value, "default_delete cannot delete incomplete type");
71 71 delete p;
72 72 }
73 73
74 74 template <class T>
75 75 struct default_deleter {
76 76 using type = void (*)(T *);
77 77 };
78 78
79 79 template <class T>
80 80 using default_deleter_t = typename default_deleter<T>::type;
81 81
82 82 template <class T>
83 83 struct default_copier {
84 84 using type = T *(*)(T *);
85 85 };
86 86
87 87 template <class T>
88 88 using default_copier_t = typename default_copier<T>::type;
89 89
90 90 template <class T, class D, class C>
91 91 struct is_default_manageable
92 : public std::integral_constant<bool, std::is_same<D, default_deleter_t<T> >::value
93 && std::is_same<C, default_copier_t<T> >::value> {
92 : public std::integral_constant<bool,
93 std::is_same<D, default_deleter_t<T> >::value
94 && std::is_same<C, default_copier_t<T> >::value> {
94 95 };
95 96 }
96 97
97 98
98 99 template <class T, class Deleter = details::default_deleter_t<T>,
99 100 class Copier = details::default_copier_t<T> >
100 101 class impl_ptr {
101 102 private:
102 103 static_assert(!std::is_array<T>::value,
103 104 "impl_ptr specialization for arrays is not implemented");
104 105 struct dummy_t_ {
105 106 int dummy__;
106 107 };
107 108
108 109 public:
109 110 using pointer = T *;
110 111 using element_type = T;
111 112 using copier_type = typename std::decay<Copier>::type;
112 113 using deleter_type = typename std::decay<Deleter>::type;
113 114 using unique_ptr_type = std::unique_ptr<T, deleter_type>;
114 115 using is_default_manageable = details::is_default_manageable<T, deleter_type, copier_type>;
115 116
116 117 SPIMPL_CONSTEXPR impl_ptr() SPIMPL_NOEXCEPT : ptr_(nullptr, deleter_type{}),
117 118 copier_(copier_type{})
118 119 {
119 120 }
120 121
121 122 SPIMPL_CONSTEXPR impl_ptr(std::nullptr_t) SPIMPL_NOEXCEPT : impl_ptr() {}
122 123
123 124 template <class D, class C>
124 125 impl_ptr(pointer p, D &&d, C &&c,
125 126 typename std::enable_if<std::is_convertible<D, deleter_type>::value
126 127 && std::is_convertible<C, copier_type>::value,
127 128 dummy_t_>::type
128 129 = dummy_t_()) SPIMPL_NOEXCEPT : ptr_(std::move(p), std::forward<D>(d)),
129 130 copier_(std::forward<C>(c))
130 131 {
131 132 }
132 133
133 134 template <class U>
134 impl_ptr(U *u, typename std::enable_if<std::is_convertible<U *, pointer>::value
135 && is_default_manageable::value,
136 dummy_t_>::type
137 = dummy_t_()) SPIMPL_NOEXCEPT
135 impl_ptr(U *u,
136 typename std::enable_if<std::is_convertible<U *, pointer>::value
137 && is_default_manageable::value,
138 dummy_t_>::type
139 = dummy_t_()) SPIMPL_NOEXCEPT
138 140 : impl_ptr(u, &details::default_delete<T>, &details::default_copy<T>)
139 141 {
140 142 }
141 143
142 144 impl_ptr(const impl_ptr &r) : impl_ptr(r.clone()) {}
143 145
144 146 #ifndef SPIMPL_NO_CPP11_DEFAULT_MOVE_SPEC_FUNC
145 147 impl_ptr(impl_ptr &&r) SPIMPL_NOEXCEPT = default;
146 148 #else
147 149 impl_ptr(impl_ptr &&r) SPIMPL_NOEXCEPT : ptr_(std::move(r.ptr_)), copier_(std::move(r.copier_))
148 150 {
149 151 }
150 152 #endif
151 153
152 154 #ifdef SPIMPL_HAS_AUTO_PTR
153 155 template <class U>
154 impl_ptr(std::auto_ptr<U> &&u, typename std::enable_if<std::is_convertible<U *, pointer>::value
155 && is_default_manageable::value,
156 dummy_t_>::type
157 = dummy_t_()) SPIMPL_NOEXCEPT
158 : ptr_(u.release(), &details::default_delete<T>),
159 copier_(&details::default_copy<T>)
156 impl_ptr(std::auto_ptr<U> &&u,
157 typename std::enable_if<std::is_convertible<U *, pointer>::value
158 && is_default_manageable::value,
159 dummy_t_>::type
160 = dummy_t_()) SPIMPL_NOEXCEPT : ptr_(u.release(), &details::default_delete<T>),
161 copier_(&details::default_copy<T>)
160 162 {
161 163 }
162 164 #endif
163 165
164 166 template <class U>
165 167 impl_ptr(std::unique_ptr<U> &&u,
166 168 typename std::enable_if<std::is_convertible<U *, pointer>::value
167 169 && is_default_manageable::value,
168 170 dummy_t_>::type
169 171 = dummy_t_()) SPIMPL_NOEXCEPT : ptr_(u.release(), &details::default_delete<T>),
170 172 copier_(&details::default_copy<T>)
171 173 {
172 174 }
173 175
174 176 template <class U, class D, class C>
175 177 impl_ptr(std::unique_ptr<U, D> &&u, C &&c,
176 178 typename std::enable_if<std::is_convertible<U *, pointer>::value
177 179 && std::is_convertible<D, deleter_type>::value
178 180 && std::is_convertible<C, copier_type>::value,
179 181 dummy_t_>::type
180 182 = dummy_t_()) SPIMPL_NOEXCEPT : ptr_(std::move(u)),
181 183 copier_(std::forward<C>(c))
182 184 {
183 185 }
184 186
185 187 template <class U, class D, class C>
186 188 impl_ptr(impl_ptr<U, D, C> &&u,
187 189 typename std::enable_if<std::is_convertible<U *, pointer>::value
188 190 && std::is_convertible<D, deleter_type>::value
189 191 && std::is_convertible<C, copier_type>::value,
190 192 dummy_t_>::type
191 193 = dummy_t_()) SPIMPL_NOEXCEPT : ptr_(std::move(u.ptr_)),
192 194 copier_(std::move(u.copier_))
193 195 {
194 196 }
195 197
196 198 impl_ptr &operator=(const impl_ptr &r)
197 199 {
198 200 if (this == &r)
199 201 return *this;
200 202
201 203 return operator=(r.clone());
202 204 }
203 205
204 206 #ifndef SPIMPL_NO_CPP11_DEFAULT_MOVE_SPEC_FUNC
205 207 impl_ptr &operator=(impl_ptr &&r) SPIMPL_NOEXCEPT = default;
206 208 #else
207 209 impl_ptr &operator=(impl_ptr &&r) SPIMPL_NOEXCEPT
208 210 {
209 211 ptr_ = std::move(r.ptr_);
210 212 copier_ = std::move(r.copier_);
211 213 return *this;
212 214 }
213 215 #endif
214 216
215 217 template <class U, class D, class C>
216 218 typename std::enable_if<std::is_convertible<U *, pointer>::value
217 219 && std::is_convertible<D, deleter_type>::value
218 220 && std::is_convertible<C, copier_type>::value,
219 221 impl_ptr &>::type
220 222 operator=(impl_ptr<U, D, C> &&u) SPIMPL_NOEXCEPT
221 223 {
222 224 ptr_ = std::move(u.ptr_);
223 225 copier_ = std::move(u.copier_);
224 226 return *this;
225 227 }
226 228
227 229 template <class U, class D, class C>
228 230 typename std::enable_if<std::is_convertible<U *, pointer>::value
229 231 && std::is_convertible<D, deleter_type>::value
230 232 && std::is_convertible<C, copier_type>::value,
231 233 impl_ptr &>::type
232 234 operator=(const impl_ptr<U, D, C> &u)
233 235 {
234 236 return operator=(u.clone());
235 237 }
236 238
237 239 //
238 240
239 241 #ifdef SPIMPL_HAS_AUTO_PTR
240 242 template <class U>
241 243 typename std::enable_if<std::is_convertible<U *, pointer>::value
242 244 && is_default_manageable::value,
243 245 impl_ptr &>::type
244 246 operator=(std::auto_ptr<U> &&u) SPIMPL_NOEXCEPT
245 247 {
246 248 return operator=(impl_ptr(std::move(u)));
247 249 }
248 250 #endif
249 251
250 252 template <class U>
251 253 typename std::enable_if<std::is_convertible<U *, pointer>::value
252 254 && is_default_manageable::value,
253 255 impl_ptr &>::type
254 256 operator=(std::unique_ptr<U> &&u) SPIMPL_NOEXCEPT
255 257 {
256 258 return operator=(impl_ptr(std::move(u)));
257 259 }
258 260
259 261 impl_ptr clone() const
260 262 {
261 263 return impl_ptr(ptr_ ? copier_(ptr_.get()) : nullptr, ptr_.get_deleter(), copier_);
262 264 }
263 265
264 266 typename std::remove_reference<T>::type &operator*() const { return *ptr_; }
265 267 pointer operator->() const SPIMPL_NOEXCEPT { return get(); }
266 268 pointer get() const SPIMPL_NOEXCEPT { return ptr_.get(); }
267 269
268 270 void swap(impl_ptr &u) SPIMPL_NOEXCEPT
269 271 {
270 272 using std::swap;
271 273 ptr_.swap(u.ptr_);
272 274 swap(copier_, u.copier_);
273 275 }
274 276
275 277 pointer release() SPIMPL_NOEXCEPT { return ptr_.release(); }
276 278
277 279 unique_ptr_type release_unique() SPIMPL_NOEXCEPT { return std::move(ptr_); }
278 280
279 281 explicit operator bool() const SPIMPL_NOEXCEPT { return static_cast<bool>(ptr_); }
280 282
281 283 typename std::remove_reference<deleter_type>::type &get_deleter() SPIMPL_NOEXCEPT
282 284 {
283 285 return ptr_.get_deleter();
284 286 }
285 287 const typename std::remove_reference<deleter_type>::type &get_deleter() const SPIMPL_NOEXCEPT
286 288 {
287 289 return ptr_.get_deleter();
288 290 }
289 291
290 292 typename std::remove_reference<copier_type>::type &get_copier() SPIMPL_NOEXCEPT
291 293 {
292 294 return copier_;
293 295 }
294 296 const typename std::remove_reference<copier_type>::type &get_copier() const SPIMPL_NOEXCEPT
295 297 {
296 298 return copier_;
297 299 }
298 300
299 301 private:
300 302 unique_ptr_type ptr_;
301 303 copier_type copier_;
302 304 };
303 305
304 306
305 307 template <class T, class D, class C>
306 308 inline void swap(impl_ptr<T, D, C> &l, impl_ptr<T, D, C> &r) SPIMPL_NOEXCEPT
307 309 {
308 310 l.swap(r);
309 311 }
310 312
311 313
312 314 template <class T1, class D1, class C1, class T2, class D2, class C2>
313 315 inline bool operator==(const impl_ptr<T1, D1, C1> &l, const impl_ptr<T2, D2, C2> &r)
314 316 {
315 317 return l.get() == r.get();
316 318 }
317 319
318 320 template <class T1, class D1, class C1, class T2, class D2, class C2>
319 321 inline bool operator!=(const impl_ptr<T1, D1, C1> &l, const impl_ptr<T2, D2, C2> &r)
320 322 {
321 323 return !(l == r);
322 324 }
323 325
324 326 template <class T1, class D1, class C1, class T2, class D2, class C2>
325 327 inline bool operator<(const impl_ptr<T1, D1, C1> &l, const impl_ptr<T2, D2, C2> &r)
326 328 {
327 329 using P1 = typename impl_ptr<T1, D1, C1>::pointer;
328 330 using P2 = typename impl_ptr<T2, D2, C2>::pointer;
329 331 using CT = typename std::common_type<P1, P2>::type;
330 332 return std::less<CT>()(l.get(), r.get());
331 333 }
332 334
333 335 template <class T1, class D1, class C1, class T2, class D2, class C2>
334 336 inline bool operator>(const impl_ptr<T1, D1, C1> &l, const impl_ptr<T2, D2, C2> &r)
335 337 {
336 338 return r < l;
337 339 }
338 340
339 341 template <class T1, class D1, class C1, class T2, class D2, class C2>
340 342 inline bool operator<=(const impl_ptr<T1, D1, C1> &l, const impl_ptr<T2, D2, C2> &r)
341 343 {
342 344 return !(r < l);
343 345 }
344 346
345 347 template <class T1, class D1, class C1, class T2, class D2, class C2>
346 348 inline bool operator>=(const impl_ptr<T1, D1, C1> &l, const impl_ptr<T2, D2, C2> &r)
347 349 {
348 350 return !(l < r);
349 351 }
350 352
351 353 template <class T, class D, class C>
352 354 inline bool operator==(const impl_ptr<T, D, C> &p, std::nullptr_t) SPIMPL_NOEXCEPT
353 355 {
354 356 return !p;
355 357 }
356 358
357 359 template <class T, class D, class C>
358 360 inline bool operator==(std::nullptr_t, const impl_ptr<T, D, C> &p) SPIMPL_NOEXCEPT
359 361 {
360 362 return !p;
361 363 }
362 364
363 365 template <class T, class D, class C>
364 366 inline bool operator!=(const impl_ptr<T, D, C> &p, std::nullptr_t) SPIMPL_NOEXCEPT
365 367 {
366 368 return static_cast<bool>(p);
367 369 }
368 370
369 371 template <class T, class D, class C>
370 372 inline bool operator!=(std::nullptr_t, const impl_ptr<T, D, C> &p) SPIMPL_NOEXCEPT
371 373 {
372 374 return static_cast<bool>(p);
373 375 }
374 376
375 377 template <class T, class D, class C>
376 378 inline bool operator<(const impl_ptr<T, D, C> &l, std::nullptr_t)
377 379 {
378 380 using P = typename impl_ptr<T, D, C>::pointer;
379 381 return std::less<P>()(l.get(), nullptr);
380 382 }
381 383
382 384 template <class T, class D, class C>
383 385 inline bool operator<(std::nullptr_t, const impl_ptr<T, D, C> &p)
384 386 {
385 387 using P = typename impl_ptr<T, D, C>::pointer;
386 388 return std::less<P>()(nullptr, p.get());
387 389 }
388 390
389 391 template <class T, class D, class C>
390 392 inline bool operator>(const impl_ptr<T, D, C> &p, std::nullptr_t)
391 393 {
392 394 return nullptr < p;
393 395 }
394 396
395 397 template <class T, class D, class C>
396 398 inline bool operator>(std::nullptr_t, const impl_ptr<T, D, C> &p)
397 399 {
398 400 return p < nullptr;
399 401 }
400 402
401 403 template <class T, class D, class C>
402 404 inline bool operator<=(const impl_ptr<T, D, C> &p, std::nullptr_t)
403 405 {
404 406 return !(nullptr < p);
405 407 }
406 408
407 409 template <class T, class D, class C>
408 410 inline bool operator<=(std::nullptr_t, const impl_ptr<T, D, C> &p)
409 411 {
410 412 return !(p < nullptr);
411 413 }
412 414
413 415 template <class T, class D, class C>
414 416 inline bool operator>=(const impl_ptr<T, D, C> &p, std::nullptr_t)
415 417 {
416 418 return !(p < nullptr);
417 419 }
418 420
419 421 template <class T, class D, class C>
420 422 inline bool operator>=(std::nullptr_t, const impl_ptr<T, D, C> &p)
421 423 {
422 424 return !(nullptr < p);
423 425 }
424 426
425 427
426 428 template <class T, class... Args>
427 429 inline impl_ptr<T> make_impl(Args &&... args)
428 430 {
429 431 return impl_ptr<T>(new T(std::forward<Args>(args)...), &details::default_delete<T>,
430 432 &details::default_copy<T>);
431 433 }
432 434
433 435
434 436 // Helpers to manage unique impl, stored in std::unique_ptr
435 437
436 438 template <class T, class Deleter = void (*)(T *)>
437 439 using unique_impl_ptr = std::unique_ptr<T, Deleter>;
438 440
439 441 template <class T, class... Args>
440 442 inline unique_impl_ptr<T> make_unique_impl(Args &&... args)
441 443 {
442 444 static_assert(!std::is_array<T>::value, "unique_impl_ptr does not support arrays");
443 445 return unique_impl_ptr<T>(new T(std::forward<Args>(args)...), &details::default_delete<T>);
444 446 }
445 447 }
446 448
447 449 namespace std {
448 450 template <class T, class D, class C>
449 451 struct hash<spimpl::impl_ptr<T, D, C> > {
450 452 using argument_type = spimpl::impl_ptr<T, D, C>;
451 453 using result_type = size_t;
452 454
453 455 result_type operator()(const argument_type &p) const SPIMPL_NOEXCEPT
454 456 {
455 457 return hash<typename argument_type::pointer>()(p.get());
456 458 }
457 459 };
458 460 }
459 461
460 462 #endif // SPIMPL_H_
@@ -1,39 +1,37
1 1 #ifndef SCIQLOP_DATASOURCECONTROLLER_H
2 2 #define SCIQLOP_DATASOURCECONTROLLER_H
3 3
4 #include "DataSourceController.h"
5
6 4 #include <QLoggingCategory>
7 5 #include <QObject>
8 6
9 7 #include <Common/spimpl.h>
10 8
11 9 Q_DECLARE_LOGGING_CATEGORY(LOG_DataSourceController)
12 10
13 11 /**
14 12 * @brief The DataSourceController class aims to make the link between SciQlop
15 13 * and its plugins. This is the intermediate class that SciQlop have to use
16 14 * in the way to connect a data source. Please first use load method to intialize
17 15 * a plugin specified by its metadata name (JSON plugin source) then others specifics
18 16 * method will ba able to access it.
19 17 * You can load a data source driver plugin then create a data source.
20 18 */
21 19 class DataSourceController : public QObject {
22 20 Q_OBJECT
23 21 public:
24 22 explicit DataSourceController(QObject *parent = 0);
25 23 virtual ~DataSourceController();
26 24
27 25 public slots:
28 26 /// Manage init/end of the controller
29 27 void initialize();
30 28 void finalize();
31 29
32 30 private:
33 31 void waitForFinish();
34 32
35 33 class DataSourceControllerPrivate;
36 34 spimpl::unique_impl_ptr<DataSourceControllerPrivate> impl;
37 35 };
38 36
39 37 #endif // SCIQLOP_DATASOURCECONTROLLER_H
@@ -1,48 +1,46
1 #include "DataSource/DataSourceController.h"
1 #include <DataSource/DataSourceController.h>
2 2
3 3 #include <QMutex>
4 4 #include <QThread>
5 5
6 6 #include <QDir>
7 7 #include <QStandardPaths>
8 8
9 9 Q_LOGGING_CATEGORY(LOG_DataSourceController, "DataSourceController")
10 10
11 11 class DataSourceController::DataSourceControllerPrivate {
12 12 public:
13 DataSourceControllerPrivate() {}
14
15 13 QMutex m_WorkingMutex;
16 14 };
17 15
18 16 DataSourceController::DataSourceController(QObject *parent)
19 17 : impl{spimpl::make_unique_impl<DataSourceControllerPrivate>()}
20 18 {
21 qCDebug(LOG_DataSourceController()) << tr("Construction du DataSourceController")
22 << QThread::currentThread();
19 qCDebug(LOG_DataSourceController())
20 << tr("DataSourceController construction") << QThread::currentThread();
23 21 }
24 22
25 23 DataSourceController::~DataSourceController()
26 24 {
27 qCDebug(LOG_DataSourceController()) << tr("Desctruction du DataSourceController")
28 << QThread::currentThread();
25 qCDebug(LOG_DataSourceController())
26 << tr("DataSourceController destruction") << QThread::currentThread();
29 27 this->waitForFinish();
30 28 }
31 29
32 30 void DataSourceController::initialize()
33 31 {
34 qCDebug(LOG_DataSourceController()) << tr("initialize du DataSourceController")
35 << QThread::currentThread();
32 qCDebug(LOG_DataSourceController())
33 << tr("DataSourceController init") << QThread::currentThread();
36 34 impl->m_WorkingMutex.lock();
37 qCDebug(LOG_DataSourceController()) << tr("initialize du DataSourceController END");
35 qCDebug(LOG_DataSourceController()) << tr("DataSourceController init END");
38 36 }
39 37
40 38 void DataSourceController::finalize()
41 39 {
42 40 impl->m_WorkingMutex.unlock();
43 41 }
44 42
45 43 void DataSourceController::waitForFinish()
46 44 {
47 QMutexLocker locker(&impl->m_WorkingMutex);
45 QMutexLocker locker{&impl->m_WorkingMutex};
48 46 }
@@ -1,34 +1,34
1 1 #ifndef SCIQLOP_SQPAPPLICATION_H
2 2 #define SCIQLOP_SQPAPPLICATION_H
3 3
4 4 #include "SqpApplication.h"
5 5
6 6 #include <QApplication>
7 7 #include <QLoggingCategory>
8 8
9 9 #include <Common/spimpl.h>
10 10
11 11 Q_DECLARE_LOGGING_CATEGORY(LOG_SqpApplication)
12 12
13 13 /**
14 14 * @brief The SqpApplication class aims to make the link between SciQlop
15 * and its plugins. This is the intermediate class that SciQlop have to use
16 * in the way to connect a data source. Please first use load method to intialize
15 * and its plugins. This is the intermediate class that SciQlop has to use
16 * in the way to connect a data source. Please first use load method to initialize
17 17 * a plugin specified by its metadata name (JSON plugin source) then others specifics
18 * method will ba able to access it.
18 * method will be able to access it.
19 19 * You can load a data source driver plugin then create a data source.
20 20 */
21 21
22 22 class SqpApplication : public QApplication {
23 23 Q_OBJECT
24 24 public:
25 25 explicit SqpApplication(int &argc, char **argv);
26 26 virtual ~SqpApplication();
27 27 void initialize();
28 28
29 29 private:
30 30 class SqpApplicationPrivate;
31 31 spimpl::unique_impl_ptr<SqpApplicationPrivate> impl;
32 32 };
33 33
34 34 #endif // SCIQLOP_SQPAPPLICATION_H
@@ -1,45 +1,46
1 1 #include "SqpApplication.h"
2 2
3 3 #include <DataSource/DataSourceController.h>
4 4 #include <QThread>
5 5
6 6 Q_LOGGING_CATEGORY(LOG_SqpApplication, "SqpApplication")
7 7
8 8 class SqpApplication::SqpApplicationPrivate {
9 9 public:
10 SqpApplicationPrivate() {}
10 SqpApplicationPrivate() : m_DataSourceController{std::make_unique<DataSourceController>()}
11 {
12 m_DataSourceController->moveToThread(&m_DataSourceControllerThread);
13 }
14
11 15 virtual ~SqpApplicationPrivate()
12 16 {
13 qCInfo(LOG_SqpApplication()) << tr("Desctruction du SqpApplicationPrivate");
17 qCInfo(LOG_SqpApplication()) << tr("SqpApplicationPrivate destruction");
14 18 m_DataSourceControllerThread.quit();
15 19 m_DataSourceControllerThread.wait();
16 20 }
17 21
18 22 std::unique_ptr<DataSourceController> m_DataSourceController;
19 23 QThread m_DataSourceControllerThread;
20 24 };
21 25
22 26
23 27 SqpApplication::SqpApplication(int &argc, char **argv)
24 : QApplication(argc, argv), impl{spimpl::make_unique_impl<SqpApplicationPrivate>()}
28 : QApplication{argc, argv}, impl{spimpl::make_unique_impl<SqpApplicationPrivate>()}
25 29 {
26 qCInfo(LOG_SqpApplication()) << tr("Construction du SqpApplication");
27
28 impl->m_DataSourceController = std::make_unique<DataSourceController>();
29 impl->m_DataSourceController->moveToThread(&impl->m_DataSourceControllerThread);
30 qCInfo(LOG_SqpApplication()) << tr("SqpApplication construction");
30 31
31 32 connect(&impl->m_DataSourceControllerThread, &QThread::started,
32 33 impl->m_DataSourceController.get(), &DataSourceController::initialize);
33 34 connect(&impl->m_DataSourceControllerThread, &QThread::finished,
34 35 impl->m_DataSourceController.get(), &DataSourceController::finalize);
35 36
36 37 impl->m_DataSourceControllerThread.start();
37 38 }
38 39
39 40 SqpApplication::~SqpApplication()
40 41 {
41 42 }
42 43
43 44 void SqpApplication::initialize()
44 45 {
45 46 }
General Comments 0
You need to be logged in to leave comments. Login now