// // MPFunction.h // MathPad // // Created by Kim Wittenburg on 18.04.14. // Copyright (c) 2014 Kim Wittenburg. All rights reserved. // @import Foundation; #import "MPExpressionElement.h" #import "MPParseError.h" #import "MPTerm.h" @class MPFunction, MPExpression, MPRangePath; @interface MPFunction : NSObject + (NSString *)localizedFunctionName; // Override #pragma mark Creation Methods - (instancetype)init; #pragma mark Properties // Subclasses should define accessor properties for all sub expressions, which, in the setter, should send didChangeElementAtRangePath:replacementLength: to self with a replacement length of 1. #pragma mark Working With the Expression Tree @property (nonatomic, weak) MPExpression *parent; // Documentation: Do not set - (MPExpression *)rootExpression; - (NSIndexPath *)indexPath; - (NSUInteger)numberOfChildren; // Override - (MPExpression *)childAtIndex:(NSUInteger)index; // Override - (void)setChild:(MPExpression *)child atIndex:(NSUInteger)index; // Override // May be overridden for performance improvements - (NSArray *)children; // Indexes must equal the ones from the native methods - (NSUInteger)indexOfChild:(MPExpression *)child; - (id)elementAtIndexPath:(NSIndexPath *)indexPath; #pragma mark Evaluating Functions - (MPTerm *)parseWithError:(MPParseError *__autoreleasing *)error; // Override #pragma mark Messages - (void)didChangeElementsInRangePath:(MPRangePath *)rangePath replacementLength:(NSUInteger)replacementLength; - (void)didChangeChild:(MPExpression *)child; - (void)didChangeChildAtIndex:(NSUInteger)index; #pragma mark Working With Functions // - (BOOL)isEqualToFunction:(MPFunction *)aFunction; // Override - (NSString *)description; // Should be overridden - (NSUInteger)hash;// Override - (id)copyWithZone:(NSZone *)zone; // Override @end