AForm.hpp 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /* ************************************************************************** */
  2. /* */
  3. /* ::: :::::::: */
  4. /* AForm.hpp :+: :+: :+: */
  5. /* +:+ +:+ +:+ */
  6. /* By: bchanot <bchanot@42.fr> +#+ +:+ +#+ */
  7. /* +#+#+#+#+#+ +#+ */
  8. /* Created: 2025/12/29 16:42:01 by bchanot #+# #+# */
  9. /* Updated: 2025/12/31 16:04:33 by bchanot ### ########.fr */
  10. /* */
  11. /* ************************************************************************** */
  12. #ifndef AFORM_HPP
  13. # define AFORM_HPP
  14. # include <iostream>
  15. # include <string>
  16. # include <cstdint>
  17. class Bureaucrat;
  18. class AForm
  19. {
  20. public:
  21. AForm();
  22. AForm( AForm const & src );
  23. AForm( std::string const name, uint8_t const signGrade, uint8_t const executeGradea, std::string target );
  24. virtual ~AForm();
  25. AForm & operator=( AForm const & rhs );
  26. virtual void print(std::ostream & o) const;
  27. class GradeTooHighException : public std::exception {
  28. public:
  29. virtual const char *what() const throw() {
  30. return ("The grade specified is too high !");
  31. }
  32. };
  33. class GradeTooLowException : public std::exception {
  34. public:
  35. virtual const char *what() const throw() {
  36. return ("The grade specified is too low !");
  37. }
  38. };
  39. std::string const getName(void) const;
  40. std::string const getTarget(void) const;
  41. uint8_t getSignGrade(void) const;
  42. uint8_t getExecutionGrade(void) const;
  43. bool getSigned(void) const;
  44. void beSigned(const Bureaucrat &sch);
  45. void execute(Bureaucrat const & executor) const;
  46. protected:
  47. virtual void action(void) const = 0;
  48. std::string _target;
  49. private:
  50. std::string const _name;
  51. uint8_t const _signGrade;
  52. uint8_t const _executeGrade;
  53. bool _signed;
  54. };
  55. std::ostream & operator<<( std::ostream & o, AForm const & i );
  56. #endif /* ************************************************************ AFORM_H */