Commit 36859856 authored by Björn Richerzhagen's avatar Björn Richerzhagen
Browse files

Updated graph API to new version from Michael Stein

parent b1ee87ed
......@@ -20,6 +20,8 @@
package de.tudarmstadt.maki.simonstrator.api.component.topology;
import java.util.Collection;
import de.tudarmstadt.maki.simonstrator.api.common.graph.Node;
/**
......@@ -43,4 +45,34 @@ public interface AdaptableTopologyProvider extends TopologyProvider {
* @param node
*/
public void removeNeighbor(String topologyIdentifier, Node node);
/**
* Returns the collection of all possible interactions which may be done in
* order to adapt the topology. Returns only those actions that can later be
* conducted by this component via the performOperation() method
*
* @param topologyIdentifier
* @param node
*/
public Collection<OperationalEdge> getPossibleEdgeOperations(
String topologyIdentifier);
/**
* Performs the given edge operation. Must be one of the operation returned
* by getPossibleEdgeOperations()
*
* @param topologyidentifier
* @param edgeOperation
*/
public void performOperation(String topologyidentifier,
OperationalEdge edgeOperation);
/**
* Returns a collection of graph constraints which must be met after
* adapting a given graph.
*
* @return The set of graph constraints which must be met by the
* optimization method.
*/
public Collection<Constraint> getGraphConstraints();
}
/*
* Copyright (c) 2005-2010 KOM Multimedia Communications Lab
*
* This file is part of Simonstrator.KOM.
*
* Simonstrator.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
*/
package de.tudarmstadt.maki.simonstrator.api.component.topology;
import de.tudarmstadt.maki.simonstrator.api.common.graph.Graph;
public interface Constraint {
/**
* Checks the graph whether it is conform with the implemented graph
* constraint(s).
*
* @param graphToCheck
* @return
*/
public boolean isConform(Graph valueToCheck);
}
/*
* Copyright (c) 2005-2010 KOM Multimedia Communications Lab
*
* This file is part of Simonstrator.KOM.
*
* Simonstrator.KOM is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* PeerfactSim.KOM is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PeerfactSim.KOM. If not, see <http://www.gnu.org/licenses/>.
*
*/
package de.tudarmstadt.maki.simonstrator.api.component.topology;
import de.tudarmstadt.maki.simonstrator.api.common.graph.DirectedEdge;
import de.tudarmstadt.maki.simonstrator.api.common.graph.Node;
/**
* Represents an edge operations, which can be either an addition of the given
* edge or a removal.
*
* @author Julian M. Klomp
*
*/
public class OperationalEdge extends DirectedEdge {
/*
* (non-Javadoc)
*
* @see java.lang.Object#hashCode()
*/
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
result = prime * result + ((type == null) ? 0 : type.hashCode());
return result;
}
/*
* (non-Javadoc)
*
* @see java.lang.Object#equals(java.lang.Object)
*/
@Override
public boolean equals(Object obj) {
if (this == obj)
return true;
if (!super.equals(obj))
return false;
if (getClass() != obj.getClass())
return false;
OperationalEdge other = (OperationalEdge) obj;
if (type != other.type)
return false;
return true;
}
public enum EdgeOperationType {
Add, Remove
};
private EdgeOperationType type;
public OperationalEdge(DirectedEdge edge, EdgeOperationType type) {
super(edge.getStartNode(), edge.getEndNode(),edge.getWeight());
this.type = type;
}
public OperationalEdge(Node startNode, Node endNode,
EdgeOperationType type) {
super(startNode, endNode);
this.type = type;
}
public EdgeOperationType getType() {
return this.type;
}
public void setType(EdgeOperationType type) {
this.type = type;
}
public DirectedEdge getEdge() {
return new DirectedEdge(this.getStartNode(), this.getEndNode(),
this.getWeight());
}
@Override
public String toString() {
return this.getType() + ": " + this.getStartNode() + " -> "
+ this.getEndNode();
}
}
......@@ -49,20 +49,26 @@ public interface TopologyProvider extends HostComponent {
*
* @return the node that represents this HostComponent
*/
public Node getNode();
public Node getNode(String identifier);
/**
* This method provides the 1-hop neighborhood of this TopologyProvider
*
* @param topologyIdentifier
*/
public Set<DirectedEdge> getNeighbors();
public Set<DirectedEdge> getNeighbors(String topologyIdentifier);
/**
* This method provides the complete local view of this topology provider,
* i.e., it is not bounded by the 1-hop neighborhood. It depends on the
* concrete implementation how large the local view is.
*/
public Graph getLocalView();
public Graph getLocalView(String topologyIdentifier);
/**
*
* @return the types of topologies provided by the component
*/
public Iterable<String> getTopologyIdentifiers();
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment