Added applyToNodes().

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@4778 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2007-07-18 22:46:49 +00:00
parent 91ffdd810b
commit 9ef330b291
@@ -103,6 +103,12 @@ public class PeerManager
public T lookup (NodeObject nodeobj);
}
/** Used by {@link #applyToNodes}. */
public static interface Operation
{
public void apply (NodeObject nodeobj);
}
/**
* Creates a peer manager which will create a {@link NodeRepository} which will be used to
* publish our existence and discover the other nodes.
@@ -258,6 +264,21 @@ public class PeerManager
return value;
}
/**
* Applies the supplied operation to all {@link NodeObject}s. The operation should not modify
* the objects unless you really know what you're doing. more likely it will summarize
* information contained therein.
*/
public void applyToNodes (Operation op)
{
op.apply(_nodeobj);
for (PeerNode peer : _peers.values()) {
if (peer.nodeobj != null) {
op.apply(peer.nodeobj);
}
}
}
/**
* Returns true if the supplied peer credentials match our shared secret.
*/