STYLE: Fix typo in GetFilenameLastExtension docs
[cmake.git] / Source / cmVariableWatch.h
blob5fcd78a647585e0fefa844a2da29cd5d8ae08f72
1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmVariableWatch.h,v $
5 Language: C++
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"
22 class cmMakefile;
24 /** \class cmVariableWatch
25 * \brief Helper class for watching of variable accesses.
27 * Calls function when variable is accessed
29 class cmVariableWatch
31 public:
32 typedef void (*WatchMethod)(const std::string& variable, int access_type,
33 void* client_data, const char* newValue, const cmMakefile* mf);
35 cmVariableWatch();
36 ~cmVariableWatch();
38 /**
39 * Add watch to the variable
41 void AddWatch(const std::string& variable, WatchMethod method,
42 void* client_data=0);
43 void RemoveWatch(const std::string& variable, WatchMethod method);
45 /**
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;
51 /**
52 * Different access types.
54 enum
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,
62 NO_ACCESS
65 /**
66 * Return the access as string
68 static const char* GetAccessAsString(int access_type);
70 protected:
71 struct Pair
73 WatchMethod Method;
74 void* ClientData;
75 Pair() : Method(0), ClientData(0) {}
78 typedef std::vector< Pair > VectorOfPairs;
79 typedef std::map<cmStdString, VectorOfPairs > StringToVectorOfPairs;
81 StringToVectorOfPairs WatchMap;
85 #endif