25 #ifndef INCLUDED_GraphFactoryRegistration_h_GUID_12D5835A_12E1_4A94_758D_853F0A98C2A5 26 #define INCLUDED_GraphFactoryRegistration_h_GUID_12D5835A_12E1_4A94_758D_853F0A98C2A5 32 #include <boost/noncopyable.hpp> 38 #include <unordered_map> 45 osvr::unique_ptr<GraphOutputInterface>
create(std::ostream &os,
46 std::string
const &type) {
47 return m_factories.at(type)(os);
49 typedef std::function<osvr::unique_ptr<GraphOutputInterface>(
50 std::ostream &os)> GraphFactory;
51 void registerGraphFactory(std::string
const &type, GraphFactory factory) {
52 m_factories[type] = factory;
56 std::unordered_map<std::string, GraphFactory> m_factories;
62 std::string
const &type) {
63 genericFactory.registerGraphFactory(type, [](std::ostream &os) {
64 return osvr::unique_ptr<GraphOutputInterface>(
new T(os));
69 #endif // INCLUDED_GraphFactoryRegistration_h_GUID_12D5835A_12E1_4A94_758D_853F0A98C2A5 Definition: GraphFactoryRegistration.h:59
osvr::unique_ptr< GraphOutputInterface > create(std::ostream &os, std::string const &type)
Factory method.
Definition: GraphFactoryRegistration.h:45
Header to bring unique_ptr into the osvr namespace.
Definition: GraphFactoryRegistration.h:40