<commit_before>#import <Foundation/Foundation.h>
#import <EtoileFoundation/EtoileFoundation.h>

@class COPersistentRootEditingContext;
@class COStore, CORevision, COObject, COGroup, COSmartGroup, COCommitTrack, COError;

@protocol COPersistentObjectContext <NSObject>
@end

/**
 * An editing context exposes a CoreObject store snapshot as a working copy 
 * (in revision control system terminology).
 *
 * It queues changes and when the user requests it, it attempts to commit them 
 * to the store.
 */
@interface COEditingContext : NSObject <COPersistentObjectContext>
{
	@private
	ETUUID *_uuid;
	COStore *_store;
	int64_t _maxRevisionNumber;
	int64_t _latestRevisionNumber;
	ETModelDescriptionRepository *_modelRepository;
	/** Persistent root contexts by UUID */
	NSMutableDictionary *_persistentRootContexts;
	COError *_error;
}

/** @taskunit Accessing the current context */

/** 
 * Returns the context that should be used when none is provided.
 *
 * Factories that create persistent instances in EtoileUI will use this method. 
 * As an example, see -[ETLayoutItemFactory compoundDocument]. 
 */
+ (COEditingContext *)currentContext;
/** 
 * Sets the context that should be used when none is provided.
 *
 * See also +currentContext. 
 */
+ (void)setCurrentContext: (COEditingContext *)aCtxt;

/** @taskunit Creating a new context */

/**
 * Returns a new autoreleased context initialized with the store located at the 
 * given URL, and with no upper limit on the max revision number.
 *
 * See also -initWithStore:maxRevisionNumber: and -[COStore initWithURL:].
 */
+ (COEditingContext *)contextWithURL: (NSURL *)aURL;

/**
 * Initializes a context which persists its content in the given store.
 */
- (id)initWithStore: (COStore *)store;

/**
 * <init />
 * Initializes a context which persists its content in the given store, 
 * fixing the maximum revision number that can be loaded of an object.
 *
 * If the store is nil, the context content is not persisted.
 *
 * If maxRevisionNumber is zero, then there is no upper limit on the revision 
 * that can be loaded.
 */
- (id)initWithStore: (COStore *)store maxRevisionNumber: (int64_t)maxRevisionNumber;
/**
 * Initializes the context with no store. 
 * As a result, the context content is not persisted.
 */
- (id)init;

/** @taskunit Special Groups and Libraries */

/**
 * Returns a group listing every core object in the store.
 */
- (COSmartGroup *)mainGroup;
/**
 * Returns a group listing the libraries in the store.
 */
- (COGroup *)libraryGroup;

/** @taskunit Store and Metamodel Access */

/**
 * Returns the store for which the editing context acts a working copy.
 */
- (COStore *)store;
/**
 * Returns the latest revision number which might be the same than the one 
 * returned by -[COStore latestRevisionNumber], when multiple editing contexts 
 * are accessing the store simultaneously.
 */
- (int64_t)latestRevisionNumber;
/**
 * Returns the maximun revision that can be loaded for objects in persistent 
 * roots.
 *
 * If the returned value is zero, there is no upper limit on the revision that
 * can be loaded.
 *
 * By default, returns zero. 
 */
- (int64_t)maxRevisionNumber;
/**
 * Returns the model description repository, which holds the metamodel that 
 * describes all the persistent objects editable in the context.
 */
- (ETModelDescriptionRepository *)modelRepository;
/**
 * Returns the class bound to the entity description in the model repository.
 */
- (Class)classForEntityDescription: (ETEntityDescription *)desc;


/** @taskunit Managing Persistent Roots */

- (COPersistentRootEditingContext *)contextForPersistentRootUUID: (ETUUID *)aUUID;
- (COPersistentRootEditingContext *)insertNewPersistentRootWithEntityName: (NSString *)anEntityName;
- (COPersistentRootEditingContext *)insertNewPersistentRootWithRootObject: (COObject *)aRootObject;
- (void)deletePersistentRootForRootObject: (COObject *)aRootObject;

/** @taskunit Object Access and Loading */

/** 
 * Returns the object identified by the UUID, by loading it to its last revision 
 * when no instance managed by the receiver is present in memory.
 *
 * When the UUID doesn't correspond to a persistent object, returns nil.
 *
 * When the object is a inner object, the last revision is the one that is tied  
 * to its root object last revision.
 *
 * See also -objectWithUUID:atRevision: and -loadedObjectForUUID:.
 */
