summaryrefslogtreecommitdiffstats
path: root/kipi-plugins/sync/sinkfactory.h
blob: e570e785f3d749d7a292236e2d9989a69f714c1a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/* ============================================================
 * File  : sinkfactory.h
 * Author: Colin Guthrie <kde@colin.guthr.ie>
 * Date  : 2007-01-22
 *
 * Copyright 2007 by Colin Guthrie <kde@colin.guthr.ie>
 *
 * This program is free software; you can redistribute it
 * and/or modify it under the terms of the GNU General
 * Public License as published by the Free Software Foundation;
 * either version 2, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 * ============================================================ */

#ifndef SINKFACTORY_H
#define SINKFACTORY_H

#include <tqmap.h>
class TQListView;
class TDEConfig;
namespace KWallet
{
class Wallet;
}


namespace KIPISyncPlugin
{
class Sink;

// Create a templated creator function to allow our "sinks" to
// register themselves with the factory.
template <class T>
Sink* SinkCreator(unsigned int sinkId, TQString name, TDEConfig* pConfig, KWallet::Wallet* pWallet)
{
  return (Sink*) new T(sinkId, name, pConfig, pWallet);
}

// Define a type that is a pointer to the templated function above.
typedef Sink* SinkProxy(unsigned int sinkId, TQString name, TDEConfig* pConfig, KWallet::Wallet* pWallet);

// And define a type that is a Map of names to creator functions.
typedef TQMap<TQString, SinkProxy*> SinkMap;

// The factory to register and create the sinks
class SinkFactory
{
public:
  static bool Register(TQString name, SinkProxy* pSinkProxy);
  static Sink* Create(TQString name, unsigned int sinkId, TQString name, TDEConfig* pConfig, KWallet::Wallet* pWallet);

private:
  static SinkMap mSinkProxies;
};

}

#endif /* SINKFACTORY_H */