Alexander Afanasyev | a9034b0 | 2014-01-26 18:32:02 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /** |
| 3 | * Copyright (C) 2014 Named Data Networking Project |
| 4 | * See COPYING for copyright and distribution information. |
| 5 | */ |
| 6 | |
| 7 | #ifndef NFD_FACE_CHANNEL_FACTORY_HPP |
| 8 | #define NFD_FACE_CHANNEL_FACTORY_HPP |
| 9 | |
| 10 | #include "common.hpp" |
| 11 | |
Alexander Afanasyev | 18bbf81 | 2014-01-29 01:40:23 -0800 | [diff] [blame] | 12 | namespace nfd { |
Alexander Afanasyev | a9034b0 | 2014-01-26 18:32:02 -0800 | [diff] [blame] | 13 | |
| 14 | /** |
| 15 | * \brief Base class for all channel factories |
| 16 | */ |
| 17 | template<class E, class C> |
| 18 | class ChannelFactory |
| 19 | { |
| 20 | public: |
| 21 | typedef E Endpoint; |
| 22 | typedef C Channel; |
| 23 | |
| 24 | /** |
| 25 | * \brief Base class for all exceptions thrown by channel factories |
| 26 | */ |
| 27 | struct Error : public std::runtime_error |
| 28 | { |
| 29 | Error(const std::string& what) : std::runtime_error(what) {} |
| 30 | }; |
| 31 | |
| 32 | protected: |
Alexander Afanasyev | 8ad71ba | 2014-01-27 00:07:14 -0800 | [diff] [blame] | 33 | typedef std::map< Endpoint, shared_ptr<Channel> > ChannelMap; |
Alexander Afanasyev | a9034b0 | 2014-01-26 18:32:02 -0800 | [diff] [blame] | 34 | ChannelMap m_channels; |
| 35 | }; |
| 36 | |
Alexander Afanasyev | 18bbf81 | 2014-01-29 01:40:23 -0800 | [diff] [blame] | 37 | } // namespace nfd |
Alexander Afanasyev | a9034b0 | 2014-01-26 18:32:02 -0800 | [diff] [blame] | 38 | |
| 39 | #endif // NFD_FACE_CHANNEL_FACTORY_HPP |