/*
 * This file is part of the YSSDWebImage package.
 * (c) Olivier Poitrey <rs@dailymotion.com>
 *
 * For the full copyright and license information, please view the LICENSE
 * file that was distributed with this source code.
 */

#import <Foundation/Foundation.h>
#import "YSSDWebImageCompat.h"
#import "YSSDWebImageDefine.h"

@class YSSDWebImageOptionsResult;

typedef YSSDWebImageOptionsResult * _Nullable(^YSSDWebImageOptionsProcessorBlock)(NSURL * _Nullable url, YSSDWebImageOptions options, YSSDWebImageContext * _Nullable context);

/**
 The options result contains both options and context.
 */
@interface YSSDWebImageOptionsResult : NSObject

/**
 WebCache options.
 */
@property (nonatomic, assign, readonly) YSSDWebImageOptions options;

/**
 Context options.
 */
@property (nonatomic, copy, readonly, nullable) YSSDWebImageContext *context;

/**
 Create a new options result.

 @param options options
 @param context context
 @return The options result contains both options and context.
 */
- (nonnull instancetype)initWithOptions:(YSSDWebImageOptions)options context:(nullable YSSDWebImageContext *)context;

@end

/**
 This is the protocol for options processor.
 Options processor can be used, to control the final result for individual image request's `YSSDWebImageOptions` and `YSSDWebImageContext`
 Implements the protocol to have a global control for each indivadual image request's option.
 */
@protocol YSSDWebImageOptionsProcessor <NSObject>

/**
 Return the processed options result for specify image URL, with its options and context

 @param url The URL to the image
 @param options A mask to specify options to use for this request
 @param context A context contains different options to perform specify changes or processes, see `YSSDWebImageContextOption`. This hold the extra objects which `options` enum can not hold.
 @return The processed result, contains both options and context
 */
- (nullable YSSDWebImageOptionsResult *)processedResultForURL:(nullable NSURL *)url
                                                    options:(YSSDWebImageOptions)options
                                                    context:(nullable YSSDWebImageContext *)context;

@end

/**
 A options processor class with block.
 */
@interface YSSDWebImageOptionsProcessor : NSObject<YSSDWebImageOptionsProcessor>

- (nonnull instancetype)initWithBlock:(nonnull YSSDWebImageOptionsProcessorBlock)block;
+ (nonnull instancetype)optionsProcessorWithBlock:(nonnull YSSDWebImageOptionsProcessorBlock)block;

@end
