aboutsummaryrefslogtreecommitdiff
path: root/cpp05/ex03/Bureaucrat.hpp
blob: 1c7c5656e52a34fd78847b11c3d4c2f94f0b1924 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/* ************************************************************************** */
/*                                                                            */
/*                                                        :::      ::::::::   */
/*   Bureaucrat.hpp                                     :+:      :+:    :+:   */
/*                                                    +:+ +:+         +:+     */
/*   By: charles <charles.cabergs@gmail.com>        +#+  +:+       +#+        */
/*                                                +#+#+#+#+#+   +#+           */
/*   Created: 2020/04/14 18:04:32 by charles           #+#    #+#             */
/*   Updated: 2020/12/12 12:19:51 by cacharle         ###   ########.fr       */
/*                                                                            */
/* ************************************************************************** */

#ifndef BUREAUCRAT_HPP
# define BUREAUCRAT_HPP

# include <iostream>
# include <exception>
# include "Form.hpp"

class Form;

class Bureaucrat
{
public:
    Bureaucrat(Bureaucrat const& other);
    Bureaucrat& operator=(Bureaucrat const& other);
    ~Bureaucrat();

    Bureaucrat(std::string const& name, int grade);

    std::string const& getName()  const;
    int                getGrade() const;
    void               incrementGrade();
    void               decrementGrade();

    void               signForm(Form& form) const;
    void               executeForm(Form const& form) const;

private:
    Bureaucrat();
    void checkGrade();

    std::string const m_name;
    int               m_grade;

    class GradeTooHighException : public std::exception
    {
    public:
        GradeTooHighException();
        GradeTooHighException(GradeTooHighException const& other);
        GradeTooHighException& operator=(GradeTooHighException const& other);
        ~GradeTooHighException() throw();
        virtual char const* what() const throw();
    };

    class GradeTooLowException : public std::exception
    {
    public:
        GradeTooLowException();
        GradeTooLowException(GradeTooLowException const& other);
        GradeTooLowException& operator=(GradeTooLowException const& other);
        ~GradeTooLowException() throw();
        virtual char const* what() const throw();
    };

};

std::ostream& operator<<(std::ostream& out, Bureaucrat const& b);

#endif