1
0

cmFunctionBlocker.h 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #ifndef cmFunctionBlocker_h
  4. #define cmFunctionBlocker_h
  5. #include "cmConfigure.h" // IWYU pragma: keep
  6. #include <vector>
  7. #include "cm_string_view.hxx"
  8. #include "cmListFileCache.h"
  9. class cmExecutionStatus;
  10. class cmMakefile;
  11. class cmFunctionBlocker
  12. {
  13. public:
  14. /**
  15. * should a function be blocked
  16. */
  17. bool IsFunctionBlocked(cmListFileFunction const& lff,
  18. cmExecutionStatus& status);
  19. /**
  20. * should this function blocker be removed, useful when one function adds a
  21. * blocker and another must remove it
  22. */
  23. virtual bool ShouldRemove(const cmListFileFunction&, cmMakefile&)
  24. {
  25. return false;
  26. }
  27. virtual ~cmFunctionBlocker() = default;
  28. /** Set/Get the context in which this blocker is created. */
  29. void SetStartingContext(cmListFileContext const& lfc)
  30. {
  31. this->StartingContext = lfc;
  32. }
  33. cmListFileContext const& GetStartingContext() const
  34. {
  35. return this->StartingContext;
  36. }
  37. private:
  38. virtual cm::string_view StartCommandName() const = 0;
  39. virtual cm::string_view EndCommandName() const = 0;
  40. virtual bool Replay(std::vector<cmListFileFunction> const& functions,
  41. cmExecutionStatus& status) = 0;
  42. private:
  43. cmListFileContext StartingContext;
  44. std::vector<cmListFileFunction> Functions;
  45. unsigned int ScopeDepth = 1;
  46. };
  47. #endif