-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathTCXWorkouts.swift
More file actions
90 lines (69 loc) · 1.8 KB
/
TCXWorkouts.swift
File metadata and controls
90 lines (69 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
//
// TCXWorkouts.swift
// CoreTCX
//
// Created by Vincent Neo on 15/10/19.
//
import Foundation
/*
public final class TCXWorkouts: NSObject, TCXElement {
var workout: [TCXWorkout]?
public init(workouts: [TCXWorkout]) {
self.workout = workouts
}
}
*/
// WorkoutList_t
extension Array: TCXPublicElement where Element : TCXWorkout {}
extension Array: TCXElement where Element : TCXWorkout {
func tagName() -> String {
return "Workouts"
}
func addChildTag(toTCX tcx: inout String, indentationLevel: Int) {
forEach { element in
element.tcxTagging(&tcx, indentationLevel: indentationLevel)
}
}
}
// Workout_t
public class TCXWorkout: NSObject, TCXElement {
enum sportType: String {
case running = "Running", biking = "Biking", other = "Other", undefined
}
func tagName() -> String {
return "Workout"
}
var sport: sportType
var name: String?
var step = [TCXAbstractStep]() // at least one
var scheduledOn: [Date]?
var notes: String?
//var creator: abstractsource
var extensions: TCXExtensions?
init(sport: sportType) {
self.sport = sport
}
func addChildTag(toTCX tcx: inout String, indentationLevel: Int) {
addProperty(forValue: 330, tcx: &tcx, tagName: "Test", indentationLevel: indentationLevel)
}
}
protocol TCXAbstract {
}
enum abs: TCXAbstract {
}
class TCXAbstractStep/*<type: abs>*/: TCXElement {
func tagName() -> String {
fatalError()
}
private var privateID = Int()
public var stepID: Int {
get {
return privateID
}
set {
if newValue > 0 && newValue <= 20 {
privateID = newValue
}
}
}
}