cmCTestGenericHandler.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc.
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #ifndef cmCTestGenericHandler_h
  11. #define cmCTestGenericHandler_h
  12. #include "cmObject.h"
  13. #include "cmCTest.h"
  14. class cmMakefile;
  15. class cmCTestCommand;
  16. class cmGeneratedFileStream;
  17. /** \class cmCTestGenericHandler
  18. * \brief A superclass of all CTest Handlers
  19. *
  20. */
  21. class cmCTestGenericHandler : public cmObject
  22. {
  23. public:
  24. /**
  25. * If verbose then more informaiton is printed out
  26. */
  27. void SetVerbose(bool val) { this->HandlerVerbose = val; }
  28. /**
  29. * Populate internals from CTest custom scripts
  30. */
  31. virtual void PopulateCustomVectors(cmMakefile *) {}
  32. /**
  33. * Do the actual processing. Subclass has to override it.
  34. * Return < 0 if error.
  35. */
  36. virtual int ProcessHandler() = 0;
  37. /**
  38. * Process command line arguments that are applicable for the handler
  39. */
  40. virtual int ProcessCommandLineArguments(
  41. const std::string& /*currentArg*/, size_t& /*idx*/,
  42. const std::vector<std::string>& /*allArgs*/) { return 1; }
  43. /**
  44. * Initialize handler
  45. */
  46. virtual void Initialize();
  47. /**
  48. * Set the CTest instance
  49. */
  50. void SetCTestInstance(cmCTest* ctest) { this->CTest = ctest; }
  51. cmCTest* GetCTestInstance() { return this->CTest; }
  52. /**
  53. * Construct handler
  54. */
  55. cmCTestGenericHandler();
  56. virtual ~cmCTestGenericHandler();
  57. typedef std::map<cmStdString,cmStdString> t_StringToString;
  58. void SetPersistentOption(const char* op, const char* value);
  59. void SetOption(const char* op, const char* value);
  60. const char* GetOption(const char* op);
  61. void SetCommand(cmCTestCommand* command)
  62. {
  63. this->Command = command;
  64. }
  65. void SetSubmitIndex(int idx) { this->SubmitIndex = idx; }
  66. int GetSubmitIndex() { return this->SubmitIndex; }
  67. void SetAppendXML(bool b) { this->AppendXML = b; }
  68. protected:
  69. bool StartResultingXML(cmCTest::Part part,
  70. const char* name, cmGeneratedFileStream& xofs);
  71. bool StartLogFile(const char* name, cmGeneratedFileStream& xofs);
  72. bool AppendXML;
  73. bool HandlerVerbose;
  74. cmCTest *CTest;
  75. t_StringToString Options;
  76. t_StringToString PersistentOptions;
  77. cmCTestCommand* Command;
  78. int SubmitIndex;
  79. };
  80. #endif