- * Usual CTFEvent constructor, where we read an event from the trace (via
- * the StreamInputReader).
- *
- * @param eventDef
- * CTF EventDefinition object corresponding to this trace event
- * @param fileName
- * The path to the trace file
- * @param originTrace
- * The trace from which this event originates
- */
- public CtfTmfEvent(EventDefinition eventDef, String fileName,
- CtfTmfTrace originTrace) {
- this.fTrace = originTrace;
-
- if (eventDef == null) {
- this.timestamp = -1;
- this.sourceCPU = -1;
- this.typeId = -1;
- this.fileName = NO_STREAM;
- this.eventName = EMPTY_CTF_EVENT_NAME;
- this.fContent = null;
- return;
- }
-
- /* Read the base event info */
- this.timestamp = this.getTrace().getCTFTrace().timestampCyclesToNanos(eventDef.getTimestamp());
- this.sourceCPU = eventDef.getCPU();
- this.typeId = eventDef.getDeclaration().getId();
- this.eventName = eventDef.getDeclaration().getName();
- this.fileName = fileName;
-
- /* Read the fields */
- this.fContent = new CtfTmfContent(ITmfEventField.ROOT_FIELD_ID,
- parseFields(eventDef));
- }
-
- /**
- * Extract the field information from the structDefinition haze-inducing
- * mess, and put them into something ITmfEventField can cope with.
- *
- * @param eventDef
- * CTF EventDefinition to read
- * @return CtfTmfEventField[] The array of fields that were read
- */
- public static CtfTmfEventField[] parseFields(EventDefinition eventDef) {
- List<CtfTmfEventField> fields = new ArrayList<CtfTmfEventField>();
-
- StructDefinition structFields = eventDef.getFields();
- HashMap<String, Definition> definitions = structFields.getDefinitions();
- String curFieldName;
- Definition curFieldDef;
- CtfTmfEventField curField;
- Iterator<Entry<String, Definition>> it = definitions.entrySet().iterator();
- while(it.hasNext()) {
- Entry<String, Definition> entry = it.next();
- curFieldName = entry.getKey();
- curFieldDef = entry.getValue();
- curField = CtfTmfEventField.parseField(curFieldDef, curFieldName);
- fields.add(curField);
- }
-
- return fields.toArray(new CtfTmfEventField[fields.size()]);
- }
-
- /**
- * Copy constructor
- *
- * @param other
- * CtfTmfEvent to copy