CPP05/ex02/inc/AForm.hpp
whaffman f916d5cb2f Refactor Bureaucrat and Form classes to implement move semantics and improve exception handling
- Added move constructors and move assignment operators to Bureaucrat and Form classes.
- Updated constructors and destructors to include logging for move operations.
- Enhanced Bureaucrat class with an executeForm method to handle form execution.
- Refactored color definitions in colors.h for better organization and clarity.
- Removed redundant macro definitions and improved code readability.
- Updated main functions to utilize new executeForm method for better exception handling.
- Ensured proper handling of copy and move semantics across all relevant classes.
2026-03-27 19:54:54 +01:00

66 lines
1.7 KiB
C++

#pragma once
#include <exception>
#include <iostream>
#include <string>
#include "Bureaucrat.hpp"
class AForm
{
private:
const std::string _name;
bool _isSigned;
const int _signGrade;
const int _executeGrade;
public:
// Constructors
AForm() = delete;
AForm(std::string name, int signGrade, int executeGrade);
// Copy constructor and copy assignment operator
AForm(const AForm &other);
AForm &operator=(const AForm &other) = delete;
// Move constructor and move assignment operator
AForm(AForm &&other) noexcept;
AForm &operator=(AForm &&other) noexcept = delete;
// Destructor
virtual ~AForm();
const std::string &getName() const;
bool getIsSigned() const;
int getSignGrade() const;
int getExecuteGrade() const;
void beSigned(const Bureaucrat &bureaucrat);
bool isExecutable(const Bureaucrat &executor) const;
virtual void execute(const Bureaucrat &executor)
const = 0; // Pure virtual function, making AForm an abstract class
class GradeTooHighException : public std::exception
{
public:
const char *what() const throw();
};
class GradeTooLowException : public std::exception
{
public:
const char *what() const throw();
};
class FormAlreadySignedException : public std::exception
{
public:
const char *what() const throw();
};
class FormNotSignedException : public std::exception
{
public:
const char *what() const throw();
};
};
std::ostream &operator<<(std::ostream &os, const AForm &form);