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 | |
Alexander Afanasyev | 4671bf7 | 2014-05-19 09:01:37 -0400 | [diff] [blame^] | 19 | /** |
| 20 | * \ingroup management |
| 21 | * \enum FaceFlags |
| 22 | * \brief provides additional information about a face |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 23 | */ |
| 24 | enum { |
| 25 | /** \brief face is local (for scope control purpose) |
| 26 | */ |
| 27 | FACE_IS_LOCAL = 1, |
| 28 | /** \brief face is created on demand (accepted incoming connection, |
| 29 | * not initiated outgoing connection) |
| 30 | */ |
| 31 | FACE_IS_ON_DEMAND = 2 |
| 32 | // FACE_? = 4 |
| 33 | // FACE_? = 8 |
| 34 | }; |
| 35 | |
Alexander Afanasyev | 4671bf7 | 2014-05-19 09:01:37 -0400 | [diff] [blame^] | 36 | /** |
| 37 | * \ingroup management |
| 38 | * \brief implements getters to each face flag |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 39 | * |
Alexander Afanasyev | 4671bf7 | 2014-05-19 09:01:37 -0400 | [diff] [blame^] | 40 | * \tparam T class containing a FaceFlags field and implements |
| 41 | * `FaceFlags getFlags() const` method |
Junxiao Shi | 7b1ba1a | 2014-03-29 01:01:56 -0700 | [diff] [blame] | 42 | */ |
| 43 | template<typename T> |
| 44 | class FaceFlagsTraits |
| 45 | { |
| 46 | public: |
| 47 | bool |
| 48 | isLocal() const |
| 49 | { |
| 50 | return static_cast<const T*>(this)->getFlags() & FACE_IS_LOCAL; |
| 51 | } |
| 52 | |
| 53 | bool |
| 54 | isOnDemand() const |
| 55 | { |
| 56 | return static_cast<const T*>(this)->getFlags() & FACE_IS_ON_DEMAND; |
| 57 | } |
| 58 | }; |
| 59 | |
| 60 | } // namespace nfd |
| 61 | } // namespace ndn |
| 62 | |
| 63 | #endif // NDN_MANAGEMENT_NFD_FACE_FLAGS_HPP |