From 7c287857f3bd50b806109660d23e2993b7a4b7ad Mon Sep 17 00:00:00 2001 From: Benoit Foucher Date: Wed, 19 Dec 2012 13:08:44 +0100 Subject: ICE-4938: support for compact IDs --- cpp/src/Ice/FactoryTable.cpp | 45 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) (limited to 'cpp/src/Ice/FactoryTable.cpp') 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); + } + } +} + + -- cgit v1.2.3