1 /* This file is part of KDevelop
2 Copyright 2008 David Nolden <david.nolden.kdevelop@art-master.de>
4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public
6 License version 2 as published by the Free Software Foundation.
8 This library is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 Library General Public License for more details.
13 You should have received a copy of the GNU Library General Public License
14 along with this library; see the file COPYING.LIB. If not, write to
15 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16 Boston, MA 02110-1301, USA.
19 #include "duchainregister.h"
20 #include "duchainbase.h"
23 DUChainBase
* DUChainItemSystem::create(DUChainBaseData
* data
) const {
24 if(uint(m_factories
.size()) <= data
->classId
|| m_factories
[data
->classId
] == 0)
26 return m_factories
[data
->classId
]->create(data
);
29 DUChainBaseData
* DUChainItemSystem::cloneData(const DUChainBaseData
& data
) const {
30 if(uint(m_factories
.size()) <= data
.classId
|| m_factories
[data
.classId
] == 0) {
31 Q_ASSERT(0); //Or we'll crash later
34 return m_factories
[data
.classId
]->cloneData(data
);
37 void DUChainItemSystem::callDestructor(DUChainBaseData
* data
) const {
38 if(uint(m_factories
.size()) <= data
->classId
|| m_factories
[data
->classId
] == 0)
40 return m_factories
[data
->classId
]->callDestructor(data
);
43 uint
DUChainItemSystem::dynamicSize(const DUChainBaseData
& data
) const {
44 if(uint(m_factories
.size()) <= data
.classId
|| m_factories
[data
.classId
] == 0)
46 return m_factories
[data
.classId
]->dynamicSize(data
);
49 size_t DUChainItemSystem::dataClassSize(const DUChainBaseData
& data
) const {
50 if(uint(m_dataClassSizes
.size()) <= data
.classId
|| m_dataClassSizes
[data
.classId
] == 0)
52 return m_dataClassSizes
[data
.classId
];
56 void DUChainItemSystem::copy(const DUChainBaseData
& from
, DUChainBaseData
& to
, bool constant
) const {
57 if(uint(m_factories
.size()) <= from
.classId
|| m_factories
[from
.classId
] == 0) {
58 Q_ASSERT(0); //Shouldn't try to copy an unknown type
61 return m_factories
[from
.classId
]->copy(from
, to
, constant
);
64 DUChainItemSystem
& DUChainItemSystem::self() {
65 static DUChainItemSystem system
;