blob: 2a50ce1c8606af0077c61eb74520478d043d3972 (
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
|
/**
* @file iofactory.cc
* @brief Implementation of the IOFactory class.
* @author Andreas Aardal Hanssen
* @date 2002, 2003
*/
#include "iofactory.h"
using namespace Binc;
IOFactory &IOFactory::getInstance()
{
static IOFactory ioFactory;
return ioFactory;
}
void IOFactory::addDevice(std::unique_ptr<IODevice> dev)
{
IOFactory::getInstance().devices[dev->service()] = std::move(dev);
}
IODevice &IOFactory::getClient()
{
static IODevice nulDevice;
IOFactory &ioFactory = IOFactory::getInstance();
if (ioFactory.devices.find("client") != ioFactory.devices.end())
return *ioFactory.devices["client"];
return nulDevice;
}
IODevice &IOFactory::getLogger()
{
static IODevice nulDevice;
IOFactory &ioFactory = IOFactory::getInstance();
if (ioFactory.devices.find("log") != ioFactory.devices.end())
return *ioFactory.devices["log"];
return nulDevice;
}
|