Imported Upstream version 2.8.12.2
[platform/upstream/cmake.git] / Source / cmVariableWatchCommand.h
1 /*============================================================================
2   CMake - Cross Platform Makefile Generator
3   Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
4
5   Distributed under the OSI-approved BSD License (the "License");
6   see accompanying file Copyright.txt for details.
7
8   This software is distributed WITHOUT ANY WARRANTY; without even the
9   implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10   See the License for more information.
11 ============================================================================*/
12 #ifndef cmVariableWatchCommand_h
13 #define cmVariableWatchCommand_h
14
15 #include "cmCommand.h"
16
17 /** \class cmVariableWatchCommand
18  * \brief Watch when the variable changes and invoke command
19  *
20  */
21 class cmVariableWatchCommand : public cmCommand
22 {
23 public:
24   /**
25    * This is a virtual constructor for the command.
26    */
27   virtual cmCommand* Clone()
28     {
29     return new cmVariableWatchCommand;
30     }
31
32   //! Default constructor
33   cmVariableWatchCommand();
34
35   //! Destructor.
36   ~cmVariableWatchCommand();
37
38   /**
39    * This is called when the command is first encountered in
40    * the CMakeLists.txt file.
41    */
42   virtual bool InitialPass(std::vector<std::string> const& args,
43                            cmExecutionStatus &status);
44
45   /**
46    * This determines if the command is invoked when in script mode.
47    */
48   virtual bool IsScriptable() const { return true; }
49
50   /** This command does not really have a final pass but it needs to
51       stay alive since it owns variable watch callback information. */
52   virtual bool HasFinalPass() const { return true; }
53
54   /**
55    * The name of the command as specified in CMakeList.txt.
56    */
57   virtual const char* GetName() const { return "variable_watch";}
58
59   /**
60    * Succinct documentation.
61    */
62   virtual const char* GetTerseDocumentation() const
63     {
64     return "Watch the CMake variable for change.";
65     }
66
67   /**
68    * More documentation.
69    */
70   virtual const char* GetFullDocumentation() const
71     {
72     return
73       "  variable_watch(<variable name> [<command to execute>])\n"
74       "If the specified variable changes, the message will be printed about "
75       "the variable being changed. If the command is specified, the command "
76       "will be executed. The command will receive the following arguments:"
77       " COMMAND(<variable> <access> <value> <current list file> <stack>)";
78     }
79
80   cmTypeMacro(cmVariableWatchCommand, cmCommand);
81
82 protected:
83   std::set<std::string> WatchedVariables;
84 };
85
86
87 #endif
88
89