refactor database class hierarchy

This commit is contained in:
2020-11-28 10:22:22 +01:00
parent db838efc65
commit 21d83f93dc
22 changed files with 217 additions and 190 deletions

View File

@ -10,7 +10,7 @@
*******************************************************************************/
package com.minres.scviewer.database;
public class BitVector {
public class BitVector implements IEvent {
private final int width;
@ -166,5 +166,20 @@ public class BitVector {
}
return res;
}
@Override
public EventKind getKind() {
return EventKind.SINGLE;
}
@Override
public Class<?> getType() {
return this.getClass();
}
@Override
public IEvent duplicate() throws CloneNotSupportedException {
return (IEvent)this.clone();
}
}

View File

@ -0,0 +1,26 @@
package com.minres.scviewer.database;
public class DoubleVal implements IEvent {
final double value;
public DoubleVal(double value) {
this.value=value;
}
@Override
public EventKind getKind() {
return EventKind.SINGLE;
}
@Override
public Class<?> getType() {
return this.getClass();
}
@Override
public IEvent duplicate() throws CloneNotSupportedException {
return (IEvent) clone();
}
}

View File

@ -0,0 +1,5 @@
package com.minres.scviewer.database;
public enum EventKind {
SINGLE, BEGIN, END
}

View File

@ -0,0 +1,11 @@
package com.minres.scviewer.database;
public interface IEvent {
public IEvent duplicate() throws CloneNotSupportedException;
public EventKind getKind();
public Class<?> getType();
}

View File

@ -1,26 +0,0 @@
/*******************************************************************************
* Copyright (c) 2015 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
*******************************************************************************/
package com.minres.scviewer.database;
import java.util.NavigableMap;
public interface ISignal<T> extends IWaveform{
public NavigableMap<Long, T> getEvents();
public T getWaveformValueAtTime(Long time);
public T getWaveformValueBeforeTime(Long time);
public Class<?> getType();
}

View File

@ -17,7 +17,7 @@ public interface ITx extends Comparable<ITx>{
public Long getId();
public ITxStream<ITxEvent> getStream();
public IWaveform getStream();
public ITxGenerator getGenerator();

View File

@ -10,10 +10,9 @@
*******************************************************************************/
package com.minres.scviewer.database;
public interface ITxEvent extends IWaveformEvent {
enum Type {BEGIN, END};
public interface ITxEvent extends IEvent {
public Long getTime();
public ITx getTransaction();
public Type getType();
public ITx getTransaction();
}

View File

@ -14,7 +14,7 @@ import java.util.List;
public interface ITxGenerator {
public Long getId();
public ITxStream<ITxEvent> getStream();
public IWaveform getStream();
public String getName();
public List<ITx> getTransactions();
}

View File

@ -1,27 +0,0 @@
/*******************************************************************************
* Copyright (c) 2015 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
*******************************************************************************/
package com.minres.scviewer.database;
import java.util.Collection;
import java.util.List;
import java.util.NavigableMap;
public interface ITxStream<T extends ITxEvent> extends IWaveform {
public List<ITxGenerator> getGenerators();
public int getMaxConcurrency();
public NavigableMap<Long, List<ITxEvent>> getEvents();
public Collection<T> getWaveformEventsAtTime(Long time);
}

View File

@ -10,6 +10,7 @@
*******************************************************************************/
package com.minres.scviewer.database;
import java.util.NavigableMap;
public interface IWaveform extends IHierNode {
@ -21,4 +22,14 @@ public interface IWaveform extends IHierNode {
public Boolean equals(IWaveform other);
public NavigableMap<Long, IEvent[]> getEvents();
public IEvent[] getEventsAtTime(Long time);
public IEvent[] getEventsBeforeTime(Long time);
public Class<?> getType();
public int getMaxConcurrency();
}

View File

@ -1,20 +0,0 @@
/*******************************************************************************
* Copyright (c) 2015 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
*******************************************************************************/
package com.minres.scviewer.database;
public interface IWaveformEvent extends Comparable<IWaveformEvent>{
public Long getTime();
public IWaveformEvent duplicate() throws CloneNotSupportedException;
}