1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmVariableWatch.h,v $
6 Date: $Date: 2007/05/17 21:40:59 $
7 Version: $Revision: 1.10 $
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 cmVariableWatch_h
18 #define cmVariableWatch_h
20 #include "cmStandardIncludes.h"
24 /** \class cmVariableWatch
25 * \brief Helper class for watching of variable accesses.
27 * Calls function when variable is accessed
32 typedef void (*WatchMethod
)(const std::string
& variable
, int access_type
,
33 void* client_data
, const char* newValue
, const cmMakefile
* mf
);
39 * Add watch to the variable
41 void AddWatch(const std::string
& variable
, WatchMethod method
,
43 void RemoveWatch(const std::string
& variable
, WatchMethod method
);
46 * This method is called when variable is accessed
48 void VariableAccessed(const std::string
& variable
, int access_type
,
49 const char* newValue
, const cmMakefile
* mf
) const;
52 * Different access types.
56 VARIABLE_READ_ACCESS
= 0,
57 UNKNOWN_VARIABLE_READ_ACCESS
,
58 UNKNOWN_VARIABLE_DEFINED_ACCESS
,
59 ALLOWED_UNKNOWN_VARIABLE_READ_ACCESS
,
60 VARIABLE_MODIFIED_ACCESS
,
61 VARIABLE_REMOVED_ACCESS
,
66 * Return the access as string
68 static const char* GetAccessAsString(int access_type
);
75 Pair() : Method(0), ClientData(0) {}
78 typedef std::vector
< Pair
> VectorOfPairs
;
79 typedef std::map
<cmStdString
, VectorOfPairs
> StringToVectorOfPairs
;
81 StringToVectorOfPairs WatchMap
;