Program Listing for File StopInformation.h

Return to documentation for file (/home/kpenev/projects/git/poet/poet_src/Evolve/StopInformation.h)

#ifndef __STOP_INFORMATION_H
#define __STOP_INFORMATION_H

#include "../Core/SharedLibraryExportMacros.h"
#include "StoppingCondition.h"

namespace Evolve {

    class LIB_LOCAL StopInformation {
    private:
        double __stop_age,

               __stop_condition_precision;

        StoppingConditionType __stop_reason;

        bool
            __is_crossing,

             __crossed_zero;

        size_t __stop_condition_index;

        short __deriv_sign_at_crossing;
    public:
        StopInformation(
                double stop_age=Core::Inf,

                double stop_precision=Core::NaN,

                StoppingConditionType stop_reason=NO_STOP,

                bool is_crossing = false,

                bool crossed_zero = false,

                size_t stop_condition_index = 0,

                short deriv_sign_at_crossing = 0
        ) :
            __stop_age(stop_age),
            __stop_condition_precision(stop_precision),
            __stop_reason(stop_reason),
            __is_crossing(is_crossing),
            __crossed_zero(crossed_zero),
            __stop_condition_index(stop_condition_index),
            __deriv_sign_at_crossing(is_crossing ? deriv_sign_at_crossing : 0) {}

        StopInformation(const StopInformation &orig) :
            __stop_age(orig.__stop_age),
            __stop_condition_precision(orig.__stop_condition_precision),
            __stop_reason(orig.__stop_reason),
            __is_crossing(orig.__is_crossing),
            __crossed_zero(orig.__crossed_zero),
            __stop_condition_index(orig.__stop_condition_index),
            __deriv_sign_at_crossing(orig.__deriv_sign_at_crossing)
        {}

        double stop_age() const {return __stop_age;}

        double &stop_age() {return __stop_age;}

        double stop_condition_precision() const
        {return __stop_condition_precision;}

        double &stop_condition_precision()
        {return __stop_condition_precision;}

        StoppingConditionType stop_reason() const {return __stop_reason;}

        StoppingConditionType &stop_reason() {return __stop_reason;}

        bool is_crossing() const {return __is_crossing;}
        bool &is_crossing() {return __is_crossing;}

        size_t stop_condition_index() const {return __stop_condition_index;}

        size_t &stop_condition_index() {return __stop_condition_index;}

        bool crossed_zero() const {return __crossed_zero;}

        bool &crossed_zero() {return __crossed_zero;}

        StopInformation &operator=(const StopInformation &rhs)
        {
            __stop_age=rhs.__stop_age;
            __stop_condition_precision=rhs.__stop_condition_precision;
            __stop_reason=rhs.__stop_reason;
            __is_crossing=rhs.__is_crossing;
            __crossed_zero=rhs.__crossed_zero;
            __stop_condition_index=rhs.__stop_condition_index;
            __deriv_sign_at_crossing=rhs.__deriv_sign_at_crossing;
            return *this;
        }

        short deriv_sign_at_crossing() const
        {
            assert(__is_crossing);

            return __deriv_sign_at_crossing;
        }

        short &deriv_sign_at_crossing() {return __deriv_sign_at_crossing;}

    };//End StopInformation class.

    LIB_LOCAL std::ostream &operator<<(std::ostream &os,
                                       const StopInformation &stop);

}//End Evolve namespaec.
#endif