//
//  TemplateModelProtocol.swift
//  MVMCoreUI
//
//  Created by Suresh, Kamlesh on 11/22/19.
//  Copyright © 2019 Verizon Wireless. All rights reserved.
//


public protocol TemplateModelProtocol: PageModelProtocol, ModelProtocol, MoleculeTreeTraversalProtocol {
    var template: String { get }
    var rootMolecules: [MoleculeModelProtocol] { get }
}

public extension TemplateModelProtocol {
    
    var template: String {
        get { return Self.identifier }
    }
    
    static var categoryCodingKey: String {
        return "template"
    }
        
    static var categoryName: String {
        return "\(TemplateModelProtocol.self)"
    }
    
    func reduceDepthFirstTraverse<Result>(options: TreeTraversalOptions, depth: Int, initialResult: Result, nextPartialResult: (Result, MoleculeModelProtocol, Int) -> Result) -> Result {
        return rootMolecules.reduceDepthFirstTraverse(options: options, depth: depth, initialResult: initialResult, nextPartialResult: nextPartialResult)
    }
    
    func depthFirstTraverse(options: TreeTraversalOptions, depth: Int, onVisit: (Int, MoleculeModelProtocol) -> Void) {
        return rootMolecules.depthFirstTraverse(options: options, depth: depth, onVisit: onVisit)
    }
}
