A Discrete-Event Network Simulator
API
remote-channel-bundle-manager.cc
Go to the documentation of this file.
1 /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2 /*
3  * Copyright 2013. Lawrence Livermore National Security, LLC.
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: Steven Smith <smith84@llnl.gov>
19  *
20  */
21 
23 
24 #include "remote-channel-bundle.h"
26 
27 #include "ns3/simulator.h"
28 
29 namespace ns3 {
30 
33 
34 Ptr<RemoteChannelBundle>
36 {
37  ns3::RemoteChannelBundleManager::RemoteChannelMap::iterator kv = g_remoteChannelBundles.find (systemId);
38 
39  if ( kv == g_remoteChannelBundles.end ())
40  {
41  return 0;
42  }
43  else
44  {
45  return kv->second;
46  }
47 }
48 
51 {
53  NS_ASSERT (g_remoteChannelBundles.find (systemId) == g_remoteChannelBundles.end ());
54 
55  Ptr<RemoteChannelBundle> remoteChannelBundle = Create<RemoteChannelBundle> (systemId);
56 
57  g_remoteChannelBundles[systemId] = remoteChannelBundle;
58 
59  return remoteChannelBundle;
60 }
61 
62 std::size_t
64 {
65  return g_remoteChannelBundles.size();
66 }
67 
68 void
70 {
72 
73  for ( RemoteChannelMap::const_iterator iter = g_remoteChannelBundles.begin ();
74  iter != g_remoteChannelBundles.end ();
75  ++iter )
76  {
77  Ptr<RemoteChannelBundle> bundle = iter->second;
78  bundle->Send (bundle->GetDelay ());
79 
81  }
82 
83  g_initialized = true;
84 }
85 
86 Time
88 {
90 
92 
93  for (RemoteChannelMap::const_iterator kv = g_remoteChannelBundles.begin ();
94  kv != g_remoteChannelBundles.end ();
95  ++kv)
96  {
97  safeTime = Min (safeTime, kv->second->GetGuaranteeTime ());
98  }
99 
100  return safeTime;
101 }
102 
103 void
105 {
107 
108  g_remoteChannelBundles.clear();
109  g_initialized = false;
110 }
111 
112 } // namespace ns3
std::map< uint32_t, Ptr< RemoteChannelBundle > > RemoteChannelMap
Simulation virtual time values and global simulation resolution.
Definition: nstime.h:102
Smart pointer class similar to boost::intrusive_ptr.
Definition: ptr.h:73
#define NS_ASSERT(condition)
At runtime, in debugging builds, if this condition is not true, the program prints the source file...
Definition: assert.h:67
static NullMessageSimulatorImpl * GetInstance(void)
int64x64_t Min(const int64x64_t &a, const int64x64_t &b)
Minimum.
Definition: int64x64.h:197
static void InitializeNullMessageEvents(void)
Setup initial Null Message events for every RemoteChannelBundle.
static void Destroy(void)
Destroy the singleton.
Every class exported by the ns3 library is enclosed in the ns3 namespace.
static Ptr< RemoteChannelBundle > Find(uint32_t systemId)
static Ptr< RemoteChannelBundle > Add(uint32_t systemId)
Add RemoteChannelBundle from this task to MPI task on other side of the link.
void ScheduleNullMessageEvent(Ptr< RemoteChannelBundle > bundle)
static Time GetMaximumSimulationTime(void)
Get the maximum representable simulation time.
Definition: simulator.cc:315