FTree.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 "FirebaseDatabase/Sources/Core/Utilities/FPath.h"
  17. #import "FirebaseDatabase/Sources/Core/Utilities/FTreeNode.h"
  18. #import <Foundation/Foundation.h>
  19. @interface FTree : NSObject
  20. - (id)init;
  21. - (id)initWithName:(NSString *)aName
  22. withParent:(FTree *)aParent
  23. withNode:(FTreeNode *)aNode;
  24. - (FTree *)subTree:(FPath *)path;
  25. - (id)getValue;
  26. - (void)setValue:(id)value;
  27. - (void)clear;
  28. - (BOOL)hasChildren;
  29. - (BOOL)isEmpty;
  30. - (void)forEachChildMutationSafe:(void (^)(FTree *))action;
  31. - (void)forEachChild:(void (^)(FTree *))action;
  32. - (void)forEachDescendant:(void (^)(FTree *))action;
  33. - (void)forEachDescendant:(void (^)(FTree *))action
  34. includeSelf:(BOOL)incSelf
  35. childrenFirst:(BOOL)childFirst;
  36. - (BOOL)forEachAncestor:(BOOL (^)(FTree *))action;
  37. - (BOOL)forEachAncestor:(BOOL (^)(FTree *))action includeSelf:(BOOL)incSelf;
  38. - (void)forEachImmediateDescendantWithValue:(void (^)(FTree *))action;
  39. - (BOOL)valueExistsAtOrAbove:(FPath *)path;
  40. - (FPath *)path;
  41. - (void)updateParents;
  42. - (void)updateChild:(NSString *)childName withNode:(FTree *)child;
  43. @property(nonatomic, strong) NSString *name;
  44. @property(nonatomic, strong) FTree *parent;
  45. @property(nonatomic, strong) FTreeNode *node;
  46. @end