# Copyright (C) 2018-2019 DLR
#
# All rights reserved. This program and the accompanying materials are made
# available under the terms of the 3-Clause BSD License which accompanies this
# distribution, and is available at
# https://opensource.org/licenses/BSD-3-Clause
#
# Contributors:
# Christoph Suerig <christoph.suerig@dlr.de>

# Don't connect with the Copyright comment above!
# Version 12.11.2018
from rafcontpp.model.plan_step import PlanStep


class PlanningReport:
    """PlanningReport
    PlanningReport is a report, generated by the Planner Interface. It contains the information, if
    planning was successful, the found plan, and in case an Error Message, as well as a refernce to
    all files, which where generated by the planner or the planner Interface.
    """

    def __init__(self, planning_successful, plan, generated_files, error_message='No Error!'):
        """

        :param planning_successful: A Boolean to indicate, if planning was successful.
        :param plan: The Plan as [PlanStep]
        :param generated_files: A list, containing the names of all generated files.
        :param error_message: An error message, in case something went wrong.
        """
        if plan and len(plan) > 0 and (not isinstance(plan[0], PlanStep)):
            raise TypeError('Plan has to be a list of type PlanStep!')
        self.__planning_successful = planning_successful
        self.__plan = plan
        self.__generated_files = generated_files
        self.__error_message = error_message

    def planning_successful(self):
        """
        :return: Boolean: True if planning was successful, false otherwhise
        """
        return self.__planning_successful

    def get_plan(self):
        """
        :return: [PlanStep]: Returns the Plan.
        """
        return self.__plan

    def get_error_message(self):
        """
        :return: String: An error message, in case something went wrong.
        """
        return self.__error_message

    def get_generated_files(self):
        """
        :return: [String]: A list, containing all names of files, generated by the planner.
        """
        return self.__generated_files
