Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil -*- */ |
Alexander Afanasyev | 3a6ea5c | 2011-08-11 18:15:49 -0700 | [diff] [blame] | 2 | /* |
| 3 | * Copyright (c) 2011 University of California, Los Angeles |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License version 2 as |
| 7 | * published by the Free Software Foundation; |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 | * |
| 18 | * Author: Ilya Moiseenko <iliamo@cs.ucla.edu> |
| 19 | */ |
| 20 | |
| 21 | #ifndef _NDN_NAME_COMPONENTS_H_ |
| 22 | #define _NDN_NAME_COMPONENTS_H_ |
| 23 | |
Alexander Afanasyev | 2536e20 | 2011-08-12 14:13:10 -0700 | [diff] [blame] | 24 | #include "ns3/simple-ref-count.h" |
| 25 | |
Alexander Afanasyev | 3a6ea5c | 2011-08-11 18:15:49 -0700 | [diff] [blame] | 26 | #include <string> |
| 27 | #include <list> |
| 28 | |
Alexander Afanasyev | 3a6ea5c | 2011-08-11 18:15:49 -0700 | [diff] [blame] | 29 | namespace ns3 { |
Alexander Afanasyev | 3a6ea5c | 2011-08-11 18:15:49 -0700 | [diff] [blame] | 30 | namespace Name { |
| 31 | |
| 32 | class Components : public SimpleRefCount<Components> |
| 33 | { |
| 34 | public: |
| 35 | Components (); |
| 36 | Components (const std::string &s); |
| 37 | ~Components (); |
| 38 | |
Alexander Afanasyev | 834f35c | 2011-08-16 17:13:50 -0700 | [diff] [blame] | 39 | inline void |
| 40 | Add (const std::string &s); |
| 41 | |
| 42 | Components& |
| 43 | operator () (const std::string &s); |
Alexander Afanasyev | 2a5df20 | 2011-08-15 22:39:05 -0700 | [diff] [blame] | 44 | |
| 45 | const std::list<std::string> & |
| 46 | GetComponents () const; |
Alexander Afanasyev | 3a6ea5c | 2011-08-11 18:15:49 -0700 | [diff] [blame] | 47 | |
| 48 | // virtual uint32_t |
| 49 | // GetSerializedSize (void) const; |
| 50 | |
| 51 | // virtual void |
| 52 | // Serialize (Buffer::Iterator start) const; |
| 53 | |
| 54 | // virtual uint32_t |
| 55 | // Deserialize (Buffer::Iterator start); |
| 56 | |
| 57 | void Print (std::ostream &os) const; |
Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 58 | |
| 59 | inline size_t |
| 60 | size () const; |
Alexander Afanasyev | 3a6ea5c | 2011-08-11 18:15:49 -0700 | [diff] [blame] | 61 | |
| 62 | private: |
| 63 | std::list<std::string> m_prefix; |
| 64 | |
| 65 | typedef std::list<std::string>::iterator iterator; |
| 66 | typedef std::list<std::string>::const_iterator const_iterator; |
| 67 | }; |
| 68 | |
| 69 | std::ostream & operator << (std::ostream &os, const Components &components); |
| 70 | |
Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 71 | size_t |
| 72 | Components::size () const |
| 73 | { |
| 74 | return m_prefix.size (); |
| 75 | } |
| 76 | |
Alexander Afanasyev | 834f35c | 2011-08-16 17:13:50 -0700 | [diff] [blame] | 77 | void |
| 78 | Components::Add (const std::string &s) |
| 79 | { |
| 80 | (*this) (s); |
| 81 | } |
| 82 | |
Alexander Afanasyev | c74a602 | 2011-08-15 20:01:35 -0700 | [diff] [blame] | 83 | |
Alexander Afanasyev | 3a6ea5c | 2011-08-11 18:15:49 -0700 | [diff] [blame] | 84 | } // Namespace Name |
Alexander Afanasyev | 3a6ea5c | 2011-08-11 18:15:49 -0700 | [diff] [blame] | 85 | } // namespace ns3 |
| 86 | |
| 87 | #endif // _NDN_NAME_COMPONENTS_H_ |
| 88 | |