CanDb.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. Copyright (c) 2015, 2016 Hubert Denkmair <hubert@denkmair.de>
  3. This file is part of cangaroo.
  4. cangaroo is free software: you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation, either version 2 of the License, or
  7. (at your option) any later version.
  8. cangaroo is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with cangaroo. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. #pragma once
  16. #include <QString>
  17. #include <QList>
  18. #include <QMap>
  19. #include <QSharedPointer>
  20. #include "CanDbNode.h"
  21. #include "CanDbMessage.h"
  22. class QDomDocument;
  23. class QDomElement;
  24. class Backend;
  25. class CanDb;
  26. class CanDbMessage;
  27. typedef QMap<QString,CanDbNode*> CanDbNodeMap;
  28. typedef QMap<uint32_t, CanDbMessage*> CanDbMessageList;
  29. typedef QSharedPointer<CanDb> pCanDb;
  30. class CanDb
  31. {
  32. public:
  33. CanDb();
  34. void setPath(QString path) { _path = path; }
  35. QString getPath() { return _path; }
  36. QString getFileName();
  37. QString getDirectory();
  38. void setVersion(QString version) { _version = version; }
  39. QString getVersion() { return _version; }
  40. CanDbNode *getOrCreateNode(QString node_name);
  41. CanDbMessage *getMessageById(uint32_t raw_id);
  42. void addMessage(CanDbMessage *msg);
  43. QString getComment() const;
  44. void setComment(const QString &comment);
  45. bool saveXML(Backend &backend, QDomDocument &xml, QDomElement &root);
  46. private:
  47. QString _path;
  48. QString _version;
  49. QString _comment;
  50. CanDbNodeMap _nodes;
  51. CanDbMessageList _messages;
  52. };