androidglobal.h 2.9 KB
Newer Older
BogDan Vatra's avatar
BogDan Vatra committed
1
2
/**************************************************************************
**
3
** Copyright (c) 2014 BogDan Vatra <bog_dan_ro@yahoo.com>
hjk's avatar
hjk committed
4
** Contact: http://www.qt-project.org/legal
BogDan Vatra's avatar
BogDan Vatra committed
5
**
hjk's avatar
hjk committed
6
** This file is part of Qt Creator.
BogDan Vatra's avatar
BogDan Vatra committed
7
**
hjk's avatar
hjk committed
8
9
10
11
12
13
14
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.  For licensing terms and
** conditions see http://qt.digia.com/licensing.  For further information
** use the contact form at http://qt.digia.com/contact-us.
BogDan Vatra's avatar
BogDan Vatra committed
15
16
**
** GNU Lesser General Public License Usage
hjk's avatar
hjk committed
17
18
19
20
21
22
23
24
25
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights.  These rights are described in the Digia Qt LGPL Exception
BogDan Vatra's avatar
BogDan Vatra committed
26
27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
28
****************************************************************************/
BogDan Vatra's avatar
BogDan Vatra committed
29
30
31
32
33
34

#ifndef ANDROIDGLOBAL_H
#define ANDROIDGLOBAL_H

#include <utils/environment.h>

35
#include <projectexplorer/buildconfiguration.h>
BogDan Vatra's avatar
BogDan Vatra committed
36
37
38
39
40
41
42
43
44
45
46
47
#include <projectexplorer/buildsteplist.h>

#define ASSERT_STATE_GENERIC(State, expected, actual)                         \
    AndroidGlobal::assertState<State>(expected, actual, Q_FUNC_INFO)

namespace Android {
namespace Internal {

class AndroidGlobal
{
public:

48
    template<class T> static T *buildStep(const ProjectExplorer::BuildConfiguration *dc)
BogDan Vatra's avatar
BogDan Vatra committed
49
    {
Robert Loehning's avatar
Robert Loehning committed
50
        foreach (const Core::Id &id, dc->knownStepLists()) {
51
52
53
54
55
56
57
58
            ProjectExplorer::BuildStepList *bsl = dc->stepList(id);
            if (!bsl)
                return 0;
            const QList<ProjectExplorer::BuildStep *> &buildSteps = bsl->steps();
            for (int i = buildSteps.count() - 1; i >= 0; --i) {
                if (T * const step = qobject_cast<T *>(buildSteps.at(i)))
                    return step;
            }
BogDan Vatra's avatar
BogDan Vatra committed
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
        }
        return 0;
    }

    template<typename State> static void assertState(State expected,
        State actual, const char *func)
    {
        assertState(QList<State>() << expected, actual, func);
    }

    template<typename State> static void assertState(const QList<State> &expected,
        State actual, const char *func)
    {
        if (!expected.contains(actual)) {
            qWarning("Warning: Unexpected state %d in function %s.",
                actual, func);
        }
    }
};

} // namespace Internal
} // namespace Android

#endif // ANDROIDGLOBAL_H