Alexander Afanasyev | efe3ab2 | 2014-02-19 14:57:50 -0800 | [diff] [blame^] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /** |
| 3 | * Copyright (C) 2014 Regents of the University of California. |
| 4 | * See COPYING for copyright and distribution information. |
| 5 | */ |
| 6 | |
| 7 | #ifndef NDN_MANAGEMENT_NFD_CONTROLLER_HPP |
| 8 | #define NDN_MANAGEMENT_NFD_CONTROLLER_HPP |
| 9 | |
| 10 | #include "controller.hpp" |
| 11 | #include "../security/key-chain.hpp" |
| 12 | |
| 13 | namespace ndn { |
| 14 | namespace nrd { |
| 15 | |
| 16 | class PrefixRegOptions; |
| 17 | |
| 18 | class Controller : public ndn::Controller |
| 19 | { |
| 20 | public: |
| 21 | typedef function<void(const PrefixRegOptions&)> CommandSucceedCallback; |
| 22 | |
| 23 | /** |
| 24 | * @brief Construct ndnd::Control object |
| 25 | */ |
| 26 | Controller(Face& face); |
| 27 | |
| 28 | virtual void |
| 29 | selfRegisterPrefix(const Name& prefixToRegister, |
| 30 | const SuccessCallback& onSuccess, |
| 31 | const FailCallback& onFail); |
| 32 | |
| 33 | virtual void |
| 34 | selfDeregisterPrefix(const Name& prefixToRegister, |
| 35 | const SuccessCallback& onSuccess, |
| 36 | const FailCallback& onFail); |
| 37 | |
| 38 | protected: |
| 39 | void |
| 40 | startCommand(const std::string& command, |
| 41 | const PrefixRegOptions& options, |
| 42 | const CommandSucceedCallback& onSuccess, |
| 43 | const FailCallback& onFailure); |
| 44 | |
| 45 | private: |
| 46 | void |
| 47 | recordSelfRegisteredFaceId(const PrefixRegOptions& entry, |
| 48 | const SuccessCallback& onSuccess); |
| 49 | |
| 50 | void |
| 51 | processCommandResponse(Data& data, |
| 52 | const CommandSucceedCallback& onSuccess, |
| 53 | const FailCallback& onFail); |
| 54 | |
| 55 | protected: |
| 56 | Face& m_face; |
| 57 | KeyChain m_keyChain; |
| 58 | uint64_t m_faceId; // internal face ID (needed for prefix de-registration) |
| 59 | }; |
| 60 | |
| 61 | } // namespace nrd |
| 62 | } // namespace ndn |
| 63 | |
| 64 | #endif // NDN_MANAGEMENT_NFD_CONTROLLER_HPP |