summaryrefslogtreecommitdiff
path: root/cpp/src/Ice/FactoryTable.cpp
diff options
context:
space:
mode:
authorBenoit Foucher <benoit@zeroc.com>2012-12-19 13:08:44 +0100
committerBenoit Foucher <benoit@zeroc.com>2012-12-19 13:08:44 +0100
commit7c287857f3bd50b806109660d23e2993b7a4b7ad (patch)
treeca0bcebbc06373520b7badd426762b6caa744fe5 /cpp/src/Ice/FactoryTable.cpp
parentICE-5148 - adding more tests (diff)
downloadice-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.cpp45
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);
+ }
+ }
+}
+
+