2014 snapchat source code
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

75 lines
1.4 KiB

  1. //
  2. // SCCaptureConfiguration.m
  3. // Snapchat
  4. //
  5. // Created by Lin Jia on 10/3/17.
  6. //
  7. //
  8. #import "SCCaptureConfiguration.h"
  9. #import "SCCaptureConfiguration_Private.h"
  10. #import <SCFoundation/SCAppEnvironment.h>
  11. #import <SCFoundation/SCAssertWrapper.h>
  12. @interface SCCaptureConfiguration () {
  13. BOOL _sealed;
  14. NSMutableSet<SCCaptureConfigurationDirtyKey *> *_dirtyKeys;
  15. }
  16. @end
  17. @implementation SCCaptureConfiguration
  18. - (instancetype)init
  19. {
  20. self = [super init];
  21. if (self) {
  22. _dirtyKeys = [[NSMutableSet<SCCaptureConfigurationDirtyKey *> alloc] init];
  23. _sealed = NO;
  24. }
  25. return self;
  26. }
  27. - (void)setIsRunning:(BOOL)running
  28. {
  29. if ([self _configurationSealed]) {
  30. return;
  31. }
  32. _isRunning = running;
  33. [_dirtyKeys addObject:@(SCCaptureConfigurationKeyIsRunning)];
  34. }
  35. /*
  36. All set methods will be added later. They follow the format of setIsRunning.
  37. */
  38. @end
  39. @implementation SCCaptureConfiguration (privateMethods)
  40. - (NSArray *)dirtyKeys
  41. {
  42. if (!_sealed && SCIsDebugBuild()) {
  43. SCAssert(NO, @"Configuration not sealed yet, setting is still happening!");
  44. }
  45. return [_dirtyKeys allObjects];
  46. }
  47. - (void)seal
  48. {
  49. _sealed = YES;
  50. }
  51. - (BOOL)_configurationSealed
  52. {
  53. if (_sealed) {
  54. if (SCIsDebugBuild()) {
  55. SCAssert(NO, @"Try to set property after commit configuration to configurator");
  56. }
  57. return YES;
  58. } else {
  59. return NO;
  60. }
  61. }
  62. @end