Skip to content

Commit

Permalink
rename public classes
Browse files Browse the repository at this point in the history
  • Loading branch information
kosyloa committed Sep 4, 2023
1 parent 5aa6b28 commit e0a53d6
Show file tree
Hide file tree
Showing 20 changed files with 143 additions and 145 deletions.
64 changes: 32 additions & 32 deletions DXFeedFramework.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions DXFeedFramework/Api/Osub/Symbol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ public protocol Symbol {

extension Symbol {
public var stringValue: String {
#warning("TODO: implement it")
return "empty description for \(type(of: self)). please change"
fatalError("Symbol.stringValue has not been implemented")
}
}
11 changes: 10 additions & 1 deletion DXFeedFramework/Api/Osub/TimeSeriesSubscriptionSymbol.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,20 @@ public class TimeSeriesSubscriptionSymbol: IndexedEventSubscriptionSymbol<AnyHas
}

convenience public init(symbol: AnyHashable, date: Date) {

self.init(symbol: symbol, fromTime: Long(date.timeIntervalSince1970) * 1000)
}

static func == (lhs: TimeSeriesSubscriptionSymbol, rhs: TimeSeriesSubscriptionSymbol) -> Bool {
return lhs === rhs || lhs.symbol == rhs.symbol
}

public var stringValue: String {
return "\(symbol){fromTime=\(TimeUtil.toLocalDateString(millis: fromTime))}"
}
}

