aboutsummaryrefslogtreecommitdiff
path: root/cpp05/ex03/Form.hpp
diff options
context:
space:
mode:
authorCharles Cabergs <me@cacharle.xyz>2020-11-17 19:02:35 +0100
committerCharles Cabergs <me@cacharle.xyz>2020-11-17 19:02:35 +0100
commit452e6bfa7bb4bca75dc4659bf9d707101b411977 (patch)
treef4ee27a96437d6d17a89bbbbc135ae45f9f3faae /cpp05/ex03/Form.hpp
parenta92013c92bfcd50b0e2561280c9eaa604843ade0 (diff)
downloadpiscine_cpp-452e6bfa7bb4bca75dc4659bf9d707101b411977.tar.gz
piscine_cpp-452e6bfa7bb4bca75dc4659bf9d707101b411977.tar.bz2
piscine_cpp-452e6bfa7bb4bca75dc4659bf9d707101b411977.zip
Added cpp05/ex02 main, Added cpp05/ex03
Diffstat (limited to 'cpp05/ex03/Form.hpp')
-rw-r--r--cpp05/ex03/Form.hpp86
1 files changed, 86 insertions, 0 deletions
diff --git a/cpp05/ex03/Form.hpp b/cpp05/ex03/Form.hpp
new file mode 100644
index 0000000..78828da
--- /dev/null
+++ b/cpp05/ex03/Form.hpp
@@ -0,0 +1,86 @@
+/* ************************************************************************** */
+/* */
+/* ::: :::::::: */
+/* Form.hpp :+: :+: :+: */
+/* +:+ +:+ +:+ */
+/* By: charles <charles.cabergs@gmail.com> +#+ +:+ +#+ */
+/* +#+#+#+#+#+ +#+ */
+/* Created: 2020/04/14 19:19:45 by charles #+# #+# */
+/* Updated: 2020/11/17 17:09:15 by charles ### ########.fr */
+/* */
+/* ************************************************************************** */
+
+#ifndef FORM_HPP
+# define FORM_HPP
+
+# include <iostream>
+# include <exception>
+# include "Bureaucrat.hpp"
+
+class Bureaucrat;
+
+class Form
+{
+public:
+ Form(Form const& other);
+ Form& operator=(Form const& other);
+ ~Form();
+
+ Form(std::string const& name, int gradeSign, int gradeExecute);
+
+ std::string const& getName() const;
+ bool getSigned() const;
+ int getGradeSign() const;
+ int getGradeExecute() const;
+
+ void beSigned(Bureaucrat const& b);
+
+ void execute(Bureaucrat const& executor) const;
+
+protected:
+ virtual void executeUnsafe() const = 0;
+
+private:
+ Form();
+ void checkGrade();
+
+ std::string const m_name;
+ bool m_signed;
+ int const m_gradeSign;
+ int const m_gradeExecute;
+
+ 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();
+ };
+
+ class NoSignatureException : public std::exception
+ {
+ public:
+ NoSignatureException();
+ NoSignatureException(NoSignatureException const& other);
+ NoSignatureException& operator=(NoSignatureException const& other);
+ ~NoSignatureException() throw();
+ virtual char const* what() const throw();
+ };
+
+};
+
+std::ostream& operator<<(std::ostream& out, Form const& f);
+
+#endif