ENH: add submit via cp mode
[cmake.git] / Source / cmVariableWatchCommand.h
blob469249a2adb05aa6a562d315f99f0c60df1b2a3a
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmVariableWatchCommand.h,v $
5 Language: C++
6 Date: $Date: 2008-01-23 15:27:59 $
7 Version: $Revision: 1.4 $
9 Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
10 See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
12 This software is distributed WITHOUT ANY WARRANTY; without even
13 the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
14 PURPOSE. See the above copyright notices for more information.
16 =========================================================================*/
17 #ifndef cmVariableWatchCommand_h
18 #define cmVariableWatchCommand_h
20 #include "cmCommand.h"
22 class cmVariableWatchCommandHandler
24 public:
25 typedef std::vector<std::string> VectorOfCommands;
26 VectorOfCommands Commands;
29 /** \class cmVariableWatchCommand
30 * \brief Watch when the variable changes and invoke command
33 class cmVariableWatchCommand : public cmCommand
35 public:
36 /**
37 * This is a virtual constructor for the command.
39 virtual cmCommand* Clone()
41 return new cmVariableWatchCommand;
44 //! Default constructor
45 cmVariableWatchCommand();
47 /**
48 * This is called when the command is first encountered in
49 * the CMakeLists.txt file.
51 virtual bool InitialPass(std::vector<std::string> const& args,
52 cmExecutionStatus &status);
54 /**
55 * This determines if the command is invoked when in script mode.
57 virtual bool IsScriptable() { return true; }
59 /**
60 * The name of the command as specified in CMakeList.txt.
62 virtual const char* GetName() { return "variable_watch";}
64 /**
65 * Succinct documentation.
67 virtual const char* GetTerseDocumentation()
69 return "Watch the CMake variable for change.";
72 /**
73 * More documentation.
75 virtual const char* GetFullDocumentation()
77 return
78 " variable_watch(<variable name> [<command to execute>])\n"
79 "If the specified variable changes, the message will be printed about "
80 "the variable being changed. If the command is specified, the command "
81 "will be executed. The command will receive the following arguments:"
82 " COMMAND(<variable> <access> <value> <current list file> <stack>)";
85 cmTypeMacro(cmVariableWatchCommand, cmCommand);
87 void VariableAccessed(const std::string& variable, int access_type,
88 const char* newValue, const cmMakefile* mf);
90 protected:
91 std::map<std::string, cmVariableWatchCommandHandler> Handlers;
93 bool InCallback;
97 #endif