language/duchain
duchainregister.cpp
00001 /* This file is part of KDevelop 00002 Copyright 2008 David Nolden <david.nolden.kdevelop@art-master.de> 00003 00004 This library is free software; you can redistribute it and/or 00005 modify it under the terms of the GNU Library General Public 00006 License version 2 as published by the Free Software Foundation. 00007 00008 This library is distributed in the hope that it will be useful, 00009 but WITHOUT ANY WARRANTY; without even the implied warranty of 00010 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00011 Library General Public License for more details. 00012 00013 You should have received a copy of the GNU Library General Public License 00014 along with this library; see the file COPYING.LIB. If not, write to 00015 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 00016 Boston, MA 02110-1301, USA. 00017 */ 00018 00019 #include "duchainregister.h" 00020 #include "duchainbase.h" 00021 00022 namespace KDevelop { 00023 DUChainBase* DUChainItemSystem::create(DUChainBaseData* data) const { 00024 if(uint(m_factories.size()) <= data->classId || m_factories[data->classId] == 0) 00025 return 0; 00026 return m_factories[data->classId]->create(data); 00027 } 00028 00029 DUChainBaseData* DUChainItemSystem::cloneData(const DUChainBaseData& data) const { 00030 if(uint(m_factories.size()) <= data.classId || m_factories[data.classId] == 0) { 00031 Q_ASSERT(0); //Or we'll crash later 00032 return 0; 00033 } 00034 return m_factories[data.classId]->cloneData(data); 00035 } 00036 00037 void DUChainItemSystem::callDestructor(DUChainBaseData* data) const { 00038 if(uint(m_factories.size()) <= data->classId || m_factories[data->classId] == 0) 00039 return; 00040 return m_factories[data->classId]->callDestructor(data); 00041 } 00042 00043 void DUChainItemSystem::freeDynamicData(KDevelop::DUChainBaseData* data) const { 00044 if(uint(m_factories.size()) <= data->classId || m_factories[data->classId] == 0) 00045 return; 00046 return m_factories[data->classId]->freeDynamicData(data); 00047 00048 } 00049 00050 uint DUChainItemSystem::dynamicSize(const DUChainBaseData& data) const { 00051 if(uint(m_factories.size()) <= data.classId || m_factories[data.classId] == 0) 00052 return 0; 00053 return m_factories[data.classId]->dynamicSize(data); 00054 } 00055 00056 size_t DUChainItemSystem::dataClassSize(const DUChainBaseData& data) const { 00057 if(uint(m_dataClassSizes.size()) <= data.classId || m_dataClassSizes[data.classId] == 0) 00058 return 0; 00059 return m_dataClassSizes[data.classId]; 00060 } 00061 00062 00063 void DUChainItemSystem::copy(const DUChainBaseData& from, DUChainBaseData& to, bool constant) const { 00064 if(uint(m_factories.size()) <= from.classId || m_factories[from.classId] == 0) { 00065 Q_ASSERT(0); //Shouldn't try to copy an unknown type 00066 return; 00067 } 00068 return m_factories[from.classId]->copy(from, to, constant); 00069 } 00070 00071 DUChainItemSystem& DUChainItemSystem::self() { 00072 static DUChainItemSystem system; 00073 return system; 00074 } 00075 }
KDE 4.4 API Reference