Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
| 2 | /** |
Alexander Afanasyev | dfa52c4 | 2014-04-24 21:10:11 -0700 | [diff] [blame] | 3 | * Copyright (c) 2013-2014, Regents of the University of California. |
| 4 | * All rights reserved. |
| 5 | * |
| 6 | * This file is part of ndn-cxx library (NDN C++ library with eXperimental eXtensions). |
| 7 | * See AUTHORS.md for complete list of ndn-cxx authors and contributors. |
| 8 | * |
| 9 | * This file licensed under New BSD License. See COPYING for detailed information about |
| 10 | * ndn-cxx library copyright, permissions, and redistribution restrictions. |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 11 | */ |
| 12 | |
| 13 | #ifndef NDN_MANAGEMENT_NFD_FACE_FLAGS_HPP |
| 14 | #define NDN_MANAGEMENT_NFD_FACE_FLAGS_HPP |
| 15 | |
| 16 | namespace ndn { |
| 17 | namespace nfd { |
| 18 | |
| 19 | /** \class FaceFlags |
| 20 | * \brief provides additional information about a face |
| 21 | */ |
| 22 | enum { |
| 23 | /** \brief face is local (for scope control purpose) |
| 24 | */ |
| 25 | FACE_IS_LOCAL = 1, |
| 26 | /** \brief face is created on demand (accepted incoming connection, |
| 27 | * not initiated outgoing connection) |
| 28 | */ |
| 29 | FACE_IS_ON_DEMAND = 2 |
| 30 | // FACE_? = 4 |
| 31 | // FACE_? = 8 |
| 32 | }; |
| 33 | |
| 34 | /** \brief implements getters to each face flag |
| 35 | * |
| 36 | * \tparam T class containing a FaceFlags field and implements |
| 37 | * `FaceFlags getFlags() const` method |
| 38 | */ |
| 39 | template<typename T> |
| 40 | class FaceFlagsTraits |
| 41 | { |
| 42 | public: |
| 43 | bool |
| 44 | isLocal() const |
| 45 | { |
| 46 | return static_cast<const T*>(this)->getFlags() & FACE_IS_LOCAL; |
| 47 | } |
| 48 | |
| 49 | bool |
| 50 | isOnDemand() const |
| 51 | { |
| 52 | return static_cast<const T*>(this)->getFlags() & FACE_IS_ON_DEMAND; |
| 53 | } |
| 54 | }; |
| 55 | |
| 56 | } // namespace nfd |
| 57 | } // namespace ndn |
| 58 | |
| 59 | #endif // NDN_MANAGEMENT_NFD_FACE_FLAGS_HPP |