Skip to content

Commit

Permalink
Issue #108: Added generics annotations to MIKMIDIDeviceManager, MIKMI…
Browse files Browse the repository at this point in the history
…DIDevice, and MIKMIDIEntity.
  • Loading branch information
Andrew Madsen committed Nov 4, 2015
1 parent 234ce47 commit ce917ee
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 12 deletions.
10 changes: 7 additions & 3 deletions Source/MIKMIDIDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
//

#import "MIKMIDIObject.h"
#import "MIKMIDIUtilities.h"

@class MIKMIDIEntity;
@class MIKMIDIEndpoint;

/**
* MIKMIDIDevice represents a MIDI device such as a DJ controller, MIDI piano keyboard, etc.
Expand Down Expand Up @@ -84,7 +88,7 @@
*
* @return An initialized MIKMIDIDevice instance.
*/
+ (instancetype)deviceWithVirtualEndpoints:(NSArray *)endpoints;
+ (instancetype)deviceWithVirtualEndpoints:(MIKArrayOf(MIKMIDIEndpoint *) *)endpoints;

/**
* Creates and initializes a "virtual" MIKMIDIDevice instance from one or more virtual endpoints.
Expand All @@ -104,7 +108,7 @@
*
* @return An initialized MIKMIDIDevice instance.
*/
- (instancetype)initWithVirtualEndpoints:(NSArray *)endpoints;
- (instancetype)initWithVirtualEndpoints:(MIKArrayOf(MIKMIDIEndpoint *) *)endpoints;

/**
* The manufacturer of the MIDI device.
Expand All @@ -121,6 +125,6 @@
* receiver. Entities contain logically related source and destination endpoints. Often
* a device will only have one entity.
*/
@property (nonatomic, strong, readonly) NSArray *entities;
@property (nonatomic, strong, readonly) MIKArrayOf(MIKMIDIEntity *) *entities;

@end
4 changes: 3 additions & 1 deletion Source/MIKMIDIDevice.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#import "MIKMIDIDevice.h"
#import "MIKMIDIObject_SubclassMethods.h"
#import "MIKMIDIEntity.h"
#import "MIKMIDISourceEndpoint.h"
#import "MIKMIDIDestinationEndpoint.h"
#import "MIKMIDIUtilities.h"

