CPP05 1.0
読み取り中…
検索中…
一致する文字列を見つけられません
AForm.hpp
[詳解]
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* AForm.hpp :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: kamitsui <kamitsui@student.42tokyo.jp> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2025/06/30 12:08:23 by kamitsui #+# #+# */
9/* Updated: 2025/06/30 12:10:59 by kamitsui ### ########.fr */
10/* */
11/* ************************************************************************** */
12
18#ifndef AFORM_HPP
19#define AFORM_HPP
20
21#include "Bureaucrat.hpp"
22#include <iostream>
23#include <stdexcept>
24#include <string>
25
26class Bureaucrat;
27
34class AForm {
35
36 private:
37 const std::string _name;
38 bool _isSigned;
39 const int _gradeToSign;
40 const int _gradeToExecute;
41 const std::string _target;
42 AForm(); // Private default constructor
43
44 public:
45 // Orthodox Canonical Form
46 AForm(const std::string &name, int gradeToSign, int gradeToExecute, const std::string &target);
47 AForm(const AForm &other);
48 AForm &operator=(const AForm &other);
49 virtual ~AForm();
50
51 // Getters
52 const std::string &getName() const;
53 bool getIsSigned() const;
54 int getGradeToSign() const;
55 int getGradeToExecute() const;
56 const std::string &getTarget() const;
57
58 // Member functions
59 void beSigned(const Bureaucrat &bureaucrat);
60 void execute(Bureaucrat const &executor) const;
61
62 // Pure virtual function for concrete class action
63 virtual void performAction() const = 0;
64
65 // Exception Classes
67 public:
68 virtual const char *what() const throw();
69 };
71 public:
72 virtual const char *what() const throw();
73 };
75 public:
76 virtual const char *what() const throw();
77 };
78};
79
80std::ostream &operator<<(std::ostream &os, const AForm &form);
81
82#endif
virtual const char * what() const
Definition AForm.cpp:74
virtual const char * what() const
Definition AForm.cpp:72
virtual const char * what() const
Definition AForm.cpp:73
An abstract base class for forms.
Definition AForm.hpp:34
virtual ~AForm()
Definition AForm.cpp:39
void execute(Bureaucrat const &executor) const
Central execution logic. Checks requirements before calling specific action.
Definition AForm.cpp:61
int getGradeToSign() const
Definition AForm.cpp:44
int getGradeToExecute() const
Definition AForm.cpp:45
bool getIsSigned() const
Definition AForm.cpp:43
const std::string & getName() const
Definition AForm.cpp:42
virtual void performAction() const =0
const std::string & getTarget() const
Definition AForm.cpp:46
void beSigned(const Bureaucrat &bureaucrat)
Definition AForm.cpp:48
AForm & operator=(const AForm &other)
Definition AForm.cpp:32
Represents a bureaucrat with a name and a grade.
std::ostream & operator<<(std::ostream &os, const AForm &form)
Definition AForm.cpp:77
Defines the Bureaucrat class, updated to execute AForms.