FLEXProtocolBuilder.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. //
  2. // FLEXProtocolBuilder.h
  3. // FLEX
  4. //
  5. // Derived from MirrorKit.
  6. // Created by Tanner on 7/4/15.
  7. // Copyright (c) 2015 Tanner Bennett. All rights reserved.
  8. //
  9. #import <Foundation/Foundation.h>
  10. @class FLEXProperty, FLEXProtocol, Protocol;
  11. @interface FLEXProtocolBuilder : NSObject
  12. /// Begins to construct a new protocol with the given name.
  13. /// @discussion You must register the protocol with the
  14. /// \c registerProtocol method before you can use it.
  15. + (instancetype)allocateProtocol:(NSString *)name;
  16. /// Adds a property to a protocol.
  17. /// @param property The property to add.
  18. /// @param isRequired Whether the property is required to implement the protocol.
  19. - (void)addProperty:(FLEXProperty *)property isRequired:(BOOL)isRequired;
  20. /// Adds a property to a protocol.
  21. /// @param selector The selector of the method to add.
  22. /// @param typeEncoding The type encoding of the method to add.
  23. /// @param isRequired Whether the method is required to implement the protocol.
  24. /// @param isInstanceMethod \c YES if the method is an instance method, \c NO if it is a class method.
  25. - (void)addMethod:(SEL)selector
  26. typeEncoding:(NSString *)typeEncoding
  27. isRequired:(BOOL)isRequired
  28. isInstanceMethod:(BOOL)isInstanceMethod;
  29. /// Makes the recieving protocol conform to the given protocol.
  30. - (void)addProtocol:(Protocol *)protocol;
  31. /// Registers and returns the recieving protocol, which was previously under construction.
  32. - (FLEXProtocol *)registerProtocol;
  33. /// Whether the protocol is still under construction or already registered.
  34. @property (nonatomic, readonly) BOOL isRegistered;
  35. @end