/* ************************************************************************** */ /* */ /* ::: :::::::: */ /* Intern.cpp :+: :+: :+: */ /* +:+ +:+ +:+ */ /* By: narnaud +#+ +:+ +#+ */ /* +#+#+#+#+#+ +#+ */ /* Created: 2022/06/27 15:07:10 by narnaud #+# #+# */ /* Updated: 2022/06/27 16:28:56 by narnaud ### ########.fr */ /* */ /* ************************************************************************** */ #include "Intern.hpp" Intern::Intern(void) {} Intern::Intern(Intern const &src) { (void)src; } Intern &Intern::operator=(Intern const &src) { (void)src; return (*this); } Intern::~Intern(void) {} Form *createRobotForm(string targ) { return (new RobotomyRequestForm(targ)); } Form *createPresidentForm(string targ) { return (new PresidentialPardonForm(targ)); } Form *createShrubberyForm(string targ) { return (new ShrubberyCreationForm(targ)); } Form *Intern::makeForm(string name, string target) { string subFormsName[3] = {"robotomy request", "president pardon", "shrubbery creation"}; Form *(*subFormsCreation[3])(string targ) = { createRobotForm, createPresidentForm, createShrubberyForm}; for (int i = 0; i < 3; i++) if (name == subFormsName[i]) return (subFormsCreation[i](target)); cout << "Intern fail to create " << name << ": unknow form name" << endl; return (NULL); }