FCompoundWrite.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. /*
  2. * Copyright 2017 Google
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. #import <Foundation/Foundation.h>
  17. @class FImmutableTree;
  18. @protocol FNode;
  19. @class FPath;
  20. /**
  21. * This class holds a collection of writes that can be applied to nodes in unison. It abstracts away the logic with
  22. * dealing with priority writes and multiple nested writes. At any given path, there is only allowed to be one write
  23. * modifying that path. Any write to an existing path or shadowing an existing path will modify that existing write to
  24. * reflect the write added.
  25. */
  26. @interface FCompoundWrite : NSObject
  27. - (id) initWithWriteTree:(FImmutableTree *)tree;
  28. /**
  29. * Creates a compound write with NSDictionary from path string to object
  30. */
  31. + (FCompoundWrite *) compoundWriteWithValueDictionary:(NSDictionary *)dictionary;
  32. /**
  33. * Creates a compound write with NSDictionary from path string to node
  34. */
  35. + (FCompoundWrite *) compoundWriteWithNodeDictionary:(NSDictionary *)dictionary;
  36. + (FCompoundWrite *) emptyWrite;
  37. - (FCompoundWrite *) addWrite:(id<FNode>)node atPath:(FPath *)path;
  38. - (FCompoundWrite *) addWrite:(id<FNode>)node atKey:(NSString *)key;
  39. - (FCompoundWrite *) addCompoundWrite:(FCompoundWrite *)node atPath:(FPath *)path;
  40. - (FCompoundWrite *) removeWriteAtPath:(FPath *)path;
  41. - (id<FNode>)rootWrite;
  42. - (BOOL) hasCompleteWriteAtPath:(FPath *)path;
  43. - (id<FNode>) completeNodeAtPath:(FPath *)path;
  44. - (NSArray *) completeChildren;
  45. - (NSDictionary *)childCompoundWrites;
  46. - (FCompoundWrite *) childCompoundWriteAtPath:(FPath *)path;
  47. - (id<FNode>) applyToNode:(id<FNode>)node;
  48. - (void)enumerateWrites:(void (^)(FPath *path, id<FNode>node, BOOL *stop))block;
  49. - (NSDictionary *)valForExport:(BOOL)exportFormat;
  50. - (BOOL) isEmpty;
  51. @end