Bincimap 2.0.16
Easy Imapping
Loading...
Searching...
No Matches
iofactory.cc
Go to the documentation of this file.
1/* --------------------------------------------------------------------
2 * @file iofactory.cc
3 * @brief Implementation of the IOFactory class.
4 * @author Andreas Aardal Hanssen
5 * @date 2002, 2003
6 * ----------------------------------------------------------------- **/
7#include "iofactory.h"
8#include "iodevice.h"
9
10using namespace ::Binc;
11using namespace ::std;
12
13//------------------------------------------------------------------------
14IOFactory::IOFactory(void)
15{
16}
17
18//------------------------------------------------------------------------
19IOFactory::~IOFactory(void)
20{
21}
22
23//------------------------------------------------------------------------
24IOFactory &IOFactory::getInstance(void)
25{
26 static IOFactory ioFactory;
27 return ioFactory;
28}
29
30//------------------------------------------------------------------------
31void IOFactory::addDevice(IODevice *dev)
32{
33 IODevice *ioDevice = IOFactory::getInstance().devices[dev->service()];
34
35 // FIXME: Delete correct object. Now, only IODevice's destructor is
36 // called, and only IODevice's memory is freed.
37 if (ioDevice)
38 delete ioDevice;
39
40 IOFactory::getInstance().devices[dev->service()] = dev;
41}
42
43//------------------------------------------------------------------------
44IODevice &IOFactory::getClient(void)
45{
46 static IODevice nulDevice;
47
48 IOFactory &ioFactory = IOFactory::getInstance();
49
50 if (ioFactory.devices.find("client") != ioFactory.devices.end())
51 return *ioFactory.devices["client"];
52
53 return nulDevice;
54}
55
56//------------------------------------------------------------------------
57IODevice &IOFactory::getLogger(void)
58{
59 static IODevice nulDevice;
60
61 IOFactory &ioFactory = IOFactory::getInstance();
62
63 if (ioFactory.devices.find("log") != ioFactory.devices.end())
64 return *ioFactory.devices["log"];
65 return nulDevice;
66}
The IODevice class provides a framework for reading and writing to device.
Definition: iodevice.h:31
virtual std::string service(void) const
Definition: iodevice.cc:220
Declaration of the IODevice class.
Declaration of the IOFactory class.
Definition: bincimapd.cc:9