/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. #ifndef KANDAS_CONSOLE_BASEDATA_H
  19. #define KANDAS_CONSOLE_BASEDATA_H
  20. #include <kandas-daemon/definitions.h>
  21. #include <QList>
  22. namespace Kandas
  23. {
  24. namespace Console
  25. {
  26. struct Device
  27. {
  28. QString name, serial;
  29. Kandas::DeviceState state;
  30. bool hasWriteKey;
  31. };
  32. struct Slot
  33. {
  34. int number;
  35. QString device, blockDevice;
  36. Kandas::SlotState state;
  37. };
  38. class DeviceList : public QList<Kandas::Console::Device*>
  39. {
  40. public:
  41. Kandas::Console::Device* device(const QString &name)
  42. {
  43. foreach (Kandas::Console::Device* theDevice, *this)
  44. if (theDevice->name == name)
  45. return theDevice;
  46. return 0;
  47. }
  48. };
  49. class SlotList : public QList<Kandas::Console::Slot*>
  50. {
  51. public:
  52. Kandas::Console::Slot* slot(int number)
  53. {
  54. foreach (Kandas::Console::Slot* theSlot, *this)
  55. if (theSlot->number == number)
  56. return theSlot;
  57. return 0;
  58. }
  59. };
  60. }
  61. }
  62. #endif // KANDAS_CONSOLE_BASEDATA_H