diff options
author | Brad King <brad.king@kitware.com> | 2001-05-16 13:19:46 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2001-05-16 13:19:46 (GMT) |
commit | a5480276d5782f2bcc8d44cf4c5cbf29b980a1f0 (patch) | |
tree | 964433a727426aedff6e7e50bce08fbd5a8235f2 /Source/cmMakefile.cxx | |
parent | a12448c19ba732eaf9b5b2907bf25318f9f97ce8 (diff) | |
download | CMake-a5480276d5782f2bcc8d44cf4c5cbf29b980a1f0.zip CMake-a5480276d5782f2bcc8d44cf4c5cbf29b980a1f0.tar.gz CMake-a5480276d5782f2bcc8d44cf4c5cbf29b980a1f0.tar.bz2 |
ENH: Added cmData and corresponding DataMap in cmMakefile to allow commands to register arbitrary extra data with the makefile without modifying the cmMakefile class definition.
Diffstat (limited to 'Source/cmMakefile.cxx')
-rw-r--r-- | Source/cmMakefile.cxx | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index f415147..cf219bd 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -98,6 +98,14 @@ cmMakefile::~cmMakefile() { delete (*j).second; } + for(DataMap::const_iterator d = m_DataMap.begin(); + d != m_DataMap.end(); ++d) + { + if(d->second) + { + delete d->second; + } + } delete m_MakefileGenerator; } @@ -863,3 +871,52 @@ void cmMakefile::SetHomeOutputDirectory(const char* lib) this->ReadListFile(NULL,fpath.c_str()); #endif } + + +/** + * Register the given cmData instance with its own name. + */ +void cmMakefile::RegisterData(cmData* data) +{ + std::string name = data->GetName(); + DataMap::const_iterator d = m_DataMap.find(name); + if((d != m_DataMap.end()) && (d->second != NULL) && (d->second != data)) + { + delete d->second; + } + m_DataMap[name] = data; +} + + +/** + * Register the given cmData instance with the given name. This can be used + * to register a NULL pointer. + */ +void cmMakefile::RegisterData(const char* name, cmData* data) +{ + DataMap::const_iterator d = m_DataMap.find(name); + if((d != m_DataMap.end()) && (d->second != NULL) && (d->second != data)) + { + delete d->second; + } + m_DataMap[name] = data; +} + + +/** + * Lookup a cmData instance previously registered with the given name. If + * the instance cannot be found, return NULL. + */ +cmData* cmMakefile::LookupData(const char* name) const +{ + DataMap::const_iterator d = m_DataMap.find(name); + if(d != m_DataMap.end()) + { + return d->second; + } + else + { + return NULL; + } +} + |