Skip to content

Commit

Permalink
core: remove unnecessary @JVMNames
Browse files Browse the repository at this point in the history
  • Loading branch information
eckter committed Nov 23, 2023
1 parent 36d11ec commit 1263c69
Show file tree
Hide file tree
Showing 13 changed files with 21 additions and 91 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,11 @@ import fr.sncf.osrd.utils.units.OffsetList
sealed interface Zone
typealias ZoneId = StaticIdx<Zone>

@Suppress("INAPPLICABLE_JVM_NAME")
interface LocationInfra : TrackNetworkInfra, TrackInfra, TrackProperties {
val zones: StaticIdxSpace<Zone>
fun getMovableElements(zone: ZoneId): StaticIdxSortedSet<TrackNode>
fun getZoneBounds(zone: ZoneId): List<DirDetectorId>
@JvmName("getZoneName")
fun getZoneName(zone: ZoneId): String
@JvmName("getZoneFromName")
fun getZoneFromName(name: String): ZoneId

val detectors: StaticIdxSpace<Detector>
Expand All @@ -39,16 +36,13 @@ fun LocationInfra.isBufferStop(detector: StaticIdx<Detector>): Boolean {
}


@Suppress("INAPPLICABLE_JVM_NAME")
interface ReservationInfra : LocationInfra {
val zonePaths: StaticIdxSpace<ZonePath>
fun findZonePath(entry: DirDetectorId, exit: DirDetectorId,
movableElements: StaticIdxList<TrackNode>,
trackNodeConfigs: StaticIdxList<TrackNodeConfig>): ZonePathId?
fun getZonePathEntry(zonePath: ZonePathId): DirDetectorId
@JvmName("getZonePathExit")
fun getZonePathExit(zonePath: ZonePathId): DirDetectorId
@JvmName("getZonePathLength")
fun getZonePathLength(zonePath: ZonePathId): Length<ZonePath>
/** The movable elements in the order encountered when traversing the zone from entry to exit */
fun getZonePathMovableElements(zonePath: ZonePathId): StaticIdxList<TrackNode>
Expand All @@ -57,11 +51,9 @@ interface ReservationInfra : LocationInfra {
/** The distances from the beginning of the zone path to its switches, in encounter order */
fun getZonePathMovableElementsPositions(zonePath: ZonePathId): OffsetList<ZonePath>
/** Returns the list of track chunks on the zone path */
@JvmName("getZonePathChunks")
fun getZonePathChunks(zonePath: ZonePathId): DirStaticIdxList<TrackChunk>
}

@JvmName("getZonePathZone")
fun ReservationInfra.getZonePathZone(zonePath: ZonePathId): ZoneId {
return getNextZone(getZonePathEntry(zonePath))!!
}
Expand All @@ -78,39 +70,29 @@ typealias RouteId = StaticIdx<Route>

@Suppress("INAPPLICABLE_JVM_NAME")
interface RoutingInfra : ReservationInfra {
@get:JvmName("getRoutes")
val routes: StaticIdxSpace<Route>
@JvmName("getRoutePath")
fun getRoutePath(route: RouteId): StaticIdxList<ZonePath>
@JvmName("getRouteName")
fun getRouteName(route: RouteId): String?
@JvmName("getRouteLength")
fun getRouteLength(route: RouteId): Length<Route>
@JvmName("getRouteFromName")
fun getRouteFromName(name: String): RouteId

/** Returns a list of indices of zones in the train path at which the reservations shall be released. */
fun getRouteReleaseZones(route: RouteId): IntArray
@JvmName("getChunksOnRoute")
fun getChunksOnRoute(route: RouteId): DirStaticIdxList<TrackChunk>
@JvmName("getRoutesOnTrackChunk")
fun getRoutesOnTrackChunk(trackChunk: DirTrackChunkId): StaticIdxList<Route>
@JvmName("getRoutesStartingAtDet")
fun getRoutesStartingAtDet(dirDetector: DirDetectorId): StaticIdxList<Route>
@JvmName("getRoutesEndingAtDet")
fun getRoutesEndingAtDet(dirDetector: DirDetectorId): StaticIdxList<Route>
}

fun ReservationInfra.findZonePath(entry: DirDetectorId, exit: DirDetectorId): ZonePathId? {
return findZonePath(entry, exit, mutableStaticIdxArrayListOf(), mutableStaticIdxArrayListOf())
}

@JvmName("getRouteEntry")
fun RoutingInfra.getRouteEntry(route: RouteId): DirDetectorId {
return getZonePathEntry(getRoutePath(route).first())
}

@JvmName("getRouteExit")
fun RoutingInfra.getRouteExit(route: RouteId): DirDetectorId {
return getZonePathExit(getRoutePath(route).last())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,7 @@ typealias SigStateSchema = SigSchema<SignalStateMarker>


/** The signaling system manager is a repository for drivers and signaling systems */
@Suppress("INAPPLICABLE_JVM_NAME")
interface InfraSigSystemManager {
@get:JvmName("getSignalingSystems")
val signalingSystems: StaticIdxSpace<SignalingSystem>
fun findSignalingSystem(sigSystem: String): SignalingSystemId
fun getStateSchema(sigSystem: SignalingSystemId): SigStateSchema
Expand Down Expand Up @@ -54,26 +52,19 @@ interface LoadedSignalInfra {

@Suppress("INAPPLICABLE_JVM_NAME")
interface BlockInfra {
@get:JvmName("getBlocks")
val blocks: StaticIdxSpace<Block>
@JvmName("getBlockPath")
fun getBlockPath(block: BlockId): StaticIdxList<ZonePath>
@JvmName("getBlocksInZone")
fun getBlocksInZone(zone: ZoneId): StaticIdxList<Block>
fun getBlockSignals(block: BlockId): StaticIdxList<LogicalSignal>
fun blockStartAtBufferStop(block: BlockId): Boolean
fun blockStopAtBufferStop(block: BlockId): Boolean

fun getBlockSignalingSystem(block: BlockId): SignalingSystemId
@JvmName("getBlocksStartingAtDetector")
fun getBlocksStartingAtDetector(detector: DirDetectorId): StaticIdxList<Block>
@JvmName("getBlocksEndingAtDetector")
fun getBlocksEndingAtDetector(detector: DirDetectorId): StaticIdxList<Block>
fun getBlocksAtSignal(signal: LogicalSignalId): StaticIdxList<Block>
fun getSignalsPositions(block: BlockId): OffsetList<Block>
@JvmName("getBlocksFromTrackChunk")
fun getBlocksFromTrackChunk(trackChunk: TrackChunkId, direction: Direction): MutableStaticIdxArraySet<Block>
@JvmName("getTrackChunksFromBlock")
fun getTrackChunksFromBlock(block: BlockId): DirStaticIdxList<TrackChunk>
@JvmName("getBlockLength")
fun getBlockLength(block: BlockId): Length<Block>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,5 @@ typealias LoadingGaugeTypeId = StaticIdx<LoadingGaugeType>

interface LoadingGaugeConstraint {
/** Returns true if a train of the given type is compatible */
@Suppress("INAPPLICABLE_JVM_NAME")
@JvmName("isCompatibleWith")
fun isCompatibleWith(trainType: LoadingGaugeTypeId): Boolean
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,7 @@ import fr.sncf.osrd.utils.units.Offset
import fr.sncf.osrd.utils.units.Speed

data class IdxWithOffset<T>(
@get:JvmName("getValue")
val value: StaticIdx<T>,
@get:JvmName("getOffset")
val offset: Distance,
)

Expand All @@ -35,9 +33,7 @@ interface PathProperties {
fun getCurves(): DistanceRangeMap<Double>
fun getGeo(): LineString
fun getLoadingGauge(): DistanceRangeMap<LoadingGaugeConstraint>
@JvmName("getCatenary")
fun getCatenary(): DistanceRangeMap<String>
@JvmName("getNeutralSections")
fun getNeutralSections(): DistanceRangeMap<NeutralSection>
@JvmName("getSpeedLimits")
fun getSpeedLimits(trainTag: String?): DistanceRangeMap<Speed>
Expand All @@ -51,7 +47,6 @@ interface PathProperties {
}

/** Build a Path from chunks and offsets, filtering the chunks outside the offsets */
@JvmName("buildPathPropertiesFrom")
fun buildPathPropertiesFrom(
infra: TrackProperties,
chunks: DirStaticIdxList<TrackChunk>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ interface TrackInfra {
@JvmName("getTrackSectionName")
fun getTrackSectionName(trackSection: TrackSectionId): String
fun getTrackSectionFromName(name: String): TrackSectionId?
@JvmName("getTrackSectionChunks")
fun getTrackSectionChunks(trackSection: TrackSectionId): StaticIdxList<TrackChunk>
@JvmName("getTrackSectionLength")
fun getTrackSectionLength(trackSection: TrackSectionId): Length<TrackSection>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,10 @@ import fr.sncf.osrd.utils.units.Speed
sealed interface OperationalPointPart
typealias OperationalPointPartId = StaticIdx<OperationalPointPart>

@Suppress("INAPPLICABLE_JVM_NAME")
interface TrackProperties {
// Chunk attributes
@JvmName("getTrackChunkLength")
fun getTrackChunkLength(trackChunk: TrackChunkId): Length<TrackChunk>
@JvmName("getTrackChunkOffset")
fun getTrackChunkOffset(trackChunk: TrackChunkId): Offset<TrackSection>
@JvmName("getTrackFromChunk")
fun getTrackFromChunk(trackChunk: TrackChunkId): TrackSectionId

// Linear track attributes
Expand All @@ -34,16 +30,13 @@ interface TrackProperties {
fun getTrackChunkGradient(trackChunk: DirTrackChunkId): DistanceRangeMap<Double>
fun getTrackChunkLoadingGaugeConstraints(trackChunk: TrackChunkId): DistanceRangeMap<LoadingGaugeConstraint>
fun getTrackChunkCatenaryVoltage(trackChunk: TrackChunkId): DistanceRangeMap<String>
@JvmName("getTrackChunkNeutralSections")
fun getTrackChunkNeutralSections(trackChunk: DirTrackChunkId): DistanceRangeMap<NeutralSection>
fun getTrackChunkSpeedSections(trackChunk: DirTrackChunkId, trainTag: String?): DistanceRangeMap<Speed>
@JvmName("getTrackChunkGeom")
fun getTrackChunkGeom(trackChunk: TrackChunkId): LineString

// Operational points
fun getTrackChunkOperationalPointParts(trackChunk: TrackChunkId): StaticIdxList<OperationalPointPart>
fun getOperationalPointPartChunk(operationalPoint: OperationalPointPartId): TrackChunkId
fun getOperationalPointPartChunkOffset(operationalPoint: OperationalPointPartId): Offset<TrackChunk>
@JvmName("getOperationalPointPartName")
fun getOperationalPointPartName(operationalPoint: OperationalPointPartId): String
}
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,12 @@ class BlockInfraImpl(
}
}

@JvmName("getBlockEntry")
fun BlockInfra.getBlockEntry(rawInfra: RawInfra, block: BlockId): DirDetectorId {
val blockPath: StaticIdxList<ZonePath> = getBlockPath(block)
val firstZone: ZonePathId = blockPath[0]
return rawInfra.getZonePathEntry(firstZone)
}

@JvmName("getBlockExit")
fun BlockInfra.getBlockExit(rawInfra: RawInfra, block: BlockId): DirDetectorId {
val blockPath: StaticIdxList<ZonePath> = getBlockPath(block)
val lastZonePath: ZonePathId = blockPath[blockPath.size - 1]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,8 @@ import fr.sncf.osrd.utils.units.*
/** A ChunkPath is a list of directional track chunks which form a path, with beginOffset being the offset
* on the first chunk, and endOffset on the last chunk. **/
data class ChunkPath(
@get:JvmName("getChunks")
val chunks: DirStaticIdxList<TrackChunk>,
@get:JvmName("getBeginOffset")
val beginOffset: Distance,
@get:JvmName("getEndOffset")
val endOffset: Distance
)

Expand Down Expand Up @@ -243,18 +240,7 @@ fun getOffsetOfTrackLocationOnChunks(
return null
}

/** Returns the offset of a location on a given list of chunks, throws if not found */
@JvmName("getOffsetOfTrackLocationOnChunksOrThrow")
fun getOffsetOfTrackLocationOnChunksOrThrow(
infra: TrackProperties,
location: TrackLocation,
chunks: DirStaticIdxList<TrackChunk>,
): Distance {
return getOffsetOfTrackLocationOnChunks(infra, location, chunks) ?: throw RuntimeException()
}

/** Build chunkPath, which is the subset of the given chunks corresponding to the beginOffset and endOffset. **/
@JvmName("buildChunkPath")
fun buildChunkPath(
infra: TrackProperties,
chunks: DirStaticIdxList<TrackChunk>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import java.util.*

data class BlockPathElement(
val prev: BlockPathElement?,
@get:JvmName("getBlock")
val block: BlockId,
// the index of the route in the path
val routeIndex: Int,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import fr.sncf.osrd.sim_infra.api.TrackSection
import fr.sncf.osrd.utils.indexing.DirStaticIdxList
import fr.sncf.osrd.utils.indexing.mutableDirStaticIdxArrayListOf

@JvmName("getNextTrackSections")
fun TrackNetworkInfra.getNextTrackSections(trackSection: DirTrackSectionId): DirStaticIdxList<TrackSection> {
val nextTrackSections = mutableDirStaticIdxArrayListOf<TrackSection>()
val node = getNextTrackNode(trackSection)
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package fr.sncf.osrd.infra.implementation.tracks.undirected

import com.google.common.collect.ImmutableSet
import fr.sncf.osrd.railjson.schema.rollingstock.RJSLoadingGaugeType
import fr.sncf.osrd.sim_infra.api.LoadingGaugeConstraint
import fr.sncf.osrd.sim_infra.api.LoadingGaugeTypeId

class LoadingGaugeConstraintImpl(blockedTypes: ImmutableSet<RJSLoadingGaugeType>) : LoadingGaugeConstraint {
private val blockedTypes: ImmutableSet<LoadingGaugeTypeId>

init {
val builder = ImmutableSet.builder<LoadingGaugeTypeId>()
for (blockedType in blockedTypes)
builder.add(LoadingGaugeTypeId(blockedType.ordinal.toUInt()))
this.blockedTypes = builder.build()
}

override fun isCompatibleWith(trainType: LoadingGaugeTypeId): Boolean {
return !blockedTypes.contains(trainType)
}
}
9 changes: 0 additions & 9 deletions core/src/test/kotlin/fr/sncf/osrd/utils/DummyInfra.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import kotlin.time.Duration
* Ids are all interchangeable, there's one zone, one chunk, one track, one route per block.
* Block descriptor can be edited when we need to set data that isn't included in the method parameters.
* Not all methods are implemented, but it can be added when relevant. */
@Suppress("INAPPLICABLE_JVM_NAME")
class DummyInfra : RawInfra, BlockInfra {

val blockPool = mutableListOf<DummyBlockDescriptor>() // A StaticPool (somehow) fails to link with java here
Expand All @@ -25,7 +24,6 @@ class DummyInfra : RawInfra, BlockInfra {
private val exitMap = HashMultimap.create<DirDetectorId, BlockId>()

/** get the FullInfra */
@JvmName("fullInfra")
fun fullInfra(): FullInfra {
return FullInfra(
this,
Expand All @@ -36,7 +34,6 @@ class DummyInfra : RawInfra, BlockInfra {
}

/** Creates a block going from nodes `entry` to `exit` of length 100m, named $entry->$exit, with no max speed. */
@JvmName("addBlock")
fun addBlock(
entry: String,
exit: String,
Expand All @@ -45,7 +42,6 @@ class DummyInfra : RawInfra, BlockInfra {
}

/** Creates a block going from nodes `entry` to `exit` of length `length`, named $entry->$exit */
@JvmName("addBlock")
fun addBlock(
entry: String,
exit: String,
Expand All @@ -56,7 +52,6 @@ class DummyInfra : RawInfra, BlockInfra {

/** Creates a block going from nodes `entry` to `exit` of length `length`, named $entry->$exit,
* with the given maximum speed. */
@JvmName("addBlock")
fun addBlock(
entry: String,
exit: String,
Expand Down Expand Up @@ -156,17 +151,14 @@ class DummyInfra : RawInfra, BlockInfra {
return makeIndexList(route)
}

@JvmName("getRouteName")
override fun getRouteName(route: RouteId): String {
return blockPool[route.index].name
}

@JvmName("getRouteLength")
override fun getRouteLength(route: RouteId): Length<Route> {
return Length(blockPool[route.index].length)
}

@JvmName("getRouteFromName")
override fun getRouteFromName(name: String): RouteId {
for (i in 0 until blockPool.size) {
if (blockPool[i].name == name)
Expand Down Expand Up @@ -478,7 +470,6 @@ class DummyInfra : RawInfra, BlockInfra {
return makeDirIndexList(block)
}

@JvmName("getBlockLength")
override fun getBlockLength(block: BlockId): Length<Block> {
return Length(blockPool[block.index].length)
}
Expand Down

0 comments on commit 1263c69

Please sign in to comment.