- (COObject *)objectWithUUID: (ETUUID *)uuid;
/** <commit_msg>Fixed a warning on GNUstep<commit_after>#import <Foundation/Foundation.h>
#import <EtoileFoundation/EtoileFoundation.h>

@class COPersistentRootEditingContext;
@class COStore, CORevision, COObject, COGroup, COSmartGroup, COCommitTrack, COError;

@protocol COPersistentObjectContext <NSObject>
@end

/**
 * An editing context exposes a CoreObject store snapshot as a working copy 
 * (in revision control system terminology).
 *
 * It queues changes and when the user requests it, it attempts to commit them 
 * to the store.
 */
@interface COEditingContext : NSObject <COPersistentObjectContext>
{
	@private
	ETUUID *_uuid;
	COStore *_store;
	int64_t _maxRevisionNumber;
	int64_t _latestRevisionNumber;
	ETModelDescriptionRepository *_modelRepository;
	/** Persistent root contexts by UUID */
	NSMutableDictionary *_persistentRootContexts;
	COError *_error;
}

/** @taskunit Accessing the current context */

/** 
 * Returns the context that should be used when none is provided.
 *
 * Factories that create persistent instances in EtoileUI will use this method. 
 * As an example, see -[ETLayoutItemFactory compoundDocument]. 
 */
+ (COEditingContext *)currentContext;
/** 
 * Sets the context that should be used when none is provided.
 *
 * See also +currentContext. 
 */
+ (void)setCurrentContext: (COEditingContext *)aCtxt;

/** @taskunit Creating a new context */

/**
 * Returns a new autoreleased context initialized with the store located at the 
 * given URL, and with no upper limit on the max revision number.
 *
 * See also -initWithStore:maxRevisionNumber: and -[COStore initWithURL:].
 */
+ (COEditingContext *)contextWithURL: (NSURL *)aURL;

/**
 * Initializes a context which persists its content in the given store.
 */
- (id)initWithStore: (COStore *)store;

/**
 * <init />
 * Initializes a context which persists its content in the given store, 
 * fixing the maximum revision number that can be loaded of an object.
 *
 * If the store is nil, the context content is not persisted.
 *
 * If maxRevisionNumber is zero, then there is no upper limit on the revision 
 * that can be loaded.
 */
- (id)initWithStore: (COStore *)store maxRevisionNumber: (int64_t)maxRevisionNumber;
/**
 * Initializes the context with no store. 
 * As a result, the context content is not persisted.
 */
- (id)init;

/** @taskunit Special Groups and Libraries */

/**
 * Returns a group listing every core object in the store.
 */
- (COSmartGroup *)mainGroup;
/**
 * Returns a group listing the libraries in the store.
 */
- (COGroup *)libraryGroup;

/** @taskunit Store and Metamodel Access */

/**
 * Returns the store for which the editing context acts a working copy.
 */
- (COStore *)store;
/**
 * Returns the latest revision number which might be the same than the one 
 * returned by -[COStore latestRevisionNumber], when multiple editing contexts 
 * are accessing the store simultaneously.
 */
- (int64_t)latestRevisionNumber;
/**
 * Returns the maximun revision that can be loaded for objects in persistent 
 * roots.
 *
 * If the returned value is zero, there is no upper limit on the revision that
 * can be loaded.
 *
 * By default, returns zero. 
 */
- (int64_t)maxRevisionNumber;
/**
 * Returns the model description repository, which holds the metamodel that 
 * describes all the persistent objects editable in the context.
 */
- (ETModelDescriptionRepository *)modelRepository;

/** @taskunit Managing Persistent Roots */

- (COPersistentRootEditingContext *)contextForPersistentRootUUID: (ETUUID *)aUUID;
- (COPersistentRootEditingContext *)insertNewPersistentRootWithEntityName: (NSString *)anEntityName;
- (COPersistentRootEditingContext *)insertNewPersistentRootWithRootObject: (COObject *)aRootObject;
- (void)deletePersistentRootForRootObject: (COObject *)aRootObject;

/** @taskunit Object Access and Loading */

/** 
 * Returns the object identified by the UUID, by loading it to its last revision 
 * when no instance managed by the receiver is present in memory.
 *
 * When the UUID doesn't correspond to a persistent object, returns nil.
 *
 * When the object is a inner object, the last revision is the one that is tied  
 * to its root object last revision.
 *
 * See also -objectWithUUID:atRevision: and -loadedObjectForUUID:.
 */
- (COObject *)objectWithUUID: (ETUUID *)uuid;
/** 
{'fraction_non_alphanumeric': 0.09165620362972264, 'fraction_numerical': 0.002282844424152494, 'mean_word_length': 4.392, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '4373967', 'n_tokens_mistral': 2502, 'n_tokens_neox': 2394, 'n_words': 971}