cmCTestGenericHandler.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. #include "cmSystemTools.h" //OutputOption
  15. class cmMakefile;
  16. class cmCTestCommand;
  17. class cmGeneratedFileStream;
  18. /** \class cmCTestGenericHandler
  19. * \brief A superclass of all CTest Handlers
  20. *
  21. */
  22. class cmCTestGenericHandler : public cmObject
  23. {
  24. public:
  25. /**
  26. * If verbose then more informaiton is printed out
  27. */
  28. void SetVerbose(bool val)
  29. { this->HandlerVerbose = val ?
  30. cmSystemTools::OUTPUT_MERGE : cmSystemTools::OUTPUT_NONE; }
  31. /**
  32. * Populate internals from CTest custom scripts
  33. */
  34. virtual void PopulateCustomVectors(cmMakefile *) {}
  35. /**
  36. * Do the actual processing. Subclass has to override it.
  37. * Return < 0 if error.
  38. */
  39. virtual int ProcessHandler() = 0;
  40. /**
  41. * Process command line arguments that are applicable for the handler
  42. */
  43. virtual int ProcessCommandLineArguments(
  44. const std::string& /*currentArg*/, size_t& /*idx*/,
  45. const std::vector<std::string>& /*allArgs*/) { return 1; }
  46. /**
  47. * Initialize handler
  48. */
  49. virtual void Initialize();
  50. /**
  51. * Set the CTest instance
  52. */
  53. void SetCTestInstance(cmCTest* ctest) { this->CTest = ctest; }
  54. cmCTest* GetCTestInstance() { return this->CTest; }
  55. /**
  56. * Construct handler
  57. */
  58. cmCTestGenericHandler();
  59. virtual ~cmCTestGenericHandler();
  60. typedef std::map<std::string,std::string> t_StringToString;
  61. void SetPersistentOption(const std::string& op, const char* value);
  62. void SetOption(const std::string& op, const char* value);
  63. const char* GetOption(const std::string& op);
  64. void SetCommand(cmCTestCommand* command)
  65. {
  66. this->Command = command;
  67. }
  68. void SetSubmitIndex(int idx) { this->SubmitIndex = idx; }
  69. int GetSubmitIndex() { return this->SubmitIndex; }
  70. void SetAppendXML(bool b) { this->AppendXML = b; }
  71. protected:
  72. bool StartResultingXML(cmCTest::Part part,
  73. const char* name, cmGeneratedFileStream& xofs);
  74. bool StartLogFile(const char* name, cmGeneratedFileStream& xofs);
  75. bool AppendXML;
  76. cmSystemTools::OutputOption HandlerVerbose;
  77. cmCTest *CTest;
  78. t_StringToString Options;
  79. t_StringToString PersistentOptions;
  80. cmCTestCommand* Command;
  81. int SubmitIndex;
  82. };
  83. #endif