2021-01-09 12:43:02 +01:00
|
|
|
/*******************************************************************************
|
|
|
|
* Copyright (c) 2020 MINRES Technologies GmbH 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 accompanies this distribution, and is available at
|
|
|
|
* http://www.eclipse.org/legal/epl-v10.html
|
|
|
|
*
|
|
|
|
* Contributors:
|
|
|
|
* MINRES Technologies GmbH - initial API and implementation
|
|
|
|
*******************************************************************************/
|
2020-11-28 14:08:34 +01:00
|
|
|
package com.minres.scviewer.database.text;
|
|
|
|
|
|
|
|
import com.minres.scviewer.database.EventKind;
|
|
|
|
import com.minres.scviewer.database.WaveformType;
|
2020-11-28 14:47:43 +01:00
|
|
|
import com.minres.scviewer.database.tx.ITx;
|
|
|
|
import com.minres.scviewer.database.tx.ITxEvent;
|
2020-11-28 14:08:34 +01:00
|
|
|
|
2021-01-09 12:43:02 +01:00
|
|
|
/**
|
|
|
|
* The Class TxEvent.
|
|
|
|
*/
|
2021-01-03 14:16:56 +01:00
|
|
|
class TxEvent implements ITxEvent {
|
2020-11-28 14:08:34 +01:00
|
|
|
|
2021-01-09 12:43:02 +01:00
|
|
|
/** The loader. */
|
2021-01-03 14:16:56 +01:00
|
|
|
final TextDbLoader loader;
|
2021-01-09 12:43:02 +01:00
|
|
|
|
|
|
|
/** The kind. */
|
2020-11-28 14:08:34 +01:00
|
|
|
final EventKind kind;
|
2021-01-09 12:43:02 +01:00
|
|
|
|
|
|
|
/** The transaction. */
|
2021-01-09 10:34:22 +01:00
|
|
|
final long transaction;
|
2021-01-09 12:43:02 +01:00
|
|
|
|
|
|
|
/** The time. */
|
2021-01-09 10:34:22 +01:00
|
|
|
final long time;
|
2021-01-09 12:43:02 +01:00
|
|
|
|
2021-01-14 23:13:11 +01:00
|
|
|
private int concurrencyIdx=-1;
|
2021-01-09 12:43:02 +01:00
|
|
|
/**
|
|
|
|
* Instantiates a new tx event.
|
|
|
|
*
|
|
|
|
* @param loader the loader
|
|
|
|
* @param kind the kind
|
|
|
|
* @param transaction the transaction
|
|
|
|
* @param time the time
|
|
|
|
*/
|
2021-01-03 14:16:56 +01:00
|
|
|
TxEvent(TextDbLoader loader, EventKind kind, Long transaction, Long time) {
|
2021-01-09 12:43:02 +01:00
|
|
|
this.loader = loader;
|
2020-11-28 14:08:34 +01:00
|
|
|
this.kind = kind;
|
|
|
|
this.transaction = transaction;
|
|
|
|
this.time = time;
|
|
|
|
}
|
|
|
|
|
2021-01-09 12:43:02 +01:00
|
|
|
/**
|
|
|
|
* Duplicate.
|
|
|
|
*
|
|
|
|
* @return the i tx event
|
|
|
|
* @throws CloneNotSupportedException the clone not supported exception
|
|
|
|
*/
|
2020-11-28 14:08:34 +01:00
|
|
|
@Override
|
2021-01-09 12:43:02 +01:00
|
|
|
public ITxEvent duplicate() throws CloneNotSupportedException {
|
2021-01-03 14:16:56 +01:00
|
|
|
return new TxEvent(loader, kind, transaction, time);
|
2020-11-28 14:08:34 +01:00
|
|
|
}
|
|
|
|
|
2021-01-09 12:43:02 +01:00
|
|
|
/**
|
|
|
|
* To string.
|
|
|
|
*
|
|
|
|
* @return the string
|
|
|
|
*/
|
2020-11-28 14:08:34 +01:00
|
|
|
@Override
|
2021-01-09 12:43:02 +01:00
|
|
|
public String toString() {
|
|
|
|
return kind.toString() + "@" + time + " of tx #" + transaction;
|
2020-11-28 14:08:34 +01:00
|
|
|
}
|
|
|
|
|
2021-01-09 12:43:02 +01:00
|
|
|
/**
|
|
|
|
* Gets the type.
|
|
|
|
*
|
|
|
|
* @return the type
|
|
|
|
*/
|
2020-11-28 14:08:34 +01:00
|
|
|
@Override
|
|
|
|
public WaveformType getType() {
|
|
|
|
return WaveformType.TRANSACTION;
|
|
|
|
}
|
|
|
|
|
2021-01-09 12:43:02 +01:00
|
|
|
/**
|
|
|
|
* Gets the kind.
|
|
|
|
*
|
|
|
|
* @return the kind
|
|
|
|
*/
|
2020-11-28 14:08:34 +01:00
|
|
|
@Override
|
|
|
|
public EventKind getKind() {
|
|
|
|
return kind;
|
|
|
|
}
|
|
|
|
|
2021-01-09 12:43:02 +01:00
|
|
|
/**
|
|
|
|
* Gets the time.
|
|
|
|
*
|
|
|
|
* @return the time
|
|
|
|
*/
|
2020-11-28 14:08:34 +01:00
|
|
|
@Override
|
2021-02-27 14:59:00 +01:00
|
|
|
public long getTime() {
|
2020-11-28 14:08:34 +01:00
|
|
|
return time;
|
|
|
|
}
|
|
|
|
|
2021-01-09 12:43:02 +01:00
|
|
|
/**
|
|
|
|
* Gets the transaction.
|
|
|
|
*
|
|
|
|
* @return the transaction
|
|
|
|
*/
|
2020-11-28 14:08:34 +01:00
|
|
|
@Override
|
|
|
|
public ITx getTransaction() {
|
2021-01-03 14:16:56 +01:00
|
|
|
return loader.getTransaction(transaction);
|
2020-11-28 14:08:34 +01:00
|
|
|
}
|
2021-01-14 23:13:11 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public int getRowIndex() {
|
|
|
|
return concurrencyIdx;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void setConcurrencyIndex(int idx) {
|
|
|
|
concurrencyIdx=idx;
|
|
|
|
}
|
2020-11-28 14:08:34 +01:00
|
|
|
}
|