1 /*============================================================================
2 CMake - Cross Platform Makefile Generator
3 Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
5 Distributed under the OSI-approved BSD License (the "License");
6 see accompanying file Copyright.txt for details.
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 #include "cmVariableWatch.h"
14 static const char* const cmVariableWatchAccessStrings[] =
17 "UNKNOWN_READ_ACCESS",
18 "ALLOWED_UNKNOWN_READ_ACCESS",
24 const char* cmVariableWatch::GetAccessAsString(int access_type)
26 if ( access_type < 0 || access_type >= cmVariableWatch::NO_ACCESS )
30 return cmVariableWatchAccessStrings[access_type];
33 cmVariableWatch::cmVariableWatch()
37 cmVariableWatch::~cmVariableWatch()
41 void cmVariableWatch::AddWatch(const std::string& variable,
42 WatchMethod method, void* client_data /*=0*/)
44 cmVariableWatch::Pair p;
46 p.ClientData = client_data;
47 cmVariableWatch::VectorOfPairs* vp = &this->WatchMap[variable];
48 cmVariableWatch::VectorOfPairs::size_type cc;
49 for ( cc = 0; cc < vp->size(); cc ++ )
51 cmVariableWatch::Pair* pair = &(*vp)[cc];
52 if ( pair->Method == method )
61 void cmVariableWatch::RemoveWatch(const std::string& variable,
64 cmVariableWatch::VectorOfPairs* vp = &this->WatchMap[variable];
65 cmVariableWatch::VectorOfPairs::iterator it;
66 for ( it = vp->begin(); it != vp->end(); ++it )
68 if ( it->Method == method )
76 void cmVariableWatch::VariableAccessed(const std::string& variable,
79 const cmMakefile* mf) const
81 cmVariableWatch::StringToVectorOfPairs::const_iterator mit =
82 this->WatchMap.find(variable);
83 if ( mit != this->WatchMap.end() )
85 const cmVariableWatch::VectorOfPairs* vp = &mit->second;
86 cmVariableWatch::VectorOfPairs::const_iterator it;
87 for ( it = vp->begin(); it != vp->end(); it ++ )
89 it->Method(variable, access_type, it->ClientData,