PageRenderTime 27ms CodeModel.GetById 12ms app.highlight 10ms RepoModel.GetById 1ms app.codeStats 0ms

/src/kandas-console/base-data.h

http://kandas.googlecode.com/
C++ Header | 71 lines | 45 code | 9 blank | 17 comment | 4 complexity | c8f36e9b0365c77a9d209e967b2fe187 MD5 | raw file
 1/***************************************************************************
 2 *   Copyright 2009 Stefan Majewsky <majewsky@gmx.net>
 3 *
 4 *   This program is free software; you can redistribute it and/or
 5 *   modify it under the terms of the GNU General Public
 6 *   License as published by the Free Software Foundation; either
 7 *   version 2 of the License, or (at your option) any later version.
 8 *
 9 *   This program is distributed in the hope that it will be useful,
10 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
11 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 *   GNU General Public License for more details.
13 *
14 *   You should have received a copy of the GNU General Public License
15 *   along with this program; if not, write to the Free Software
16 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 ***************************************************************************/
18
19#ifndef KANDAS_CONSOLE_BASEDATA_H
20#define KANDAS_CONSOLE_BASEDATA_H
21
22#include <kandas-daemon/definitions.h>
23#include <QList>
24
25namespace Kandas
26{
27    namespace Console
28    {
29
30        struct Device
31        {
32            QString name, serial;
33            Kandas::DeviceState state;
34            bool hasWriteKey;
35        };
36
37        struct Slot
38        {
39            int number;
40            QString device, blockDevice;
41            Kandas::SlotState state;
42        };
43
44        class DeviceList : public QList<Kandas::Console::Device*>
45        {
46            public:
47                Kandas::Console::Device* device(const QString &name)
48                {
49                    foreach (Kandas::Console::Device* theDevice, *this)
50                        if (theDevice->name == name)
51                            return theDevice;
52                    return 0;
53                }
54        };
55
56        class SlotList : public QList<Kandas::Console::Slot*>
57        {
58            public:
59                Kandas::Console::Slot* slot(int number)
60                {
61                    foreach (Kandas::Console::Slot* theSlot, *this)
62                        if (theSlot->number == number)
63                            return theSlot;
64                    return 0;
65                }
66        };
67
68    }
69}
70
71#endif // KANDAS_CONSOLE_BASEDATA_H