Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Simonstrator
PeerfactSim.KOM
Commits
2f992985
Commit
2f992985
authored
Aug 31, 2017
by
Tobias Meuser
Committed by
Jose Ignacio Monreal Bailey
Aug 20, 2019
Browse files
Changed constructor of DefaultCachingComponent to provide the host
parent
34596f97
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/de/tud/kom/p2psim/impl/vehicular/DefaultCachingComponent.java
View file @
2f992985
...
...
@@ -25,10 +25,21 @@ import java.util.HashMap;
import
java.util.List
;
import
java.util.Map
;
import
de.tudarmstadt.maki.simonstrator.api.Host
;
import
de.tudarmstadt.maki.simonstrator.api.component.network.NetInterface
;
import
de.tudarmstadt.maki.simonstrator.api.component.network.NetworkComponent.NetInterfaceName
;
import
de.tudarmstadt.maki.simonstrator.api.component.transport.ConnectivityListener
;
import
de.tudarmstadt.maki.simonstrator.api.component.vehicular.CachingComponent
;
public
class
DefaultCachingComponent
implements
CachingComponent
{
public
class
DefaultCachingComponent
implements
CachingComponent
,
ConnectivityListener
{
private
Map
<
Class
<?
extends
Object
>,
List
<
Object
>>
_cache
=
new
HashMap
<>();
private
Host
_host
;
public
DefaultCachingComponent
(
Host
pHost
)
{
_host
=
pHost
;
_host
.
getNetworkComponent
().
getByName
(
NetInterfaceName
.
WIFI
).
addConnectivityListener
(
this
);
}
@Override
public
<
T
>
List
<
T
>
getCacheEntries
(
Class
<
T
>
pCacheEntryClass
)
{
...
...
@@ -53,4 +64,30 @@ public class DefaultCachingComponent implements CachingComponent {
_cache
.
get
(
pCacheEntry
.
getClass
()).
add
(
pCacheEntry
);
}
@Override
public
void
initialize
()
{
_cache
.
clear
();
}
@Override
public
void
shutdown
()
{
}
@Override
public
Host
getHost
()
{
return
_host
;
}
@Override
public
void
wentOnline
(
Host
pHost
,
NetInterface
pNetInterface
)
{
_cache
.
clear
();
}
@Override
public
void
wentOffline
(
Host
pHost
,
NetInterface
pNetInterface
)
{
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment