FTree.h 1.7 KB

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