Factory/CCObject.cpp

50 lines
1.3 KiB
C++
Raw Normal View History

2025-12-06 17:11:34 +08:00
#include "CCObject.h"
#include "iostream"
#include <chrono>
#include <random>
2025-12-06 17:31:53 +08:00
#include "CCClassFactory.h"
2025-12-06 17:11:34 +08:00
bool CTL::Object::equals(const Object *other) {
return this == other; // 默认比较内存地址
}
size_t CTL::Object::hashCode() const noexcept {
return std::hash<const Object*>{}(this);
}
std::string CTL::Object::toString() const {
char buffer[64];
snprintf(buffer, sizeof(buffer), "Object@%p", static_cast<const void*>(this));
return buffer;
}
2025-12-06 17:31:53 +08:00
void CTL::Object::set_class_name(const std::string &name) {
this->m_class_Name = name;
}
std::string CTL::Object::get_class_name() const{
return m_class_Name;
}
int CTL::Object::get_info_count() const {
const auto factory = ClassFactory::getInstance();
return factory->get_info_count(this->m_class_Name);
}
CTL::ClassFactoryInfo * CTL::Object::get_info(const int pos) const {
const auto factory = ClassFactory::getInstance();
return factory->get_info(this->m_class_Name, pos);
}
CTL::ClassFactoryInfo * CTL::Object::get_info(const std::string &infoName) const {
const auto factory = ClassFactory::getInstance();
return factory->get_info(this->m_class_Name, infoName);
}
2025-12-06 17:11:34 +08:00
std::ostream & CTL::operator<<(std::ostream &os, const Object &map) {
os << map.toString();
return os;
}