AForm.hpp 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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/30 17:01:02 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. class GradeTooHighException : public std::exception {
  27. public:
  28. virtual const char *what() const throw() {
  29. return ("The grade specified is too high !");
  30. }
  31. };
  32. class GradeTooLowException : public std::exception {
  33. public:
  34. virtual const char *what() const throw() {
  35. return ("The grade specified is too low !");
  36. }
  37. };
  38. std::string const getName(void) const;
  39. uint8_t getSignGrade(void) const;
  40. uint8_t getExecutionGrade(void) const;
  41. bool getSigned(void) const;
  42. void beSigned(const Bureaucrat &sch);
  43. void execute(Bureaucrat const & executor) const;
  44. protected:
  45. virtual void action(void) const = 0;
  46. std::string _target;
  47. private:
  48. std::string const _name;
  49. uint8_t const _signGrade;
  50. uint8_t const _executeGrade;
  51. bool _signed;
  52. };
  53. std::ostream & operator<<( std::ostream & o, AForm const & i );
  54. #endif /* ************************************************************ AFORM_H */