From e530f977df7b5f986349c1023fbdca1898cb28df Mon Sep 17 00:00:00 2001 From: David Capello Date: Sun, 13 Nov 2011 18:00:46 -0300 Subject: [PATCH] Remove ASSERTs from ObjectsContainerImpl. The exceptions are good enough and they work correctly for the unittests. --- src/objects_container_impl.cpp | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/src/objects_container_impl.cpp b/src/objects_container_impl.cpp index 48d3f7ebc..b95ac8bb9 100644 --- a/src/objects_container_impl.cpp +++ b/src/objects_container_impl.cpp @@ -50,16 +50,12 @@ ObjectId ObjectsContainerImpl::addObject(void* object) void ObjectsContainerImpl::insertObject(ObjectId id, void* object) { std::map::iterator it1 = m_idToPtr.find(id); - if (it1 != m_idToPtr.end()) { - ASSERT(false && "You've inserted two times the same object"); + if (it1 != m_idToPtr.end()) throw ExistentObjectException(); - } std::map::iterator it2 = m_ptrToId.find(object); - if (it2 != m_ptrToId.end()) { - ASSERT(false && "You've inserted two times the same object"); + if (it2 != m_ptrToId.end()) throw ExistentObjectException(); - } m_idToPtr[id] = object; m_ptrToId[object] = id; @@ -68,17 +64,13 @@ void ObjectsContainerImpl::insertObject(ObjectId id, void* object) void ObjectsContainerImpl::removeObject(ObjectId id) { std::map::iterator it1 = m_idToPtr.find(id); - if (it1 == m_idToPtr.end()) { - ASSERT(false && "You want to remove a non-existent object"); + if (it1 == m_idToPtr.end()) throw ObjectNotFoundException(); - } void* ptr = it1->second; std::map::iterator it2 = m_ptrToId.find(ptr); - if (it2 == m_ptrToId.end()) { - ASSERT(false && "You want to remove a non-existent object"); + if (it2 == m_ptrToId.end()) throw ObjectNotFoundException(); - } m_idToPtr.erase(it1); m_ptrToId.erase(it2); @@ -87,10 +79,8 @@ void ObjectsContainerImpl::removeObject(ObjectId id) void* ObjectsContainerImpl::getObject(ObjectId id) { std::map::iterator it = m_idToPtr.find(id); - if (it == m_idToPtr.end()) { - ASSERT(false && "You want to get information about a non-existent object"); + if (it == m_idToPtr.end()) throw ObjectNotFoundException(); - } return it->second; }