/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* Form.cpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: bchanot +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2025/12/29 16:42:01 by bchanot #+# #+# */ /* Updated: 2025/12/29 19:29:17 by bchanot ### ########.fr */ /* */ /* ************************************************************************** */ #include "Form.hpp" #include "Bureaucrat.hpp" /* ** ------------------------------- CONSTRUCTOR -------------------------------- */ Form::Form() : _name("DefaultFormName"), _signGrade(1), _executeGrade(1), _signed(false) { } Form::Form( const std::string name, uint8_t execGrade, uint8_t signGrade ) : _name(name), _signGrade(signGrade), _executeGrade(execGrade), _signed(false) { if (this->_executeGrade > 150 || this->_signGrade > 150) throw Bureaucrat::GradeTooHighException(); else if (this->_executeGrade < 1 || this->_signGrade < 1) throw Bureaucrat::GradeTooLowException(); } Form::Form( const Form & src ) : _name(src._name), _signGrade(src._signGrade), _executeGrade(src._executeGrade), _signed(false) { if (this->_executeGrade > 150 || this->_signGrade > 150) throw Bureaucrat::GradeTooHighException(); else if (this->_executeGrade < 1 || this->_signGrade < 1) throw Bureaucrat::GradeTooLowException(); } /* ** -------------------------------- DESTRUCTOR -------------------------------- */ Form::~Form() { } /* ** --------------------------------- OVERLOAD --------------------------------- */ Form & Form::operator=( Form const & rhs ) { (void)rhs; //if ( this != &rhs ) //{ //this->_value = rhs.getValue(); //} return *this; } std::ostream & operator<<( std::ostream & o, Form const & i ) { o << "Form name : " << i.getName() << ", Minimum grade for sign : " << (int)i.getSignGrade() << ", Minimum exection grade : " << (int)i.getExecutionGrade() << ", Is signed : " << i.getSigned(); return o; } /* ** --------------------------------- METHODS ---------------------------------- */ void Form::beSigned(const Bureaucrat &sch) { if (sch.getGrade() <= this->_signGrade) this->_signed = true; else throw Form::GradeTooLowException(); } /* ** --------------------------------- ACCESSOR --------------------------------- */ std::string const Form::getName(void) const { return this->_name; } uint8_t Form::getSignGrade(void) const { return this->_signGrade; } uint8_t Form::getExecutionGrade(void) const { return this->_executeGrade; } bool Form::getSigned(void) const { return this->_signed; } /* ************************************************************************** */