CPP04 1.0
読み取り中…
検索中…
一致する文字列を見つけられません
AMateria.cpp
[詳解]
1/* ************************************************************************** */
2/* */
3/* ::: :::::::: */
4/* AMateria.cpp :+: :+: :+: */
5/* +:+ +:+ +:+ */
6/* By: kamitsui <kamitsui@student.42tokyo.jp> +#+ +:+ +#+ */
7/* +#+#+#+#+#+ +#+ */
8/* Created: 2025/05/29 22:42:03 by kamitsui #+# #+# */
9/* Updated: 2025/06/05 23:44:11 by kamitsui ### ########.fr */
10/* */
11/* ************************************************************************** */
12
23#include "AMateria.hpp"
24#include "Character.hpp" // Included as ICharacter is part of Character.hpp, and required for use()
25#include "Logger.hpp"
26#include <sstream>
27
32AMateria::AMateria(std::string const &type) : type(type) {
34 oss << this->type;
35 LOG_INFO("AMateria constructor called for type: " + oss.str());
36}
37
43AMateria::AMateria(const AMateria &src) : type(src.type) {
45 oss << src.type;
46 LOG_INFO("AMateria copy constructor called for type: " + oss.str());
47}
48
57 oss << rhs.type;
58 LOG_INFO("AMateria copy assignment operator called for type: " + oss.str());
59 if (this != &rhs) {
60 // this->type = rhs.type; // Cannot assign to const member type.
61 }
62 return *this;
63}
64
70 oss << this->type;
71 LOG_INFO("AMateria destructor called for type: " + oss.str());
72}
73
78std::string const &AMateria::getType() const { return this->type; }
79
87 (void)target; // To avoid unused parameter warning in the base class
88 std::cout << "* uses " << this->type << " *" << std::endl;
89}
Declares the AMateria abstract base class.
Declares the Character class.
Defines the Logger class for console-based logging.
#define LOG_INFO(msg)
Macro for logging informational messages.
Definition Logger.hpp:70
Represents an abstract base class for all magical materias.
Definition AMateria.hpp:42
virtual AMateria & operator=(const AMateria &rhs)
Copy assignment operator for AMateria. Assigns the type from another AMateria object....
Definition AMateria.cpp:55
virtual ~AMateria()
Destroys the AMateria object.
Definition AMateria.cpp:68
std::string const & getType() const
Gets the type of the materia.
Definition AMateria.cpp:78
virtual void use(ICharacter &target)
Uses the materia on a target character. This is a virtual function with a base implementation that pr...
Definition AMateria.cpp:86
std::string const type
Definition AMateria.hpp:44
An interface for any character that can interact with Materias.
T endl(T... args)
T str(T... args)