1 /*=========================================================================
3 Program: CMake - Cross-Platform Makefile Generator
4 Module: $RCSfile: cmVariableWatch.cxx,v $
6 Date: $Date: 2007-04-11 19:13:05 $
7 Version: $Revision: 1.5 $
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 #include "cmVariableWatch.h"
19 static const char* const cmVariableWatchAccessStrings
[] =
22 "UNKNOWN_READ_ACCESS",
23 "ALLOWED_UNKNOWN_READ_ACCESS",
29 const char* cmVariableWatch::GetAccessAsString(int access_type
)
31 if ( access_type
< 0 || access_type
>= cmVariableWatch::NO_ACCESS
)
35 return cmVariableWatchAccessStrings
[access_type
];
38 cmVariableWatch::cmVariableWatch()
42 cmVariableWatch::~cmVariableWatch()
46 void cmVariableWatch::AddWatch(const std::string
& variable
,
47 WatchMethod method
, void* client_data
/*=0*/)
49 cmVariableWatch::Pair p
;
51 p
.ClientData
= client_data
;
52 cmVariableWatch::VectorOfPairs
* vp
= &this->WatchMap
[variable
];
53 cmVariableWatch::VectorOfPairs::size_type cc
;
54 for ( cc
= 0; cc
< vp
->size(); cc
++ )
56 cmVariableWatch::Pair
* pair
= &(*vp
)[cc
];
57 if ( pair
->Method
== method
)
66 void cmVariableWatch::RemoveWatch(const std::string
& variable
,
69 cmVariableWatch::VectorOfPairs
* vp
= &this->WatchMap
[variable
];
70 cmVariableWatch::VectorOfPairs::iterator it
;
71 for ( it
= vp
->begin(); it
!= vp
->end(); ++it
)
73 if ( it
->Method
== method
)
81 void cmVariableWatch::VariableAccessed(const std::string
& variable
,
84 const cmMakefile
* mf
) const
86 cmVariableWatch::StringToVectorOfPairs::const_iterator mit
=
87 this->WatchMap
.find(variable
);
88 if ( mit
!= this->WatchMap
.end() )
90 const cmVariableWatch::VectorOfPairs
* vp
= &mit
->second
;
91 cmVariableWatch::VectorOfPairs::const_iterator it
;
92 for ( it
= vp
->begin(); it
!= vp
->end(); it
++ )
94 it
->Method(variable
, access_type
, it
->ClientData
,