karbon

karbon_tool_registry.cpp
1/*
2 Copyright (c) 2004 Boudewijn Rempt <boud@valdyas.org>
3 Copyright (c) 2005 Sven Langkamp <longamp@reallygood.de>
4
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details.
14
15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19*/
20
21#include <kdebug.h>
22#include <tdeaction.h>
23#include <tdeactioncollection.h>
24
25#include "vtool.h"
26#include "karbon_part.h"
27#include "karbon_tool_factory.h"
28#include "karbon_tool_registry.h"
29
30KarbonToolRegistry* KarbonToolRegistry::m_singleton = 0;
31
32KarbonToolRegistry::KarbonToolRegistry()
33{
34 kdDebug() << " creating a KarbonToolRegistry" << endl;
35}
36
37KarbonToolRegistry::~KarbonToolRegistry()
38{
39}
40
41KarbonToolRegistry* KarbonToolRegistry::instance()
42{
43 if(KarbonToolRegistry::m_singleton == 0)
44 {
45 KarbonToolRegistry::m_singleton = new KarbonToolRegistry();
46 }
47 return KarbonToolRegistry::m_singleton;
48}
49
50void KarbonToolRegistry::createTools(TDEActionCollection * ac, KarbonView* view)
51{
52 Q_ASSERT(view);
53
54 TQValueVector<KarbonAbstractToolFactory*>::iterator it;
55 for ( it = begin(); it != end(); ++it )
56 (*it) -> createTool(ac, view);
57}
58
59void KarbonToolRegistry::add(KarbonAbstractToolFactory* factory)
60{
61 append(factory);
62}
A registry where new tool plugins can register themselves.