<commit_before>//
//  SVRemoteResource.h
//  SVNetworking
//
//  Created by <NAME> on 3/14/14.
//  Copyright (c) 2014 Svpply. All rights reserved.
//

#import "SVDataRequest.h"
#import "SVRemoteResourceDiskCache.h"

typedef enum {
    SVRemoteResourceStateNotLoaded,
    SVRemoteResourceStateLoading,
    SVRemoteResourceStateError,
    SVRemoteResourceStateFinished
} SVRemoteResourceState;

/**
 SVRemoteResource is an abstract class to load resources from a remote source, typically over the network.
 
 Instances are uniqued by class and a key string (which is hashed, so that it can be safely used as a filename
 for disk caches). A remote resource that is unloaded or has failed to load can be instructed to load itself by
 sending the -load message. Subclasses provide various properties that will be set on a successful load, the
 -error property of the base class is used to communicate failure. The -state property will automatically update
 as the loading process begins, completes, or fails.
 
 Consumers of the class should use KVO or bindings to observe changes.
 
 This class does not provide any actual networking support (as the network is an implementation detail of subclasses,
 and this class could easily be adapated to various non-network uses (loading a large resource from disk asynchronously,
 for example). Abstract network implementations are provided for raw data and JSON by SVRemoteDataResource and
 SVRemoteJSONResource respectively. SVRemoteImage, a subclass of SVRemoteDataResource, provides an image loader
 implementation.
 */
@interface SVRemoteResource : NSObject

#pragma mark - Unique Resources
/** @name Unique Resources */

/**
 Retrieves a cached remote resource with the given unique key, if one exists. Otherwise, returns nil.
 
 Subclasses should provide their own accessors, as unique key generation for each remote resource subclass should be an
 implementation detail of that class, and not externally visible.
 <commit_msg>Notes on uniquing and mutability.<commit_after>//
//  SVRemoteResource.h
//  SVNetworking
//
//  Created by <NAME> on 3/14/14.
//  Copyright (c) 2014 Svpply. All rights reserved.
//

#import "SVDataRequest.h"
#import "SVRemoteResourceDiskCache.h"

typedef enum {
    SVRemoteResourceStateNotLoaded,
    SVRemoteResourceStateLoading,
    SVRemoteResourceStateError,
    SVRemoteResourceStateFinished
} SVRemoteResourceState;

/**
 SVRemoteResource is an abstract class to load resources from a remote source, typically over the network.
 
 Instances are uniqued by class and a key string (which is hashed, so that it can be safely used as a filename
 for disk caches). A remote resource that is unloaded or has failed to load can be instructed to load itself by
 sending the -load message. Subclasses provide various properties that will be set on a successful load, the
 -error property of the base class is used to communicate failure. The -state property will automatically update
 as the loading process begins, completes, or fails.
 
 Strictly speaking, uniquing is entirely optional. However, SVNetworking encourages it, and the built-in resource
 subclasses are only accessible via uniqued instances. Despite this, remote resource subclasses are free to have mutable
 properties or public instance initializers. This is discouraged, especially mutability.
 
 Consumers of the class should use KVO or bindings to observe changes.
 
 This class does not provide any actual networking support (as the network is an implementation detail of subclasses,
 and this class could easily be adapated to various non-network uses (loading a large resource from disk asynchronously,
 for example). Abstract network implementations are provided for raw data and JSON by SVRemoteDataResource and
 SVRemoteJSONResource respectively. SVRemoteImage, a subclass of SVRemoteDataResource, provides an image loader
 implementation.
 */
@interface SVRemoteResource : NSObject

#pragma mark - Unique Resources
/** @name Unique Resources */

/**
 Retrieves a cached remote resource with the given unique key, if one exists. Otherwise, returns nil.
 
 Subclasses should provide their own accessors, as unique key generation for each remote resource subclass should be an
 implementation detail of that class, and not externally visible.
 
{'fraction_non_alphanumeric': 0.04592074592074592, 'fraction_numerical': 0.004195804195804196, 'mean_word_length': 4.466242038216561, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '359910', 'n_tokens_mistral': 1045, 'n_tokens_neox': 984, 'n_words': 555}