forked from xcore/tool_axe
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathPeripheralRegistry.cpp
36 lines (30 loc) · 978 Bytes
/
PeripheralRegistry.cpp
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
// Copyright (c) 2011, Richard Osborne, All rights reserved
// This software is freely distributable under a derivative of the
// University of Illinois/NCSA Open Source License posted in
// LICENSE.txt and at <http://github.xcore.com/>
#include "PeripheralRegistry.h"
#include "PeripheralDescriptor.h"
#include <map>
std::map<std::string,PeripheralDescriptor*> peripherals;
void PeripheralRegistry::add(std::auto_ptr<PeripheralDescriptor> p)
{
// TODO fix memory leak.
std::string name = p->getName();
peripherals.insert(std::make_pair(name, p.release()));
}
PeripheralDescriptor *PeripheralRegistry::get(const std::string &name)
{
std::map<std::string,PeripheralDescriptor*>::iterator it =
peripherals.find(name);
if (it == peripherals.end())
return 0;
return it->second;
}
PeripheralRegistry::iterator PeripheralRegistry::begin()
{
return peripherals.begin();
}
PeripheralRegistry::iterator PeripheralRegistry::end()
{
return peripherals.end();
}