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 | |
Alexander Afanasyev | 0eb7065 | 2014-02-27 18:35:07 -0800 | [diff] [blame] | 7 | #ifndef NFD_FACE_PROTOCOL_FACTORY_HPP |
| 8 | #define NFD_FACE_PROTOCOL_FACTORY_HPP |
Alexander Afanasyev | a9034b0 | 2014-01-26 18:32:02 -0800 | [diff] [blame] | 9 | |
| 10 | #include "common.hpp" |
Alexander Afanasyev | d665530 | 2014-02-28 08:41:28 -0800 | [diff] [blame^] | 11 | #include "core/face-uri.hpp" |
Alexander Afanasyev | a9034b0 | 2014-01-26 18:32:02 -0800 | [diff] [blame] | 12 | |
Alexander Afanasyev | 18bbf81 | 2014-01-29 01:40:23 -0800 | [diff] [blame] | 13 | namespace nfd { |
Alexander Afanasyev | a9034b0 | 2014-01-26 18:32:02 -0800 | [diff] [blame] | 14 | |
Alexander Afanasyev | d665530 | 2014-02-28 08:41:28 -0800 | [diff] [blame^] | 15 | class Face; |
| 16 | |
| 17 | /** |
| 18 | * \brief Prototype for the callback called when face is created |
| 19 | * (as a response to incoming connection or after connection |
| 20 | * is established) |
| 21 | */ |
| 22 | typedef function<void(const shared_ptr<Face>& newFace)> FaceCreatedCallback; |
| 23 | |
| 24 | /** |
| 25 | * \brief Prototype for the callback that is called when face is failed to |
| 26 | * get created |
| 27 | */ |
| 28 | typedef function<void(const std::string& reason)> FaceConnectFailedCallback; |
| 29 | |
| 30 | |
Alexander Afanasyev | 0eb7065 | 2014-02-27 18:35:07 -0800 | [diff] [blame] | 31 | class ProtocolFactory |
Alexander Afanasyev | a9034b0 | 2014-01-26 18:32:02 -0800 | [diff] [blame] | 32 | { |
| 33 | public: |
Alexander Afanasyev | a9034b0 | 2014-01-26 18:32:02 -0800 | [diff] [blame] | 34 | /** |
| 35 | * \brief Base class for all exceptions thrown by channel factories |
| 36 | */ |
| 37 | struct Error : public std::runtime_error |
| 38 | { |
| 39 | Error(const std::string& what) : std::runtime_error(what) {} |
| 40 | }; |
Alexander Afanasyev | d665530 | 2014-02-28 08:41:28 -0800 | [diff] [blame^] | 41 | |
| 42 | /** \brief Try to create Face using the supplied Face URI |
| 43 | * |
| 44 | * This method should automatically choose channel, based on supplied Face URI |
| 45 | * and create face. |
| 46 | * |
| 47 | * \throws Factory::Error if Factory does not support connect operation |
| 48 | */ |
| 49 | virtual void |
| 50 | createFace(const FaceUri& uri, |
| 51 | const FaceCreatedCallback& onCreated, |
| 52 | const FaceConnectFailedCallback& onConnectFailed) = 0; |
Alexander Afanasyev | a9034b0 | 2014-01-26 18:32:02 -0800 | [diff] [blame] | 53 | }; |
| 54 | |
Alexander Afanasyev | 18bbf81 | 2014-01-29 01:40:23 -0800 | [diff] [blame] | 55 | } // namespace nfd |
Alexander Afanasyev | a9034b0 | 2014-01-26 18:32:02 -0800 | [diff] [blame] | 56 | |
Alexander Afanasyev | 0eb7065 | 2014-02-27 18:35:07 -0800 | [diff] [blame] | 57 | #endif // NFD_FACE_PROTOCOL_FACTORY_HPP |