59 lines
1.9 KiB
C++
59 lines
1.9 KiB
C++
/* ************************************************************************** */
|
||
/* */
|
||
/* ::: :::::::: */
|
||
/* MateriaTemplate.hpp :+: :+: :+: */
|
||
/* +:+ +:+ +:+ */
|
||
/* By: adjoly <adjoly@student.42angouleme.fr> +#+ +:+ +#+ */
|
||
/* +#+#+#+#+#+ +#+ */
|
||
/* Created: 2024/12/11 10:59:31 by adjoly #+# #+# */
|
||
/* Updated: 2024/12/11 12:06:51 by adjoly ### ########.fr */
|
||
/* */
|
||
/* ************************************************************************** */
|
||
|
||
#pragma once
|
||
|
||
#include "AMateria.hpp"
|
||
#include "Log.hpp"
|
||
|
||
template <typename T>
|
||
class MateriaTemplate : public AMateria {
|
||
public:
|
||
MateriaTemplate(void);
|
||
~MateriaTemplate(void);
|
||
MateriaTemplate(T const &);
|
||
T &operator=(const T &);
|
||
|
||
AMateria *clone(void) const;
|
||
};
|
||
|
||
template <typename T>
|
||
MateriaTemplate<T>::MateriaTemplate(void) :
|
||
AMateria(T::_typeName()) {
|
||
log("➕", T::_typeName(), "", "default constructor called");
|
||
}
|
||
|
||
template <typename T>
|
||
MateriaTemplate<T>::~MateriaTemplate(void) {
|
||
log("➖", T::_typeName(), "", "destructor called");
|
||
}
|
||
|
||
template <typename T>
|
||
MateriaTemplate<T>::MateriaTemplate(T const &cpy) {
|
||
*this = cpy;
|
||
log("➕", T::_typeName(), "", "copy constructor called");
|
||
}
|
||
|
||
template <typename T>
|
||
T &MateriaTemplate<T>::operator=(const T &cpy) {
|
||
log("➕", T::_typeName(), "", "copy assignement constructor called");
|
||
if (this != &cpy) {
|
||
this->_type = cpy._type;
|
||
}
|
||
return (*this);
|
||
}
|
||
|
||
template <typename T>
|
||
AMateria *MateriaTemplate<T>::clone(void) const {
|
||
return (new T);
|
||
}
|