A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Documentation ▼
Manual
Models
Contributing
Wiki
Development ▼
API Docs
Issue Tracker
Merge Requests
API
propagation-cache.h
Go to the documentation of this file.
1
/* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */
2
/*
3
* Copyright (c) 2012 Telum (www.telum.ru)
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: Kirill Andreev <andreev@telum.ru>
19
*/
20
#ifndef PROPAGATION_CACHE_H_
21
#define PROPAGATION_CACHE_H_
22
23
#include "ns3/mobility-model.h"
24
#include <map>
25
26
namespace
ns3
27
{
34
template
<
class
T>
35
class
PropagationCache
36
{
37
public
:
38
PropagationCache
() {};
39
~PropagationCache
() {};
40
48
Ptr<T>
GetPathData
(
Ptr<const MobilityModel>
a,
Ptr<const MobilityModel>
b, uint32_t modelUid)
49
{
50
PropagationPathIdentifier
key =
PropagationPathIdentifier
(a, b, modelUid);
51
typename
PathCache::iterator it =
m_pathCache
.find (key);
52
if
(it ==
m_pathCache
.end ())
53
{
54
return
0;
55
}
56
return
it->second;
57
};
58
66
void
AddPathData
(
Ptr<T>
data
,
Ptr<const MobilityModel>
a,
Ptr<const MobilityModel>
b, uint32_t modelUid)
67
{
68
PropagationPathIdentifier
key =
PropagationPathIdentifier
(a, b, modelUid);
69
NS_ASSERT
(
m_pathCache
.find (key) ==
m_pathCache
.end ());
70
m_pathCache
.insert (std::make_pair (key,
data
));
71
};
72
private
:
74
struct
PropagationPathIdentifier
75
{
82
PropagationPathIdentifier
(
Ptr<const MobilityModel>
a,
Ptr<const MobilityModel>
b, uint32_t modelUid) :
83
m_srcMobility
(a),
m_dstMobility
(b),
m_spectrumModelUid
(modelUid)
84
{};
85
Ptr<const MobilityModel>
m_srcMobility
;
86
Ptr<const MobilityModel>
m_dstMobility
;
87
uint32_t
m_spectrumModelUid
;
88
101
bool
operator <
(
const
PropagationPathIdentifier
& other)
const
102
{
103
if
(
m_spectrumModelUid
!= other.
m_spectrumModelUid
)
104
{
105
return
m_spectrumModelUid
< other.
m_spectrumModelUid
;
106
}
108
if
(
std::min
(
m_dstMobility
,
m_srcMobility
) !=
std::min
(other.
m_dstMobility
, other.
m_srcMobility
))
109
{
110
return
std::min
(
m_dstMobility
,
m_srcMobility
) <
std::min
(other.
m_dstMobility
, other.
m_srcMobility
);
111
}
112
if
(
std::max
(
m_dstMobility
,
m_srcMobility
) !=
std::max
(other.
m_dstMobility
, other.
m_srcMobility
))
113
{
114
return
std::max
(
m_dstMobility
,
m_srcMobility
) <
std::max
(other.
m_dstMobility
, other.
m_srcMobility
);
115
}
116
return
false
;
117
}
118
};
119
121
typedef
std::map<PropagationPathIdentifier, Ptr<T> >
PathCache
;
122
private
:
123
PathCache
m_pathCache
;
124
};
125
}
// namespace ns3
126
127
#endif
// PROPAGATION_CACHE_H_
min
#define min(a, b)
Definition:
80211b.c:42
max
#define max(a, b)
Definition:
80211b.c:43
ns3::PropagationCache
Constructs a cache of objects, where each object is responsible for a single propagation path loss ca...
Definition:
propagation-cache.h:36
ns3::PropagationCache::m_pathCache
PathCache m_pathCache
Path cache.
Definition:
propagation-cache.h:123
ns3::PropagationCache::PropagationCache
PropagationCache()
Definition:
propagation-cache.h:38
ns3::PropagationCache::PathCache
std::map< PropagationPathIdentifier, Ptr< T > > PathCache
Typedef: PropagationPathIdentifier, Ptr<T>
Definition:
propagation-cache.h:121
ns3::PropagationCache::~PropagationCache
~PropagationCache()
Definition:
propagation-cache.h:39
ns3::PropagationCache::AddPathData
void AddPathData(Ptr< T > data, Ptr< const MobilityModel > a, Ptr< const MobilityModel > b, uint32_t modelUid)
Add a model to the path.
Definition:
propagation-cache.h:66
ns3::PropagationCache::GetPathData
Ptr< T > GetPathData(Ptr< const MobilityModel > a, Ptr< const MobilityModel > b, uint32_t modelUid)
Get the model associated with the path.
Definition:
propagation-cache.h:48
ns3::Ptr
Smart pointer class similar to boost::intrusive_ptr.
Definition:
ptr.h:74
NS_ASSERT
#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
ns3
Every class exported by the ns3 library is enclosed in the ns3 namespace.
data
uint8_t data[writeSize]
Definition:
socket-bound-tcp-static-routing.cc:53
ns3::PropagationCache::PropagationPathIdentifier
Each path is identified by.
Definition:
propagation-cache.h:75
ns3::PropagationCache::PropagationPathIdentifier::PropagationPathIdentifier
PropagationPathIdentifier(Ptr< const MobilityModel > a, Ptr< const MobilityModel > b, uint32_t modelUid)
Constructor.
Definition:
propagation-cache.h:82
ns3::PropagationCache::PropagationPathIdentifier::m_srcMobility
Ptr< const MobilityModel > m_srcMobility
1st node mobility model
Definition:
propagation-cache.h:84
ns3::PropagationCache::PropagationPathIdentifier::m_spectrumModelUid
uint32_t m_spectrumModelUid
model UID
Definition:
propagation-cache.h:87
ns3::PropagationCache::PropagationPathIdentifier::m_dstMobility
Ptr< const MobilityModel > m_dstMobility
2nd node mobility model
Definition:
propagation-cache.h:86
ns3::PropagationCache::PropagationPathIdentifier::operator<
bool operator<(const PropagationPathIdentifier &other) const
Less-than operator.
Definition:
propagation-cache.h:101
src
propagation
model
propagation-cache.h
Generated on Tue Feb 6 2024 19:21:26 for ns-3 by
1.9.1