Torc  0.1
torcdevicehandler.cpp
Go to the documentation of this file.
1 /* Class TorcDeviceHandler
2 *
3 * Copyright (C) Mark Kendall 2016=18
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
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 */
19 
20 // Torc
21 #include "torcdevicehandler.h"
22 
23 QList<TorcDeviceHandler*> TorcDeviceHandler::gTorcDeviceHandlers;
24 TorcDeviceHandler* TorcDeviceHandler::gTorcDeviceHandler = nullptr;
25 QMutex* TorcDeviceHandler::gTorcDeviceHandlersLock = new QMutex(QMutex::Recursive);
26 
28  : m_handlerLock(QReadWriteLock::Recursive),
29  m_nextTorcDeviceHandler(nullptr)
30 {
31  QMutexLocker lock(gTorcDeviceHandlersLock);
32  m_nextTorcDeviceHandler = gTorcDeviceHandler;
33  gTorcDeviceHandler = this;
34 }
35 
37 {
38  return m_nextTorcDeviceHandler;
39 }
40 
42 {
43  return gTorcDeviceHandler;
44 }
45 
46 void TorcDeviceHandler::Start(const QVariantMap &Details)
47 {
49  for ( ; handler; handler = handler->GetNextHandler())
50  handler->Create(Details);
51 }
52 
54 {
56  for ( ; handler; handler = handler->GetNextHandler())
57  handler->Destroy();
58 }
static void Stop(void)
static TorcDeviceHandler * GetDeviceHandler(void)
static void Start(const QVariantMap &Details)
virtual void Create(const QVariantMap &Details)=0
TorcDeviceHandler * GetNextHandler(void)
virtual void Destroy(void)=0