#if !__has_feature(objc_arc)
Expand Down Expand Up @@ -123,7 +125,7 @@ - (MIDIObjectRef)objectRef
{
if (self.isVirtual) {
MIKMIDIEntity *entity = [self.entities firstObject];
MIKMIDIObject *endpoint = [entity.sources count] ? [entity.sources firstObject] : [entity.destinations firstObject];
MIKMIDIEndpoint *endpoint = [entity.sources count] ? [entity.sources firstObject] : [entity.destinations firstObject];
return endpoint.objectRef;
}
return [super objectRef];
Expand Down
10 changes: 6 additions & 4 deletions Source/MIKMIDIDeviceManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@

#import <Foundation/Foundation.h>
#import "MIKMIDIInputPort.h"
#import "MIKMIDIUtilities.h"

@class MIKMIDIDevice;
@class MIKMIDISourceEndpoint;
@class MIKMIDIClientSourceEndpoint;
@class MIKMIDIDestinationEndpoint;
Expand Down Expand Up @@ -130,7 +132,7 @@ extern NSString * const MIKMIDIEndpointKey;
* @see MIKMIDIDeviceWasAddedNotification
* @see MIKMIDIDeviceWasRemovedNotification
*/
@property (nonatomic, readonly) NSArray *availableDevices;
@property (nonatomic, readonly) MIKArrayOf(MIKMIDIDevice *) *availableDevices;

/**
* An NSArray containing MIKMIDISourceEndpoint instances representing virtual MIDI sources (inputs) on the system.
Expand All @@ -142,7 +144,7 @@ extern NSString * const MIKMIDIEndpointKey;
* @see MIKMIDIVirtualEndpointWasAddedNotification
* @see MIKMIDIVirtualEndpointWasRemovedNotification
*/
@property (nonatomic, readonly) NSArray *virtualSources;
@property (nonatomic, readonly) MIKArrayOf(MIKMIDISourceEndpoint *) *virtualSources;

/**
* An NSArray containing MIKMIDIDestinationEndpoint instances representing virtual
Expand All @@ -155,12 +157,12 @@ extern NSString * const MIKMIDIEndpointKey;
* @see MIKMIDIVirtualEndpointWasAddedNotification
* @see MIKMIDIVirtualEndpointWasRemovedNotification
*/
@property (nonatomic, readonly) NSArray *virtualDestinations; // Array of MIKMIDIDestinationEndpoints
@property (nonatomic, readonly) MIKArrayOf(MIKMIDIDestinationEndpoint *) *virtualDestinations;


/**
* An NSArray of MIKMIDISourceEndpoint instances that are connected to at least one event handler.
*/
@property (nonatomic, readonly) NSArray *connectedInputSources; // Array of MIKMIDISourceEndpoints
@property (nonatomic, readonly) MIKArrayOf(MIKMIDISourceEndpoint *) *connectedInputSources;

@end
12 changes: 8 additions & 4 deletions Source/MIKMIDIEntity.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,12 @@
//

#import "MIKMIDIObject.h"
#import "MIKMIDIUtilities.h"

@class MIKMIDIDevice;
@class MIKMIDIEndpoint;
@class MIKMIDISourceEndpoint;
@class MIKMIDIDestinationEndpoint;

/**
* MIKMIDIEntity represents a logical grouping of endpoints within a MIDI device. It essentially
Expand All @@ -30,7 +34,7 @@
*
* @see +[MIKMIDIDevice deviceWithVirtualEndpoints:]
*/
+ (instancetype)entityWithVirtualEndpoints:(NSArray *)endpoints;
+ (instancetype)entityWithVirtualEndpoints:(MIKArrayOf(MIKMIDIEndpoint *) *)endpoints;

/**
* Creates and initializes a "virtual" MIKMIDIEntity instance from one or more virtual endpoints.
Expand All @@ -43,7 +47,7 @@
*
* @see -[MIKMIDIDevice initWithVirtualEndpoints:]
*/
- (instancetype)initWithVirtualEndpoints:(NSArray *)endpoints;
- (instancetype)initWithVirtualEndpoints:(MIKArrayOf(MIKMIDIEndpoint *) *)endpoints;

/**
* The device that contains the receiver. May be nil if the receiver is a virtual entity not contained
Expand All @@ -55,12 +59,12 @@
* The source (input) endpoints contained by the receiver.
* An array of MIKMIDISourceEndpoint instances.
*/
@property (nonatomic, readonly) NSArray *sources;
@property (nonatomic, readonly) MIKArrayOf(MIKMIDISourceEndpoint *) *sources;

/**
* The destination (output) endpoints contained by the receiver.
* An array of MIKMIDIDestinationEndpoint instances.
*/
@property (nonatomic, readonly) NSArray *destinations;
@property (nonatomic, readonly) MIKArrayOf(MIKMIDIDestinationEndpoint *) *destinations;

@end
9 changes: 9 additions & 0 deletions Source/MIKMIDIUtilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,14 @@
#import "MIKMIDIMappableResponder.h"
#import "MIKMIDICommand.h"

#ifndef MIKArrayOf
#if __has_feature(objc_generics)
#define MIKArrayOf(TYPE) NSArray<TYPE>
#else
#define MIKArrayOf(TYPE) NSArray
#endif
#endif // #ifndef MIKArrayOf

NSString *MIKStringPropertyFromMIDIObject(MIDIObjectRef object, CFStringRef propertyID, NSError *__autoreleasing*error);
BOOL MIKSetStringPropertyOnMIDIObject(MIDIObjectRef object, CFStringRef propertyID, NSString *string, NSError *__autoreleasing*error);

Expand Down Expand Up @@ -57,3 +65,4 @@ NSString *MIKMIDINoteLetterForMIDINoteNumber(UInt8 noteNumber);
*/
NSString *MIKMIDINoteLetterAndOctaveForMIDINote(UInt8 noteNumber);


0 comments on commit ce917ee

Please sign in to comment.