extension TimeSeriesSubscriptionSymbol: CustomStringConvertible {
public var description: String {
return stringValue
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public class CandlePriceLevel {
}

static func getAttribute(_ symbol: String?) throws -> CandlePriceLevel {
var attribute = try MarketEventSymbols.getAttributeStringByKey(symbol, attributeKey)
let attribute = try MarketEventSymbols.getAttributeStringByKey(symbol, attributeKey)
guard let attribute = attribute else {
return defaultCandlePriceLevel!
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//
// InstrumentProfileReader.swift
// DXInstrumentProfileReader.swift
// DXFeedFramework
//
// Created by Aleksey Kosylo on 29.08.23.
//

import Foundation

public class InstrumentProfileReader {
public class DXInstrumentProfileReader {
private lazy var native: NativeInstrumentProfileReader? = {
try? NativeInstrumentProfileReader()
}()
Expand Down
4 changes: 4 additions & 0 deletions DXFeedFramework/Ipf/InstrumentProfileField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ public enum InstrumentProfileField: String, CaseIterable {
return map[name]
}

// swiftlint:disable function_body_length
public func getField(instrumentProfile: InstrumentProfile) -> String {
switch self {
case .type:
Expand Down Expand Up @@ -215,6 +216,7 @@ public enum InstrumentProfileField: String, CaseIterable {
instrumentProfile.tradingHours = value
}
}
// swiftlint:enable function_body_length

public func isNumericField() -> Bool {
return InstrumentProfileField.numericFields.contains(self)
Expand Down Expand Up @@ -247,7 +249,9 @@ public enum InstrumentProfileField: String, CaseIterable {
throw ArgumentException.illegalArgumentException
}
}
}

extension InstrumentProfileField {
public static func parseDate(_ value: String) -> Long {
if value.isEmpty {
return 0
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//
// InstrumentProfileCollector.swift
// DXInstrumentProfileCollector.swift
// DXFeedFramework
//
// Created by Aleksey Kosylo on 29.08.23.
//

import Foundation

public class InstrumentProfileCollector {
public class DXInstrumentProfileCollector {
private let listeners = ConcurrentSet<AnyHashable>()
let native: NativeInstrumentProfileCollector

Expand All @@ -16,7 +16,7 @@ public class InstrumentProfileCollector {
}

public func add<O>(_ observer: O) throws
where O: InstrumentProfileUpdateListener,
where O: DXInstrumentProfileUpdateListener,
O: Hashable {
try listeners.reader { [weak self] in
if $0.isEmpty {
Expand All @@ -27,7 +27,7 @@ public class InstrumentProfileCollector {
}

public func remove<O>(_ observer: O)
where O: InstrumentProfileUpdateListener,
where O: DXInstrumentProfileUpdateListener,
O: Hashable {
listeners.remove(observer)
}
Expand All @@ -40,9 +40,9 @@ public class InstrumentProfileCollector {
try native.updateInstrumentProfile(profile: profile)
}

public func view() throws -> ProfileIterator {
public func view() throws -> DXProfileIterator {
let iterator = try native.view()
return ProfileIterator(iterator)
return DXProfileIterator(iterator)
}

public func createOnConcurrentLinkedQueue() throws -> Bool {
Expand All @@ -65,11 +65,11 @@ public class InstrumentProfileCollector {
}
}

extension InstrumentProfileCollector: InstrumentProfileUpdateListener {
extension DXInstrumentProfileCollector: DXInstrumentProfileUpdateListener {
public func instrumentProfilesUpdated(_ instruments: [InstrumentProfile]) {
listeners.reader { items in
items.compactMap {
$0 as? InstrumentProfileUpdateListener
$0 as? DXInstrumentProfileUpdateListener
}.forEach { $0.instrumentProfilesUpdated(instruments) }
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
//
// InstrumentProfileConnection.swift
// DXInstrumentProfileConnection.swift
// DXFeedFramework
//
// Created by Aleksey Kosylo on 29.08.23.
//

import Foundation

public class InstrumentProfileConnection {
public class DXInstrumentProfileConnection {
private let native: NativeInstrumentProfileConnection
private let collector: InstrumentProfileCollector
private let collector: DXInstrumentProfileCollector

private var observersSet = ConcurrentSet<AnyHashable>()
private var observers: [InstrumentProfileConnectionObserver] {
return observersSet.reader { $0.compactMap { value in value as? InstrumentProfileConnectionObserver } }
private var observers: [DXInstrumentProfileConnectionObserver] {
return observersSet.reader { $0.compactMap { value in value as? DXInstrumentProfileConnectionObserver } }
}

public init(_ address: String, _ collector: InstrumentProfileCollector) throws {
public init(_ address: String, _ collector: DXInstrumentProfileCollector) throws {
self.collector = collector
native = try NativeInstrumentProfileConnection(collector.native, address)
try native.addListener(self)
Expand Down Expand Up @@ -47,21 +47,21 @@ public class InstrumentProfileConnection {
}

public func add<O>(_ observer: O)
where O: InstrumentProfileConnectionObserver,
where O: DXInstrumentProfileConnectionObserver,
O: Hashable {
observersSet.insert(observer)
}

public func remove<O>(_ observer: O)
where O: InstrumentProfileConnectionObserver,
where O: DXInstrumentProfileConnectionObserver,
O: Hashable {
observersSet.remove(observer)
}

}

extension InstrumentProfileConnection: NativeIPFConnectionListener {
func connectionDidChangeState(old: InstrumentProfileConnectionState, new: InstrumentProfileConnectionState) {
extension DXInstrumentProfileConnection: NativeIPFConnectionListener {
func connectionDidChangeState(old: DXInstrumentProfileConnectionState, new: DXInstrumentProfileConnectionState) {
observers.forEach { $0.connectionDidChangeState(old: old, new: new) }
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
//
// DXInstrumentProfileConnectionObserver.swift
// DXFeedFramework
//
// Created by Aleksey Kosylo on 01.09.23.
//

import Foundation

public protocol DXInstrumentProfileConnectionObserver {
func connectionDidChangeState(old: DXInstrumentProfileConnectionState, new: DXInstrumentProfileConnectionState)
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//
// InstrumentProfileConnectionState.swift
// DXInstrumentProfileConnectionState.swift
// DXFeedFramework
//
// Created by Aleksey Kosylo on 01.09.23.
//

import Foundation

public enum InstrumentProfileConnectionState {
public enum DXInstrumentProfileConnectionState {
case notConnected
case connecting
case connected
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
//
// InstrumentProfileUpdateListener.swift
// DXInstrumentProfileUpdateListener.swift
// DXFeedFramework
//
// Created by Aleksey Kosylo on 01.09.23.
//

import Foundation

public protocol InstrumentProfileUpdateListener: AnyObject {
public protocol DXInstrumentProfileUpdateListener: AnyObject {
func instrumentProfilesUpdated(_ instruments: [InstrumentProfile])
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//
// ProfileIterator.swift
// DXProfileIterator.swift
// DXFeedFramework
//
// Created by Aleksey Kosylo on 01.09.23.
//

import Foundation

public class ProfileIterator {
public class DXProfileIterator {
private let native: NativeProfileIterator

init(_ native: NativeProfileIterator) {
Expand Down
12 changes: 0 additions & 12 deletions DXFeedFramework/Ipf/Live/InstrumentProfileConnectionObserver.swift

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
import Foundation
@_implementationOnly import graal_api

extension InstrumentProfileConnectionState {
static func convert(_ state: dxfg_ipf_connection_state_t) -> InstrumentProfileConnectionState? {
extension DXInstrumentProfileConnectionState {
static func convert(_ state: dxfg_ipf_connection_state_t) -> DXInstrumentProfileConnectionState? {
switch state {
case DXFG_IPF_CONNECTION_STATE_NOT_CONNECTED:
return .notConnected
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@
import Foundation

protocol NativeIPFConnectionListener: AnyObject {
func connectionDidChangeState(old: InstrumentProfileConnectionState, new: InstrumentProfileConnectionState)
func connectionDidChangeState(old: DXInstrumentProfileConnectionState, new: DXInstrumentProfileConnectionState)
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class NativeInstrumentProfileCollector {
let collector: UnsafeMutablePointer<dxfg_ipf_collector_t>?
private var nativeListener: UnsafeMutablePointer<dxfg_ipf_update_listener_t>?

private weak var listener: InstrumentProfileUpdateListener?
private weak var listener: DXInstrumentProfileUpdateListener?
private static let mapper = InstrumentProfileMapper()

static let listenerCallback: dxfg_ipf_update_listener_function = {_, nativeProfiles, context in
Expand Down Expand Up @@ -110,7 +110,7 @@ class NativeInstrumentProfileCollector {
return NativeExecutor(executor: native)
}

func addListener(_ listener: InstrumentProfileUpdateListener?) throws {
func addListener(_ listener: DXInstrumentProfileUpdateListener?) throws {
removeListener()
let thread = currentThread()
self.listener = listener
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ class NativeInstrumentProfileConnection {
if let context = context {
let endpoint: AnyObject = bridge(ptr: context)
if let listener = endpoint as? NativeInstrumentProfileConnection {
var old = (try? EnumUtil.valueOf(value: InstrumentProfileConnectionState.convert(oldState)))
var new = (try? EnumUtil.valueOf(value: InstrumentProfileConnectionState.convert(newState)))
var old = (try? EnumUtil.valueOf(value: DXInstrumentProfileConnectionState.convert(oldState)))
var new = (try? EnumUtil.valueOf(value: DXInstrumentProfileConnectionState.convert(newState)))
listener.listener?.connectionDidChangeState(old: old ?? .notConnected,
new: new ?? .notConnected)
}
Expand Down Expand Up @@ -86,18 +86,18 @@ class NativeInstrumentProfileConnection {
value))
}

private func getState() throws -> InstrumentProfileConnectionState {
let thread = currentThread()
private func getState() throws -> DXInstrumentProfileConnectionState {
#warning("TODO: Check undefined symbol for dxfg_InstrumentProfileConnection_getState")

// let thread = currentThread()
// let result = try ErrorCheck.nativeCall(thread,
// dxfg_InstrumentProfileConnection_getState(
// thread,
// connection))
// if let state = InstrumentProfileConnectionState.convert(result) {
// return state
// }
return InstrumentProfileConnectionState.notConnected
return DXInstrumentProfileConnectionState.notConnected
}

func getLastModified() -> Long {
Expand Down
11 changes: 0 additions & 11 deletions DXFeedFrameworkTests/DXFeedFrameworkTests.xctestplan
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,6 @@
"testTargets" : [
{
"parallelizable" : true,
"skippedTests" : [
"CandleTests",
"EndpointPublisherTest",
"EndpointTest",
"EventsTest",
"FeedTest",
"IsolateTest",
"SystemPropertyTest",
"ThreadsTest",
"UtilsTest"
],
"target" : {
"containerPath" : "container:DXFeedFramework.xcodeproj",
"identifier" : "803BAC1429BFA50700FFAB1C",
Expand Down
3 changes: 2 additions & 1 deletion DXFeedFrameworkTests/FeedTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ final class FeedTest: XCTestCase {
fromTime: 0) as Any) as? Symbol, "String is not a symbol")

let symbol1 = try CandleSymbol(symbol: "test")
print(TimeSeriesSubscriptionSymbol(symbol: symbol1, fromTime: 0).stringValue)
let testString = TimeSeriesSubscriptionSymbol(symbol: symbol1, fromTime: 10).stringValue
print(testString)
}

func testFeedCreateMultipleSubscriptionWithSymbol() throws {
Expand Down
Loading

0 comments on commit e0a53d6

Please sign in to comment.