- 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.
58 lines
1.3 KiB
C++
58 lines
1.3 KiB
C++
#pragma once
|
|
|
|
#include <exception>
|
|
#include <iostream>
|
|
#include <string>
|
|
|
|
#include "Bureaucrat.hpp"
|
|
|
|
class Form
|
|
{
|
|
private:
|
|
const std::string _name;
|
|
bool _isSigned;
|
|
const int _signGrade;
|
|
const int _executeGrade;
|
|
|
|
public:
|
|
// Constructors
|
|
Form() = delete;
|
|
Form(std::string name, int signGrade, int executeGrade);
|
|
|
|
// Copy constructor and copy assignment operator
|
|
Form(const Form &other);
|
|
Form &operator=(const Form &other) = delete;
|
|
|
|
// Move constructor and move assignment operator
|
|
Form(Form &&other) noexcept;
|
|
Form &operator=(Form &&other) noexcept = delete;
|
|
|
|
// Destructor
|
|
~Form();
|
|
|
|
const std::string &getName() const;
|
|
bool getIsSigned() const;
|
|
int getSignGrade() const;
|
|
int getExecuteGrade() const;
|
|
void beSigned(const Bureaucrat &bureaucrat);
|
|
|
|
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();
|
|
};
|
|
};
|
|
|
|
std::ostream &operator<<(std::ostream &os, const Form &form); |