/*******************************************************************************
- * Copyright (c) 2011-2012 Ericsson, Ecole Polytechnique de Montreal and others
+ * Copyright (c) 2011-2013 Ericsson, Ecole Polytechnique de Montreal and others
*
* All rights reserved. This program and the accompanying materials are made
* available under the terms of the Eclipse Public License v1.0 which
import java.util.HashSet;
import java.util.Set;
-import org.eclipse.linuxtools.ctf.core.event.EventDeclaration;
-import org.eclipse.linuxtools.ctf.core.event.metadata.exceptions.ParseException;
+import org.eclipse.linuxtools.ctf.core.event.IEventDeclaration;
import org.eclipse.linuxtools.ctf.core.event.types.StructDeclaration;
+import org.eclipse.linuxtools.internal.ctf.core.event.metadata.exceptions.ParseException;
/**
* <b><u>Stream</u></b>
* <p>
* Represents a stream in a trace.
+ * @since 2.0
*/
public class Stream {
/**
* Maps event ids to events
*/
- private final HashMap<Long, EventDeclaration> events = new HashMap<Long, EventDeclaration>();
+ private HashMap<Long, IEventDeclaration> events = new HashMap<Long, IEventDeclaration>();
/**
* The inputs associated to this stream
// Getters/Setters/Predicates
// ------------------------------------------------------------------------
+ /**
+ * Sets the id of a stream
+ * @param id the id of a stream
+ */
public void setId(long id) {
this.id = id;
+ this.events = trace.createEvents(this.id);
}
+ /**
+ * Gets the id of a stream
+ * @return id the id of a stream
+ */
public Long getId() {
return id;
}
- public boolean idIsSet() {
+ /**
+ * Is the id of a stream set
+ *
+ * @return If the ID is set or not
+ */
+ public boolean isIdSet() {
return id != null;
}
- public boolean eventHeaderIsSet() {
+ /**
+ *
+ * @return is the event header set (timestamp and stuff) (see Ctf Spec)
+ */
+ public boolean isEventHeaderSet() {
return eventHeaderDecl != null;
}
- public boolean eventContextIsSet() {
+ /**
+ *
+ * @return is the event context set (pid and stuff) (see Ctf Spec)
+ */
+ public boolean isEventContextSet() {
return eventContextDecl != null;
}
- public boolean packetContextIsSet() {
+ /**
+ *
+ * @return Is the packet context set (see Ctf Spec)
+ */
+ public boolean isPacketContextSet() {
return packetContextDecl != null;
}
+ /**
+ *
+ * @param eventHeader the current event header for all events in this stream
+ */
public void setEventHeader(StructDeclaration eventHeader) {
this.eventHeaderDecl = eventHeader;
}
+ /**
+ *
+ * @param eventContext the context for all events in this stream
+ */
public void setEventContext(StructDeclaration eventContext) {
this.eventContextDecl = eventContext;
}
+ /**
+ *
+ * @param packetContext the packet context for all packets in this stream
+ */
public void setPacketContext(StructDeclaration packetContext) {
this.packetContextDecl = packetContext;
}
+ /**
+ *
+ * @return the event header declaration in structdeclaration form
+ */
public StructDeclaration getEventHeaderDecl() {
return eventHeaderDecl;
}
+ /**
+ *
+ * @return the event context declaration in structdeclaration form
+ */
public StructDeclaration getEventContextDecl() {
return eventContextDecl;
}
+ /**
+ *
+ * @return the packet context declaration in structdeclaration form
+ */
public StructDeclaration getPacketContextDecl() {
return packetContextDecl;
}
+ /**
+ *
+ * @return the set of all stream inputs for this stream
+ */
public Set<StreamInput> getStreamInputs() {
return inputs;
}
+ /**
+ *
+ * @return the parent trace
+ */
public CTFTrace getTrace() {
return trace;
}
- public HashMap<Long, EventDeclaration> getEvents() {
+ /**
+ *
+ * @return all the event declarations for this stream, using the id as a key for the hashmap.
+ */
+ public HashMap<Long, IEventDeclaration> getEvents() {
return events;
}
* is present in the map.
*
* @param event
- * The event to add.
+ * The event to add
* @throws ParseException
+ * If there was a problem reading the event or adding it to the
+ * stream
*/
- public void addEvent(EventDeclaration event) throws ParseException {
+ public void addEvent(IEventDeclaration event) throws ParseException {
/*
* If there is an event without id (the null key), it must be the only
* one
inputs.add(input);
}
-
- /* (non-Javadoc)
- * @see java.lang.Object#toString()
- */
@Override
public String toString() {
return "Stream [id=" + id + ", packetContextDecl=" + packetContextDecl //$NON-NLS-1$ //$NON-NLS-2$