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