Skip to content

Commit 97018d5

Browse files
committed
remove duplicate summary methods
1 parent 2de3de9 commit 97018d5

File tree

2 files changed

+24
-112
lines changed

2 files changed

+24
-112
lines changed

Sources/FoundationEssentials/ProgressManager/ProgressManager+Properties+Accessors.swift

Lines changed: 24 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -601,7 +601,13 @@ extension ProgressManager {
601601
/// - Returns: An `Int` summary value for the specified property.
602602
public func summary<P: Property>(of property: P.Type) -> P.Summary where P.Value == Int, P.Summary == Int {
603603
accessObservation(keyPath: ProgressManager.additionalPropertiesKeyPath.withLock { $0 })
604-
return getUpdatedIntSummary(property: MetatypeWrapper(property))
604+
if property.self == ProgressManager.Properties.TotalFileCount.self {
605+
return getUpdatedFileCount(type: .total)
606+
} else if property.self == ProgressManager.Properties.CompletedFileCount.self {
607+
return getUpdatedFileCount(type: .completed)
608+
} else {
609+
return getUpdatedIntSummary(property: MetatypeWrapper(property))
610+
}
605611
}
606612

607613
/// Returns a summary for a custom unsigned integer property across the progress subtree.
@@ -614,7 +620,13 @@ extension ProgressManager {
614620
/// - Returns: An `UInt64` summary value for the specified property.
615621
public func summary<P: Property>(of property: P.Type) -> P.Summary where P.Value == UInt64, P.Summary == UInt64 {
616622
accessObservation(keyPath: ProgressManager.additionalPropertiesKeyPath.withLock { $0 })
617-
return getUpdatedUInt64Summary(property: MetatypeWrapper(property))
623+
if property.self == ProgressManager.Properties.TotalByteCount.self {
624+
return getUpdatedByteCount(type: .total)
625+
} else if property.self == ProgressManager.Properties.CompletedByteCount.self {
626+
return getUpdatedByteCount(type: .completed)
627+
} else {
628+
return getUpdatedUInt64Summary(property: MetatypeWrapper(property))
629+
}
618630
}
619631

620632
/// Returns a summary for a custom double property across the progress subtree.
@@ -666,7 +678,11 @@ extension ProgressManager {
666678
/// - Returns: A `[UInt64]` summary value for the specified property.
667679
public func summary<P: Property>(of property: P.Type) -> P.Summary where P.Value == UInt64, P.Summary == [UInt64] {
668680
accessObservation(keyPath: ProgressManager.additionalPropertiesKeyPath.withLock { $0 })
669-
return getUpdatedUInt64ArraySummary(property: MetatypeWrapper(property))
681+
if property.self == ProgressManager.Properties.Throughput.self {
682+
return getUpdatedThroughput()
683+
} else {
684+
return getUpdatedUInt64ArraySummary(property: MetatypeWrapper(property))
685+
}
670686
}
671687

672688
/// Returns a summary for a custom Duration property across the progress subtree.
@@ -679,66 +695,10 @@ extension ProgressManager {
679695
/// - Returns: A `Duration` summary value for the specified property.
680696
public func summary<P: Property>(of property: P.Type) -> P.Summary where P.Value == Duration, P.Summary == Duration {
681697
accessObservation(keyPath: ProgressManager.additionalPropertiesKeyPath.withLock { $0 })
682-
return getUpdatedDurationSummary(property: MetatypeWrapper(property))
683-
}
684-
685-
/// Returns the total file count across the progress subtree.
686-
///
687-
/// - Parameter property: The `TotalFileCount` property type.
688-
/// - Returns: The sum of all total file counts across the entire progress subtree.
689-
public func summary(of property: ProgressManager.Properties.TotalFileCount.Type) -> Int {
690-
accessObservation(keyPath: ProgressManager.additionalPropertiesKeyPath.withLock { $0 })
691-
return getUpdatedFileCount(type: .total)
692-
}
693-
694-
/// Returns the completed file count across the progress subtree.
695-
///
696-
/// - Parameter property: The `CompletedFileCount` property type.
697-
/// - Returns: The sum of all completed file counts across the entire progress subtree.
698-
public func summary(of property: ProgressManager.Properties.CompletedFileCount.Type) -> Int {
699-
accessObservation(keyPath: ProgressManager.additionalPropertiesKeyPath.withLock { $0 })
700-
return getUpdatedFileCount(type: .completed)
701-
}
702-
703-
/// Returns the total byte count across the progress subtree.
704-
///
705-
/// - Parameter property: The `TotalByteCount` property type.
706-
/// - Returns: The sum of all total byte counts across the entire progress subtree, in bytes.
707-
public func summary(of property: ProgressManager.Properties.TotalByteCount.Type) -> UInt64 {
708-
accessObservation(keyPath: ProgressManager.additionalPropertiesKeyPath.withLock { $0 })
709-
return getUpdatedByteCount(type: .total)
710-
}
711-
712-
/// Returns the completed byte count across the progress subtree.
713-
///
714-
/// - Parameter property: The `CompletedByteCount` property type.
715-
/// - Returns: The sum of all completed byte counts across the entire progress subtree, in bytes.
716-
public func summary(of property: ProgressManager.Properties.CompletedByteCount.Type) -> UInt64 {
717-
accessObservation(keyPath: ProgressManager.additionalPropertiesKeyPath.withLock { $0 })
718-
return getUpdatedByteCount(type: .completed)
719-
}
720-
721-
/// Returns the average throughput across the progress subtree.
722-
///
723-
/// - Parameter property: The `Throughput` property type.
724-
/// - Returns: The average throughput across the entire progress subtree, in bytes per second.
725-
///
726-
/// - Note: The throughput is calculated as the sum of all throughput values divided by the count
727-
/// of progress managers that have throughput data.
728-
public func summary(of property: ProgressManager.Properties.Throughput.Type) -> [UInt64] {
729-
accessObservation(keyPath: ProgressManager.additionalPropertiesKeyPath.withLock { $0 })
730-
return getUpdatedThroughput()
731-
}
732-
733-
/// Returns the maximum estimated time remaining for completion across the progress subtree.
734-
///
735-
/// - Parameter property: The `EstimatedTimeRemaining` property type.
736-
/// - Returns: The estimated duration until completion for the entire progress subtree.
737-
///
738-
/// - Note: The estimation is based on current throughput and remaining work. The accuracy
739-
/// depends on the consistency of the processing rate.
740-
public func summary(of property: ProgressManager.Properties.EstimatedTimeRemaining.Type) -> Duration {
741-
accessObservation(keyPath: ProgressManager.additionalPropertiesKeyPath.withLock { $0 })
742-
return getUpdatedEstimatedTimeRemaining()
698+
if property.self == ProgressManager.Properties.EstimatedTimeRemaining.self {
699+
return getUpdatedEstimatedTimeRemaining()
700+
} else {
701+
return getUpdatedDurationSummary(property: MetatypeWrapper(property))
702+
}
743703
}
744704
}

Sources/FoundationEssentials/ProgressManager/ProgressReporter.swift

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -138,54 +138,6 @@ import Observation
138138
return manager.summary(of: property)
139139
}
140140

141-
/// Returns the total file count across the progress subtree.
142-
///
143-
/// - Parameter property: The `TotalFileCount` property type.
144-
/// - Returns: The sum of all total file counts across the entire progress subtree.
145-
public func summary(of property: ProgressManager.Properties.TotalFileCount.Type) -> Int {
146-
return manager.summary(of: property)
147-
}
148-
149-
/// Returns the completed file count across the progress subtree.
150-
///
151-
/// - Parameter property: The `CompletedFileCount` property type.
152-
/// - Returns: The sum of all completed file counts across the entire progress subtree.
153-
public func summary(of property: ProgressManager.Properties.CompletedFileCount.Type) -> Int {
154-
manager.summary(of: property)
155-
}
156-
157-
/// Returns the total byte count across the progress subtree.
158-
///
159-
/// - Parameter property: The `TotalByteCount` property type.
160-
/// - Returns: The sum of all total byte counts across the entire progress subtree, in bytes.
161-
public func summary(of property: ProgressManager.Properties.TotalByteCount.Type) -> UInt64 {
162-
manager.summary(of: property)
163-
}
164-
165-
/// Returns the completed byte count across the progress subtree.
166-
///
167-
/// - Parameter property: The `CompletedByteCount` property type.
168-
/// - Returns: The sum of all completed byte counts across the entire progress subtree, in bytes.
169-
public func summary(of property: ProgressManager.Properties.CompletedByteCount.Type) -> UInt64 {
170-
manager.summary(of: property)
171-
}
172-
173-
/// Returns the average throughput across the progress subtree.
174-
///
175-
/// - Parameter property: The `Throughput` property type.
176-
/// - Returns: The average throughput across the entire progress subtree, in bytes per second.
177-
public func summary(of property: ProgressManager.Properties.Throughput.Type) -> [UInt64] {
178-
manager.summary(of: property)
179-
}
180-
181-
/// Returns the maximum estimated time remaining for completion across the progress subtree.
182-
///
183-
/// - Parameter property: The `EstimatedTimeRemaining` property type.
184-
/// - Returns: The estimated duration until completion for the entire progress subtree.
185-
public func summary(of property: ProgressManager.Properties.EstimatedTimeRemaining.Type) -> Duration {
186-
manager.summary(of: property)
187-
}
188-
189141
internal let manager: ProgressManager
190142

191143
internal init(manager: ProgressManager) {

0 commit comments

Comments
 (0)