/*
* 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 "NetObjID.hpp"
#include
#include
#include "NetObjOwnerPtr.decl.hpp"
#include "../Networking/NetServer.hpp"
namespace NetworkingObjects {
class NetObjManager;
template class NetObjTemporaryPtr {
public:
NetObjTemporaryPtr();
NetObjTemporaryPtr(const NetObjTemporaryPtr& other);
NetObjTemporaryPtr(const NetObjOwnerPtr& owner);
NetObjTemporaryPtr& operator=(const NetObjTemporaryPtr& other);
template NetObjTemporaryPtr cast() const;
NetObjManager* get_obj_man() const;
NetObjID get_net_id() const;
T* get() const;
std::add_lvalue_reference_t operator*() const requires(!std::is_void_v);
T* operator->() const;
operator bool() const;
bool operator!=(const NetObjTemporaryPtr& rhs) const;
bool operator==(const NetObjTemporaryPtr& rhs) const;
bool operator!=(const NetObjOwnerPtr& rhs) const;
bool operator==(const NetObjOwnerPtr& rhs) const;
void send_client_update(const std::string& channel, std::function&, cereal::PortableBinaryOutputArchive&)> sendUpdateFunc) const;
void send_server_update_to_client(const std::shared_ptr& clientToSendTo, const std::string& channel, std::function&, cereal::PortableBinaryOutputArchive&)> sendUpdateFunc) const;
void send_server_update_to_all_clients_except(const std::shared_ptr& clientToNotSendTo, const std::string& channel, std::function&, cereal::PortableBinaryOutputArchive&)> sendUpdateFunc) const;
void send_server_update_to_all_clients(const std::string& channel, std::function&, cereal::PortableBinaryOutputArchive&)> sendUpdateFunc) const;
void send_update_to_all(const std::string& channel, std::function&, cereal::PortableBinaryOutputArchive&)> sendUpdateFunc) const;
void write_create_message(cereal::PortableBinaryOutputArchive& a) const;
private:
friend class NetObjManager;
template friend class NetObjWeakPtr;
template friend class NetObjTemporaryPtr;
NetObjTemporaryPtr(NetObjManager* initObjMan, NetObjID initID, T* initRawPtr);
NetObjManager* objMan;
NetObjID id;
T* rawPtr;
};
}