diff options
author | Benoit Foucher <benoit@zeroc.com> | 2012-12-19 13:08:44 +0100 |
---|---|---|
committer | Benoit Foucher <benoit@zeroc.com> | 2012-12-19 13:08:44 +0100 |
commit | 7c287857f3bd50b806109660d23e2993b7a4b7ad (patch) | |
tree | ca0bcebbc06373520b7badd426762b6caa744fe5 /cpp/src/Ice/FactoryTable.cpp | |
parent | ICE-5148 - adding more tests (diff) | |
download | ice-7c287857f3bd50b806109660d23e2993b7a4b7ad.tar.bz2 ice-7c287857f3bd50b806109660d23e2993b7a4b7ad.tar.xz ice-7c287857f3bd50b806109660d23e2993b7a4b7ad.zip |
ICE-4938: support for compact IDs
Diffstat (limited to 'cpp/src/Ice/FactoryTable.cpp')
-rw-r--r-- | cpp/src/Ice/FactoryTable.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/cpp/src/Ice/FactoryTable.cpp b/cpp/src/Ice/FactoryTable.cpp index 9bfbd6ec127..ab13f99a36f 100644 --- a/cpp/src/Ice/FactoryTable.cpp +++ b/cpp/src/Ice/FactoryTable.cpp @@ -111,3 +111,48 @@ IceInternal::FactoryTable::removeObjectFactory(const std::string& t) } } +// +// Add a factory to the object factory table. +// +void +IceInternal::FactoryTable::addTypeId(int compactId, const std::string& typeId) +{ + IceUtil::Mutex::Lock lock(_m); + assert(!typeId.empty() && compactId >= 0); + TypeIdTable::iterator i = _typeIdTable.find(compactId); + if(i == _typeIdTable.end()) + { + _typeIdTable[compactId] = TypeIdPair(typeId, 1); + } + else + { + i->second.second++; + } +} + +// +// Return the type ID for the given compact ID +// +std::string +IceInternal::FactoryTable::getTypeId(int compactId) const +{ + IceUtil::Mutex::Lock lock(_m); + TypeIdTable::const_iterator i = _typeIdTable.find(compactId); + return i != _typeIdTable.end() ? i->second.first : std::string(); +} + +void +IceInternal::FactoryTable::removeTypeId(int compactId) +{ + IceUtil::Mutex::Lock lock(_m); + TypeIdTable::iterator i = _typeIdTable.find(compactId); + if(i != _typeIdTable.end()) + { + if(--i->second.second == 0) + { + _typeIdTable.erase(i); + } + } +} + + |