2 ******************************************************************************
4 * @file uavobjecthelper.h
5 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2012.
8 * @addtogroup UAVObjectHelper
11 *****************************************************************************/
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 3 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #ifndef UAVOBJECTHELPER_H
29 #define UAVOBJECTHELPER_H
34 #include <QMutexLocker>
36 #include "uavobjectutil_global.h"
37 #include "uavobject.h"
39 class UAVOBJECTUTIL_EXPORT AbstractUAVObjectHelper
: public QObject
{
42 explicit AbstractUAVObjectHelper(QObject
*parent
= 0);
43 virtual ~AbstractUAVObjectHelper();
45 enum Result
{ SUCCESS
, FAIL
, TIMEOUT
};
47 // default timeout = 3 x 250ms + 50ms safety margin = 800ms
48 // where 3 is the number of UAVTalk retries and 250ms is the UAVTalk timeout
49 Result
doObjectAndWait(UAVObject
*object
, int timeout
= 800);
52 virtual void doObjectAndWaitImpl() = 0;
56 void transactionCompleted(UAVObject
*object
, bool success
);
60 QEventLoop m_eventLoop
;
61 bool m_transactionResult
;
62 bool m_transactionCompleted
;
65 class UAVOBJECTUTIL_EXPORT UAVObjectUpdaterHelper
: public AbstractUAVObjectHelper
{
68 explicit UAVObjectUpdaterHelper(QObject
*parent
= 0);
69 virtual ~UAVObjectUpdaterHelper();
72 virtual void doObjectAndWaitImpl();
75 class UAVOBJECTUTIL_EXPORT UAVObjectRequestHelper
: public AbstractUAVObjectHelper
{
78 explicit UAVObjectRequestHelper(QObject
*parent
= 0);
79 virtual ~UAVObjectRequestHelper();
82 virtual void doObjectAndWaitImpl();
85 #endif // UAVOBJECTHELPER_H