|
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
|
2 /* |
|
3 * Copyright (c) 2007 INRIA |
|
4 * All rights reserved. |
|
5 * |
|
6 * This program is free software; you can redistribute it and/or modify |
|
7 * it under the terms of the GNU General Public License version 2 as |
|
8 * published by the Free Software Foundation; |
|
9 * |
|
10 * This program is distributed in the hope that it will be useful, |
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
13 * GNU General Public License for more details. |
|
14 * |
|
15 * You should have received a copy of the GNU General Public License |
|
16 * along with this program; if not, write to the Free Software |
|
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
18 * |
|
19 * Author: Mathieu Lacage <mathieu.lacage@sophia.inria.fr> |
|
20 */ |
|
21 #include "iid-manager.h" |
|
22 #include "ns3/fatal-error.h" |
|
23 #include <vector> |
|
24 |
|
25 namespace ns3 { |
|
26 |
|
27 class IidManagerPriv |
|
28 { |
|
29 public: |
|
30 uint32_t Allocate (std::string name); |
|
31 private: |
|
32 typedef std::vector<std::string> NameList; |
|
33 NameList m_nameList; |
|
34 }; |
|
35 |
|
36 uint32_t |
|
37 IidManagerPriv::Allocate (std::string name) |
|
38 { |
|
39 for (NameList::iterator i = m_nameList.begin (); i != m_nameList.end (); i++) |
|
40 { |
|
41 if ((*i) == name) |
|
42 { |
|
43 NS_FATAL_ERROR ("Trying to allocate twice the same iid: " << name); |
|
44 } |
|
45 } |
|
46 m_nameList.push_back (name); |
|
47 return m_nameList.size (); |
|
48 } |
|
49 |
|
50 uint32_t |
|
51 IidManager::Allocate (std::string name) |
|
52 { |
|
53 static IidManagerPriv priv; |
|
54 return priv.Allocate (name); |
|
55 } |
|
56 |
|
57 } // namespace ns3 |