FCompoundWrite.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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
  22. * unison. It abstracts away the logic with dealing with priority writes and
  23. * multiple nested writes. At any given path, there is only allowed to be one
  24. * write modifying that path. Any write to an existing path or shadowing an
  25. * existing path will modify that existing write to reflect the write added.
  26. */
  27. @interface FCompoundWrite : NSObject
  28. - (id)initWithWriteTree:(FImmutableTree *)tree;
  29. /**
  30. * Creates a compound write with NSDictionary from path string to object
  31. */
  32. + (FCompoundWrite *)compoundWriteWithValueDictionary:(NSDictionary *)dictionary;
  33. /**
  34. * Creates a compound write with NSDictionary from path string to node
  35. */
  36. + (FCompoundWrite *)compoundWriteWithNodeDictionary:(NSDictionary *)dictionary;
  37. + (FCompoundWrite *)emptyWrite;
  38. - (FCompoundWrite *)addWrite:(id<FNode>)node atPath:(FPath *)path;
  39. - (FCompoundWrite *)addWrite:(id<FNode>)node atKey:(NSString *)key;
  40. - (FCompoundWrite *)addCompoundWrite:(FCompoundWrite *)node
  41. atPath:(FPath *)path;
  42. - (FCompoundWrite *)removeWriteAtPath:(FPath *)path;
  43. - (id<FNode>)rootWrite;
  44. - (BOOL)hasCompleteWriteAtPath:(FPath *)path;
  45. - (id<FNode>)completeNodeAtPath:(FPath *)path;
  46. - (NSArray *)completeChildren;
  47. - (NSDictionary *)childCompoundWrites;
  48. - (FCompoundWrite *)childCompoundWriteAtPath:(FPath *)path;
  49. - (id<FNode>)applyToNode:(id<FNode>)node;
  50. - (void)enumerateWrites:(void (^)(FPath *path, id<FNode> node,
  51. BOOL *stop))block;
  52. - (NSDictionary *)valForExport:(BOOL)exportFormat;
  53. - (BOOL)isEmpty;
  54. @end