- 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.
66 lines
1.7 KiB
C++
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); |