//
//  LCObjectsChangeManager.h
//  LogoistCore
//
//  Created by Mendel Kucharzeck on 04.08.12.
//  Copyright (c) 2012 AvisNocturna Software. All rights reserved.
//

#import "LCObjectsChangeManagerDelegateProtocol.h"

@class LCChangeManagerAwareObject;

@interface LCObjectsChangeManager : NSObject
{
    NSMutableArray *delegates;
    
    NSInteger changeDisableCount;
}

- (void) disableRecordingChanges;   //Stackable, will avoid propagation of changes (for example when initializing objects)
- (void) enableRecordingChanges;    //Stackable

//Changes (always call WILL AND DID)
- (void) object:(LCChangeManagerAwareObject*)object willChangeValueForKey:(NSString*)key fromValue:(id)fromValue;
- (void) object:(LCChangeManagerAwareObject*)object willAddObject:(id)addedObject toCollectionWithKey:(NSString*)key;
- (void) object:(LCChangeManagerAwareObject*)object willRemoveObject:(id)removeObject fromCollectionWithKey:(NSString*)key;
- (void) object:(LCChangeManagerAwareObject*)object willReplaceCollection:(id)oldArray withCollection:(id)newArray withKey:(NSString*)key;

- (void) object:(LCChangeManagerAwareObject*)object didChangeValueForKey:(NSString*)key toValue:(id)toValue;
- (void) object:(LCChangeManagerAwareObject*)object didAddObject:(id)addedObject toCollectionWithKey:(NSString*)key;
- (void) object:(LCChangeManagerAwareObject*)object didRemoveObject:(id)removeObject fromCollectionWithKey:(NSString*)key;
- (void) object:(LCChangeManagerAwareObject*)object didReplaceCollection:(id)oldArray withCollection:(id)newArray withKey:(NSString*)key;

//Delegates
- (void) addDelegate:(id <LCObjectsChangeManagerDelegateProtocol>)d;
- (void) removeDelegate:(id <LCObjectsChangeManagerDelegateProtocol>)d;

@end
