ajout ex03 et correction dump core
This commit is contained in:
93
d05/ex03/srcs/Intern.cpp
Normal file
93
d05/ex03/srcs/Intern.cpp
Normal file
@@ -0,0 +1,93 @@
|
||||
#include "Intern.hpp"
|
||||
|
||||
#define COPLIEN_COLOR B_CYAN
|
||||
|
||||
/*********************************************
|
||||
* STATICS
|
||||
*********************************************/
|
||||
|
||||
const t_formModel Intern::_chooseForm[] = {
|
||||
{"Shrubbery", Intern::makeShrubbery},
|
||||
{"Presidential", Intern::makePresidential},
|
||||
{"Robotomy", Intern::makeRobotomy}
|
||||
};
|
||||
|
||||
/*********************************************
|
||||
* CONSTRUCTORS
|
||||
*********************************************/
|
||||
|
||||
Intern::Intern() {
|
||||
std::cout << COPLIEN_COLOR "Intern constructor" RESET "\n";
|
||||
return;
|
||||
}
|
||||
|
||||
Intern::Intern( Intern const & src __attribute__((unused))) {
|
||||
std::cout << COPLIEN_COLOR "Intern copy constructor" RESET "\n";
|
||||
*this = src;
|
||||
return;
|
||||
}
|
||||
|
||||
/*********************************************
|
||||
* DESTRUCTORS
|
||||
*********************************************/
|
||||
|
||||
Intern::~Intern() {
|
||||
std::cout << COPLIEN_COLOR "Intern destructor" RESET "\n";
|
||||
return;
|
||||
}
|
||||
|
||||
/*********************************************
|
||||
* OPERATORS
|
||||
*********************************************/
|
||||
|
||||
Intern & Intern::operator=( Intern const & rhs __attribute__((unused))) {
|
||||
return *this;
|
||||
}
|
||||
|
||||
//std::ostream & operator<<(std::ostream & o, Intern const & rhs)
|
||||
//{
|
||||
// o << rhs.getFoo();
|
||||
// return (o);
|
||||
//}
|
||||
|
||||
/*********************************************
|
||||
* ACCESSORS
|
||||
*********************************************/
|
||||
|
||||
//std::string Intern::getFoo() const {return _foo;}
|
||||
|
||||
/*********************************************
|
||||
* PRIVATE MEMBER FUNCTIONS
|
||||
*********************************************/
|
||||
|
||||
AForm * Intern::makeForm(std::string formName, std::string formTarget) const {
|
||||
unsigned int len = sizeof _chooseForm / sizeof _chooseForm[0];
|
||||
|
||||
for (unsigned int i = 0; i < len; i++)
|
||||
if (!formName.compare(_chooseForm[i].name))
|
||||
{
|
||||
std::cout << "Intern creates " << formName << "\n";
|
||||
return _chooseForm[i].create(formTarget);
|
||||
}
|
||||
std::cout << "Intern cannot create " << formName << "\n";
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/*********************************************
|
||||
* PUBLIC MEMBER FUNCTIONS
|
||||
*********************************************/
|
||||
|
||||
AForm * Intern::makeShrubbery(std::string const &target) {
|
||||
return new ShrubberyCreationForm(target);}
|
||||
AForm * Intern::makePresidential(std::string const &target) {
|
||||
return new PresidentialPardonForm(target);}
|
||||
AForm * Intern::makeRobotomy(std::string const &target) {
|
||||
return new RobotomyRequestForm(target);}
|
||||
|
||||
/*********************************************
|
||||
* NESTED CLASS
|
||||
*********************************************/
|
||||
|
||||
//void Intern::Class::function() {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user