SDWebImageOptionsProcessor.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * This file is part of the SDWebImage package.
  3. * (c) Olivier Poitrey <rs@dailymotion.com>
  4. *
  5. * For the full copyright and license information, please view the LICENSE
  6. * file that was distributed with this source code.
  7. */
  8. #import <Foundation/Foundation.h>
  9. #import "SDWebImageCompat.h"
  10. #import "SDWebImageDefine.h"
  11. @class SDWebImageOptionsResult;
  12. typedef SDWebImageOptionsResult * _Nullable(^SDWebImageOptionsProcessorBlock)(NSURL * _Nullable url, SDWebImageOptions options, SDWebImageContext * _Nullable context);
  13. /**
  14. The options result contains both options and context.
  15. */
  16. @interface SDWebImageOptionsResult : NSObject
  17. /**
  18. WebCache options.
  19. */
  20. @property (nonatomic, assign, readonly) SDWebImageOptions options;
  21. /**
  22. Context options.
  23. */
  24. @property (nonatomic, copy, readonly, nullable) SDWebImageContext *context;
  25. /**
  26. Create a new options result.
  27. @param options options
  28. @param context context
  29. @return The options result contains both options and context.
  30. */
  31. - (nonnull instancetype)initWithOptions:(SDWebImageOptions)options context:(nullable SDWebImageContext *)context;
  32. - (nonnull instancetype)init NS_UNAVAILABLE;
  33. + (nonnull instancetype)new NS_UNAVAILABLE;
  34. @end
  35. /**
  36. This is the protocol for options processor.
  37. Options processor can be used, to control the final result for individual image request's `SDWebImageOptions` and `SDWebImageContext`
  38. Implements the protocol to have a global control for each indivadual image request's option.
  39. */
  40. @protocol SDWebImageOptionsProcessor <NSObject>
  41. /**
  42. Return the processed options result for specify image URL, with its options and context
  43. @param url The URL to the image
  44. @param options A mask to specify options to use for this request
  45. @param context A context contains different options to perform specify changes or processes, see `SDWebImageContextOption`. This hold the extra objects which `options` enum can not hold.
  46. @return The processed result, contains both options and context
  47. */
  48. - (nullable SDWebImageOptionsResult *)processedResultForURL:(nullable NSURL *)url
  49. options:(SDWebImageOptions)options
  50. context:(nullable SDWebImageContext *)context;
  51. @end
  52. /**
  53. A options processor class with block.
  54. */
  55. @interface SDWebImageOptionsProcessor : NSObject<SDWebImageOptionsProcessor>
  56. - (nonnull instancetype)initWithBlock:(nonnull SDWebImageOptionsProcessorBlock)block;
  57. + (nonnull instancetype)optionsProcessorWithBlock:(nonnull SDWebImageOptionsProcessorBlock)block;
  58. - (nonnull instancetype)init NS_UNAVAILABLE;
  59. + (nonnull instancetype)new NS_UNAVAILABLE;
  60. @end