/*
* InfiniPaint
* Copyright (C) 2025-2026 Yousef Khadadeh
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see .
*/
#pragma once
#include
#include
#include
#include
#include
#include "NetObjTemporaryPtr.decl.hpp"
#include "NetObjManager.hpp"
namespace NetworkingObjects {
template NetObjTemporaryPtr::NetObjTemporaryPtr():
objMan(nullptr),
rawPtr(nullptr)
{}
template NetObjTemporaryPtr::NetObjTemporaryPtr(const NetObjTemporaryPtr& other):
objMan(other.objMan),
id(other.id),
rawPtr(other.rawPtr)
{}
template NetObjTemporaryPtr::NetObjTemporaryPtr(const NetObjOwnerPtr& owner):
objMan(owner.objMan),
id(owner.id),
rawPtr(owner.rawPtr)
{}
template NetObjTemporaryPtr& NetObjTemporaryPtr::operator=(const NetObjTemporaryPtr& other) {
objMan = other.objMan;
id = other.id;
rawPtr = other.rawPtr;
return *this;
}
template template NetObjTemporaryPtr NetObjTemporaryPtr::cast() const {
return NetObjTemporaryPtr(objMan, id, static_cast(rawPtr));
}
template NetObjManager* NetObjTemporaryPtr::get_obj_man() const {
return objMan;
}
template NetObjID NetObjTemporaryPtr::get_net_id() const {
return id;
}
template T* NetObjTemporaryPtr::get() const {
return rawPtr;
}
template std::add_lvalue_reference_t NetObjTemporaryPtr::operator*() const requires(!std::is_void_v) {
return *rawPtr;
}
template T* NetObjTemporaryPtr::operator->() const {
return rawPtr;
}
template NetObjTemporaryPtr::operator bool() const {
return rawPtr;
}
template bool NetObjTemporaryPtr::operator!=(const NetObjTemporaryPtr& rhs) const {
return rawPtr != rhs.rawPtr;
}
template bool NetObjTemporaryPtr::operator==(const NetObjTemporaryPtr& rhs) const {
return rawPtr == rhs.rawPtr;
}
template bool NetObjTemporaryPtr::operator!=(const NetObjOwnerPtr& rhs) const {
return rawPtr != rhs.get();
}
template bool NetObjTemporaryPtr::operator==(const NetObjOwnerPtr& rhs) const {
return rawPtr == rhs.get();
}
template void NetObjTemporaryPtr::send_client_update(const std::string& channel, std::function&, cereal::PortableBinaryOutputArchive&)> sendUpdateFunc) const {
NetObjManager::send_client_update(*this, channel, sendUpdateFunc);
}
template void NetObjTemporaryPtr::send_server_update_to_all_clients(const std::string& channel, std::function&, cereal::PortableBinaryOutputArchive&)> sendUpdateFunc) const {
NetObjManager::send_server_update_to_all_clients(*this, channel, sendUpdateFunc);
}
template void NetObjTemporaryPtr::send_server_update_to_client(const std::shared_ptr& clientToSendTo, const std::string& channel, std::function&, cereal::PortableBinaryOutputArchive&)> sendUpdateFunc) const {
NetObjManager::send_server_update_to_client(*this, clientToSendTo, channel, sendUpdateFunc);
}
template void NetObjTemporaryPtr::send_server_update_to_all_clients_except(const std::shared_ptr& clientToNotSendTo, const std::string& channel, std::function&, cereal::PortableBinaryOutputArchive&)> sendUpdateFunc) const {
NetObjManager::send_server_update_to_all_clients_except(*this, clientToNotSendTo, channel, sendUpdateFunc);
}
template void NetObjTemporaryPtr::send_update_to_all(const std::string& channel, std::function&, cereal::PortableBinaryOutputArchive&)> sendUpdateFunc) const {
NetObjManager::send_update_to_all(*this, channel, sendUpdateFunc);
}
template void NetObjTemporaryPtr::write_create_message(cereal::PortableBinaryOutputArchive& a) const {
NetObjManager::write_create_message(*this, a);
}
template NetObjTemporaryPtr::NetObjTemporaryPtr(NetObjManager* initObjMan, NetObjID initID, T* initRawPtr):
objMan(initObjMan),
id(initID),
rawPtr(initRawPtr)
{}
}