-
Notifications
You must be signed in to change notification settings - Fork 269
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Jasper Blues
committed
May 4, 2014
1 parent
3a671e6
commit 95e1e36
Showing
17 changed files
with
3,097 additions
and
2,963 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
6fa80823ca08f6395fe1425c7a51cb2b34f0af68 | ||
ca6c5b5f89574fddb52d98775eb6d4ff4498b912 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
Source/Configuration/TyphoonAbstractDetachableComponentFactoryPostProcessor.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
//////////////////////////////////////////////////////////////////////////////// | ||
// | ||
// Copyright 2014 ibipit | ||
// All Rights Reserved. | ||
// | ||
// NOTICE: This software is the proprietary information of ibipit | ||
// Use is subject to license terms. | ||
// | ||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
|
||
|
||
#import <Foundation/Foundation.h> | ||
#import "TyphoonComponentFactoryPostProcessor.h" | ||
|
||
|
||
@interface TyphoonAbstractDetachableComponentFactoryPostProcessor : NSObject <TyphoonComponentFactoryPostProcessor> | ||
{ | ||
TyphoonComponentFactory* _factory; | ||
NSMutableArray *_rollbackDefinitions; | ||
} | ||
|
||
@property(nonatomic, strong, readonly) NSArray *rollbackDefinitions; | ||
|
||
/** | ||
Restores a component factory back to its initial state after post processing. | ||
*/ | ||
- (void)rollback; | ||
|
||
@end |
60 changes: 60 additions & 0 deletions
60
Source/Configuration/TyphoonAbstractDetachableComponentFactoryPostProcessor.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
//////////////////////////////////////////////////////////////////////////////// | ||
// | ||
// Copyright 2014 ibipit | ||
// All Rights Reserved. | ||
// | ||
// NOTICE: This software is the proprietary information of ibipit | ||
// Use is subject to license terms. | ||
// | ||
//////////////////////////////////////////////////////////////////////////////// | ||
|
||
|
||
|
||
#import "TyphoonAbstractDetachableComponentFactoryPostProcessor.h" | ||
#import "TyphoonComponentFactory.h" | ||
#import "TyphoonDefinition.h" | ||
|
||
@implementation TyphoonComponentFactory (DetachableComponentFactoryPostProcessor) | ||
|
||
- (void)setRegistry:(NSMutableArray *)registry | ||
{ | ||
_registry = registry; | ||
} | ||
|
||
@end | ||
|
||
|
||
@implementation TyphoonAbstractDetachableComponentFactoryPostProcessor | ||
|
||
- (void)postProcessComponentFactory:(TyphoonComponentFactory *)factory | ||
{ | ||
_factory = factory; | ||
[self cacheDefinitionsIn:_factory]; | ||
} | ||
|
||
- (void)rollback | ||
{ | ||
NSMutableArray *postProcessors = (NSMutableArray *) _factory.factoryPostProcessors; | ||
if (!postProcessors.lastObject == self) { | ||
[NSException raise:@"Only the last TyphoonAbstractDetachableComponentFactoryPostProcessor can be rolled-back" | ||
format:NSInternalInconsistencyException]; | ||
} | ||
[postProcessors removeLastObject]; | ||
_factory.registry = _rollbackDefinitions; | ||
[_factory unload]; | ||
} | ||
|
||
/* ====================================================================================================================================== */ | ||
#pragma mark - Private Methods | ||
|
||
- (void)cacheDefinitionsIn:(TyphoonComponentFactory *)factory | ||
{ | ||
NSMutableArray *definitions = [[NSMutableArray alloc] init]; | ||
for (TyphoonDefinition *definition in factory.registry) { | ||
[definitions addObject:[definition copy]]; | ||
} | ||
_rollbackDefinitions = [definitions mutableCopy]; | ||
} | ||
|
||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.