ctkCmdLineModuleObjectTreeWalker_p.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /*=============================================================================
  2. Library: CTK
  3. Copyright (c) German Cancer Research Center,
  4. Division of Medical and Biological Informatics
  5. Licensed under the Apache License, Version 2.0 (the "License");
  6. you may not use this file except in compliance with the License.
  7. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. =============================================================================*/
  15. #ifndef CTKCMDLINEMODULEOBJECTTREEWALKER_H
  16. #define CTKCMDLINEMODULEOBJECTTREEWALKER_H
  17. #include <QStack>
  18. class QObject;
  19. class QVariant;
  20. class ctkCmdLineModuleObjectTreeWalker
  21. {
  22. public:
  23. enum TokenType {
  24. NoToken,
  25. Executable,
  26. ParameterGroup,
  27. Parameter
  28. };
  29. ctkCmdLineModuleObjectTreeWalker(QObject* root = 0);
  30. ~ctkCmdLineModuleObjectTreeWalker();
  31. void setRootObject(QObject* root);
  32. void clear();
  33. bool atEnd() const;
  34. bool isParameterGroup() const;
  35. bool isParameter() const;
  36. QString name() const;
  37. QString label() const;
  38. QVariant value() const;
  39. QObject* currentObject() const;
  40. void setValue(const QVariant& value);
  41. QString flag() const;
  42. QString longFlag() const;
  43. int index() const;
  44. bool isMultiple() const;
  45. QVariant property(const QString& propName) const;
  46. TokenType readNext();
  47. bool readNextExecutable();
  48. bool readNextParameterGroup();
  49. bool readNextParameter();
  50. TokenType tokenType() const;
  51. private:
  52. TokenType token(QObject* obj);
  53. bool setCurrent(QObject* obj);
  54. QVariant prefixedProperty(const QString& propName) const;
  55. QObject* RootObject;
  56. QObject* CurrentObject;
  57. TokenType CurrentToken;
  58. bool AtEnd;
  59. QStack<QObject*> ObjectStack;
  60. };
  61. #endif // CTKCMDLINEMODULEOBJECTTREEWALKER_H