CPP05/ex03/inc/Bureaucrat.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

55 lines
1.4 KiB
C++

#pragma once
#include <exception>
#include <iostream>
#include <string>
#define HIGHEST_GRADE 1
#define LOWEST_GRADE 150
class Bureaucrat
{
private:
const std::string _name;
int _grade;
public:
// Constructors
Bureaucrat() = delete;
Bureaucrat(std::string name, int grade);
// Copy constructor and copy assignment operator
Bureaucrat(const Bureaucrat &other);
Bureaucrat &operator=(const Bureaucrat &other) = delete;
// Move constructor and move assignment operator
Bureaucrat(Bureaucrat &&other) noexcept;
Bureaucrat &operator=(Bureaucrat &&other) noexcept = delete;
// Destructor
~Bureaucrat();
Bureaucrat &operator++(); // Pre-increment
Bureaucrat operator++(int); // Post-increment
Bureaucrat &operator--(); // Pre-decrement
Bureaucrat operator--(int); // Post-decrement
int getGrade() const;
const std::string getName() const;
void signForm(class AForm &form);
void executeForm(const class AForm &form) const;
class GradeTooHighException : public std::exception
{
public:
const char *what() const throw();
};
class GradeTooLowException : public std::exception
{
public:
const char *what() const throw();
};
};
std::ostream &operator<<(std::ostream &os, const Bureaucrat &bureaucrat);