karbon

karbon_tool_factory.h
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#ifndef KARBON_TOOL_FACTORY_H_
22#define KARBON_TOOL_FACTORY_H_
23
24#include "tdeactioncollection.h"
25#include "karbon_view.h"
26#include <koffice_export.h>
27#include <vtool.h>
28
29class KARBONBASE_EXPORT KarbonAbstractToolFactory
30{
31public:
32 KarbonAbstractToolFactory();
33 virtual ~KarbonAbstractToolFactory();
34
35 virtual VTool * createTool( TDEActionCollection * ac, KarbonView* view ) = 0;
36};
37
38template<class T> class KarbonToolFactory : public KarbonAbstractToolFactory
39{
40public:
41 KarbonToolFactory() {}
42 virtual ~KarbonToolFactory() {}
43
44 virtual VTool * createTool( TDEActionCollection * ac, KarbonView* view )
45 {
46 VTool * t = new T( view );
47 TQ_CHECK_PTR(t);
48 t -> setup(ac);
49 return t;
50 }
51};
52
53#endif // KARBON_TOOL_FACTORY_H_
54