diff options
Diffstat (limited to 'Source/cmVariableWatch.h')
-rw-r--r-- | Source/cmVariableWatch.h | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/Source/cmVariableWatch.h b/Source/cmVariableWatch.h index 7dd4ac5..790c75a 100644 --- a/Source/cmVariableWatch.h +++ b/Source/cmVariableWatch.h @@ -26,6 +26,7 @@ class cmVariableWatch public: typedef void (*WatchMethod)(const std::string& variable, int access_type, void* client_data, const char* newValue, const cmMakefile* mf); + typedef void (*DeleteData)(void* client_data); cmVariableWatch(); ~cmVariableWatch(); @@ -33,9 +34,10 @@ public: /** * Add watch to the variable */ - void AddWatch(const std::string& variable, WatchMethod method, - void* client_data=0); - void RemoveWatch(const std::string& variable, WatchMethod method); + bool AddWatch(const std::string& variable, WatchMethod method, + void* client_data=0, DeleteData delete_data=0); + void RemoveWatch(const std::string& variable, WatchMethod method, + void* client_data=0); /** * This method is called when variable is accessed @@ -67,10 +69,18 @@ protected: { WatchMethod Method; void* ClientData; - Pair() : Method(0), ClientData(0) {} + DeleteData DeleteDataCall; + Pair() : Method(0), ClientData(0), DeleteDataCall(0) {} + ~Pair() + { + if (this->DeleteDataCall && this->ClientData) + { + this->DeleteDataCall(this->ClientData); + } + } }; - typedef std::vector< Pair > VectorOfPairs; + typedef std::vector< Pair* > VectorOfPairs; typedef std::map<cmStdString, VectorOfPairs > StringToVectorOfPairs; StringToVectorOfPairs WatchMap; |