A Discrete-Event Network Simulator
Home
Tutorials ▼
English
Portuguese
Docs ▼
Wiki
Manual
Models
Develop ▼
API
Bugs
API
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
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
Ptr<T>
GetPathData
(
Ptr<const MobilityModel>
a,
Ptr<const MobilityModel>
b, uint32_t modelUid)
41
{
42
PropagationPathIdentifier key = PropagationPathIdentifier (a, b, modelUid);
43
typename
PathCache::iterator it =
m_pathCache
.find (key);
44
if
(it ==
m_pathCache
.end ())
45
{
46
return
0;
47
}
48
return
it->second;
49
};
50
void
AddPathData
(
Ptr<T>
data
,
Ptr<const MobilityModel>
a,
Ptr<const MobilityModel>
b, uint32_t modelUid)
51
{
52
PropagationPathIdentifier key = PropagationPathIdentifier (a, b, modelUid);
53
NS_ASSERT
(
m_pathCache
.find (key) ==
m_pathCache
.end ());
54
m_pathCache
.insert (std::make_pair (key, data));
55
};
56
private
:
58
struct
PropagationPathIdentifier
59
{
60
PropagationPathIdentifier
(
Ptr<const MobilityModel>
a,
Ptr<const MobilityModel>
b, uint32_t modelUid) :
61
m_srcMobility
(a),
m_dstMobility
(b),
m_spectrumModelUid
(modelUid)
62
{};
63
Ptr<const MobilityModel>
m_srcMobility
;
64
Ptr<const MobilityModel>
m_dstMobility
;
65
uint32_t
m_spectrumModelUid
;
66
bool
operator <
(
const
PropagationPathIdentifier
& other)
const
67
{
68
if
(
m_spectrumModelUid
!= other.
m_spectrumModelUid
)
69
{
70
return
m_spectrumModelUid
< other.
m_spectrumModelUid
;
71
}
73
if
(std::min (
m_dstMobility
,
m_srcMobility
) != std::min (other.
m_dstMobility
, other.
m_srcMobility
))
74
{
75
return
std::min (
m_dstMobility
,
m_srcMobility
) < std::min (other.
m_dstMobility
, other.
m_srcMobility
);
76
}
77
if
(std::max (
m_dstMobility
,
m_srcMobility
) != std::max (other.
m_dstMobility
, other.
m_srcMobility
))
78
{
79
return
std::max (
m_dstMobility
,
m_srcMobility
) < std::max (other.
m_dstMobility
, other.
m_srcMobility
);
80
}
81
return
false
;
82
}
83
};
84
typedef
std::map<PropagationPathIdentifier, Ptr<T> >
PathCache
;
85
private
:
86
PathCache
m_pathCache
;
87
};
88
}
// namespace ns3
89
90
#endif // PROPAGATION_CACHE_H_
src
propagation
model
propagation-cache.h
Generated on Fri Dec 21 2012 19:00:45 for ns-3 by
1.8.1.2