protocol-factory.cpp
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
26 #include "protocol-factory.hpp"
27 #include <boost/range/adaptor/map.hpp>
28 #include <boost/range/algorithm/copy.hpp>
29 
30 namespace nfd {
31 namespace face {
32 
33 ProtocolFactory::Registry&
34 ProtocolFactory::getRegistry()
35 {
36  static Registry registry;
37  return registry;
38 }
39 
40 unique_ptr<ProtocolFactory>
41 ProtocolFactory::create(const std::string& id)
42 {
43  Registry& registry = getRegistry();
44  auto found = registry.find(id);
45  return found == registry.end() ? nullptr : found->second();
46 }
47 
48 std::set<std::string>
50 {
51  std::set<std::string> factoryIds;
52  boost::copy(getRegistry() | boost::adaptors::map_keys,
53  std::inserter(factoryIds, factoryIds.end()));
54  return factoryIds;
55 }
56 
57 } // namespace face
58 } // namespace nfd
static std::set< std::string > listRegistered()
Copyright (c) 2014-2015, Regents of the University of California, Arizona Board of Regents...
static unique_ptr< ProtocolFactory > create(const std::string &id)