Bureaucrat.hpp 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. /* ************************************************************************** */
  2. /* */
  3. /* ::: :::::::: */
  4. /* Bureaucrat.hpp :+: :+: :+: */
  5. /* +:+ +:+ +:+ */
  6. /* By: bchanot <bchanot@42.fr> +#+ +:+ +#+ */
  7. /* +#+#+#+#+#+ +#+ */
  8. /* Created: 2025/12/26 17:51:13 by bchanot #+# #+# */
  9. /* Updated: 2025/12/30 18:23:58 by bchanot ### ########.fr */
  10. /* */
  11. /* ************************************************************************** */
  12. #ifndef BUREAUCRAT_HPP
  13. # define BUREAUCRAT_HPP
  14. # include <iostream>
  15. # include <string>
  16. # include <cstdint>
  17. class AForm;
  18. class Bureaucrat
  19. {
  20. public:
  21. Bureaucrat();
  22. Bureaucrat( Bureaucrat const & src );
  23. Bureaucrat( std::string const name, u_int8_t grade );
  24. ~Bureaucrat();
  25. Bureaucrat &operator=( Bureaucrat const & rhs );
  26. Bureaucrat &operator++();
  27. Bureaucrat &operator--();
  28. class GradeTooHighException : public std::exception {
  29. public:
  30. virtual const char *what() const throw() {
  31. return ("The grade specified is too high !");
  32. }
  33. };
  34. class GradeTooLowException : public std::exception {
  35. public:
  36. virtual const char *what() const throw() {
  37. return ("The grade specified is too low !");
  38. }
  39. };
  40. uint8_t getGrade(void) const;
  41. std::string getName(void) const;
  42. void signForm(AForm *form);
  43. void decrementGrade(void);
  44. void incrementGrade(void);
  45. void executeForm(AForm const & form) const;
  46. private:
  47. std::string _name;
  48. uint8_t _grade;
  49. };
  50. std::ostream & operator<<( std::ostream & o, Bureaucrat const & i );
  51. #endif /* ****************************************************** BUREAUCRAT_H */