AForm.hpp
  1  /* ************************************************************************** */
  2  /*                                                                            */
  3  /*                                                        :::      ::::::::   */
  4  /*   AForm.hpp                                          :+:      :+:    :+:   */
  5  /*                                                    +:+ +:+         +:+     */
  6  /*   By: gychoi <gychoi@student.42seoul.kr>         +#+  +:+       +#+        */
  7  /*                                                +#+#+#+#+#+   +#+           */
  8  /*   Created: 2023/11/28 21:46:48 by gychoi            #+#    #+#             */
  9  /*   Updated: 2023/12/03 20:31:22 by gychoi           ###   ########.fr       */
 10  /*                                                                            */
 11  /* ************************************************************************** */
 12  
 13  #pragma once
 14  #ifndef __AFORM_HPP__
 15  #define __AFORM_HPP__
 16  
 17  #include <iostream>
 18  #include <stdexcept>
 19  #include <string>
 20  
 21  #include "Bureaucrat.hpp"
 22  
 23  /* ************************************************************************** */
 24  /*                                   AForm                                    */
 25  /* ************************************************************************** */
 26  class AForm
 27  {
 28  public:
 29  	AForm();
 30  	AForm(std::string const& name, int signGrade, int executeGrade);
 31  	AForm(AForm const& target);
 32  	AForm&				operator=(AForm const& target);
 33  	virtual ~AForm();
 34  
 35  public:
 36  	std::string const&	getName() const;
 37  	bool				getIsSigned() const;
 38  	int					getSignGrade() const;
 39  	int					getExecuteGrade() const;
 40  	void				setIsSigned(bool isSigned);
 41  
 42  public:
 43  	virtual void		beSigned(Bureaucrat const& bureaucrat) = 0;
 44  	virtual void		execute(Bureaucrat const& executor) const = 0;
 45  
 46  private:
 47  	std::string const	mName;
 48  	bool				mbIsSigned;
 49  	int const			mSignGrade;
 50  	int const			mExecuteGrade;
 51  
 52  /* ************************************************************************** */
 53  /*                        AForm::GradeTooHighException                        */
 54  /* ************************************************************************** */
 55  public:
 56  	class GradeTooHighException : public std::exception
 57  	{
 58  	public:
 59  		GradeTooHighException();
 60  		GradeTooHighException(std::string const& msg);
 61  		GradeTooHighException(GradeTooHighException const& target);
 62  		GradeTooHighException&	operator=(GradeTooHighException const& target);
 63  		virtual ~GradeTooHighException() throw();
 64  
 65  	public:
 66  		std::string const&		getMessage() const;
 67  
 68  	public:
 69  		virtual char const*		what() const throw();
 70  
 71  	private:
 72  		std::string				mMessage;
 73  	};
 74  
 75  /* ************************************************************************** */
 76  /*                         AForm::GradeTooLowException                        */
 77  /* ************************************************************************** */
 78  public:
 79  	class GradeTooLowException : public std::exception
 80  	{
 81  	public:
 82  		GradeTooLowException();
 83  		GradeTooLowException(std::string const& msg);
 84  		GradeTooLowException(GradeTooLowException const& target);
 85  		GradeTooLowException&	operator=(GradeTooLowException const& target);
 86  		virtual ~GradeTooLowException() throw();
 87  
 88  	public:
 89  		std::string const&		getMessage() const;
 90  
 91  	public:
 92  		virtual char const*		what() const throw();
 93  
 94  	private:
 95  		std::string				mMessage;
 96  	};
 97  };
 98  
 99  std::ostream&			operator<<(std::ostream& os, AForm const& target);
100  
101  #endif /* __AFORM_HPP__ */