001    // GraphLab Project: http://graphlab.sharif.edu
002    // Copyright (C) 2008 Mathematical Science Department of Sharif University of Technology
003    // Distributed under the terms of the GNU Lesser General Public License (LGPL): http://www.gnu.org/licenses/
004    
005    package graphlab.library.event;
006    
007    import graphlab.library.BaseEdge;
008    import graphlab.library.BaseGraph;
009    import graphlab.library.BaseVertex;
010    
011    /**
012     * @author Omid Aladini
013     *         Happens when a global event has occured on the graph.
014     */
015    public class GraphEvent<VertexType extends BaseVertex, EdgeType extends BaseEdge<VertexType>>
016            implements Event {
017        public final BaseGraph<VertexType, EdgeType> graph;
018        public final EventType eventType;
019    
020        public static enum EventType {
021            NEW_GRAPH
022        }
023    
024        /**
025         * Constructs a GraphEvent object corresponding to graph <code>g</code> and event <code>et</code>.
026         *
027         * @param g  The graph related to the GraphEvent.
028         * @param et Represents type of the event happened on the graph.
029         */
030        public GraphEvent(BaseGraph<VertexType, EdgeType> g, EventType et) {
031            if (g == null || et == null)
032                throw new NullPointerException("Null graph object or event supplied.");
033    
034            graph = g;
035            eventType = et;
036        }
037    
038        /**
039         * Constructs a GraphEvent object that represents construction of a new graph.
040         *
041         * @param g Graph object that is just constructed.
042         */
043        public GraphEvent(BaseGraph<VertexType, EdgeType> g) {
044            this(g, EventType.NEW_GRAPH);
045    
046        }
047    
048        public String getID() {
049            return "GraphEvent";
050        }
051    
052        public String getDescription() {
053            return "Graph event occurred.";
054        }
055    
056        private String message;
057    
058        public String getMessage() {
059            return message;
060        }
061    
062        public void setMessage(String message) {
063            this.message = message;
064        }
065    }