|
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 "trace-resolver.h" |
|
22 #include "ns3/debug.h" |
|
23 |
|
24 NS_DEBUG_COMPONENT_DEFINE ("TraceResolver"); |
|
25 |
|
26 namespace ns3 { |
|
27 |
|
28 TraceResolver::TraceResolver () |
|
29 : m_count (1) |
|
30 {} |
|
31 |
|
32 TraceResolver::~TraceResolver () |
|
33 {} |
|
34 |
|
35 void |
|
36 TraceResolver::Ref (void) |
|
37 { |
|
38 m_count++; |
|
39 } |
|
40 void |
|
41 TraceResolver::Unref (void) |
|
42 { |
|
43 m_count--; |
|
44 if (m_count == 0) |
|
45 { |
|
46 NS_DEBUG ("delete "<<this); |
|
47 delete this; |
|
48 } |
|
49 } |
|
50 |
|
51 |
|
52 void |
|
53 TraceResolver::Connect (std::string path, CallbackBase const &cb, const TraceContext &context) |
|
54 {} |
|
55 |
|
56 void |
|
57 TraceResolver::Disconnect (std::string path, CallbackBase const &cb) |
|
58 {} |
|
59 |
|
60 std::string |
|
61 TraceResolver::GetElement (std::string path) |
|
62 { |
|
63 std::string::size_type cur = 1; |
|
64 // check that first char is "/" |
|
65 std::string::size_type next = path.find ("/", cur); |
|
66 std::string id = std::string (path, cur, next-1); |
|
67 return id; |
|
68 } |
|
69 std::string |
|
70 TraceResolver::GetSubpath (std::string path) |
|
71 { |
|
72 std::string::size_type cur = 1; |
|
73 // check that first char is "/" |
|
74 std::string::size_type next = path.find ("/", cur); |
|
75 std::string subpath; |
|
76 if (next != std::string::npos) |
|
77 { |
|
78 subpath = std::string (path, next, std::string::npos); |
|
79 } |
|
80 else |
|
81 { |
|
82 subpath = ""; |
|
83 } |
|
84 return subpath; |
|
85 } |
|
86 |
|
87 }//namespace ns3 |