Network: Add SocketPoller class
Former-commit-id: 86b9266d904551d19e7ec8e8d6bbe5f137e8d29f [formerly 34575937d84f796cfe36a5ab97ea1f787c1506ba] [formerly 6c8c621523800958ad38eef118fcb3687c34b367 [formerly a1f1330fbe6f990a21bbe6dccfe727edec0e2b44]] Former-commit-id: 6635c463a753f744b835267181b51ed89620b627 [formerly 14e84c7155cd669ac20a5492e67704059a442925] Former-commit-id: 7becccdf2d8aac7cdf526d855215d7d144be284c
This commit is contained in:
44
include/Nazara/Network/SocketPoller.hpp
Normal file
44
include/Nazara/Network/SocketPoller.hpp
Normal file
@@ -0,0 +1,44 @@
|
||||
// Copyright (C) 2015 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Network module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#pragma once
|
||||
|
||||
#ifndef NAZARA_SOCKETPOLLER_HPP
|
||||
#define NAZARA_SOCKETPOLLER_HPP
|
||||
|
||||
#include <Nazara/Prerequesites.hpp>
|
||||
#include <Nazara/Network/AbstractSocket.hpp>
|
||||
#include <Nazara/Network/IpAddress.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
class SocketPollerImpl;
|
||||
|
||||
class NAZARA_NETWORK_API SocketPoller
|
||||
{
|
||||
public:
|
||||
SocketPoller();
|
||||
inline SocketPoller(SocketPoller&& socketPoller);
|
||||
~SocketPoller() = default;
|
||||
|
||||
void Clear();
|
||||
|
||||
bool IsReady(const AbstractSocket& socket) const;
|
||||
bool IsRegistered(const AbstractSocket& socket) const;
|
||||
|
||||
bool RegisterSocket(AbstractSocket& socket);
|
||||
void UnregisterSocket(AbstractSocket& socket);
|
||||
|
||||
bool Wait(UInt64 msTimeout);
|
||||
|
||||
inline SocketPoller& operator=(SocketPoller&& socketPoller);
|
||||
|
||||
private:
|
||||
SocketPollerImpl* m_impl;
|
||||
};
|
||||
}
|
||||
|
||||
#include <Nazara/Network/SocketPoller.inl>
|
||||
|
||||
#endif // NAZARA_SOCKETPOLLER_HPP
|
||||
37
include/Nazara/Network/SocketPoller.inl
Normal file
37
include/Nazara/Network/SocketPoller.inl
Normal file
@@ -0,0 +1,37 @@
|
||||
// Copyright (C) 2015 Jérôme Leclercq
|
||||
// This file is part of the "Nazara Engine - Network module"
|
||||
// For conditions of distribution and use, see copyright notice in Config.hpp
|
||||
|
||||
#include <Nazara/Network/SocketPoller.hpp>
|
||||
#include <utility>
|
||||
#include <Nazara/Network/Debug.hpp>
|
||||
|
||||
namespace Nz
|
||||
{
|
||||
/*!
|
||||
* \brief Constructs a SocketPoller object with another one by move semantic
|
||||
*
|
||||
* \param socketPoller SocketPoller to move into this
|
||||
*/
|
||||
inline SocketPoller::SocketPoller(SocketPoller&& socketPoller) :
|
||||
m_impl(socketPoller.m_impl)
|
||||
{
|
||||
socketPoller.m_impl = nullptr;
|
||||
}
|
||||
|
||||
/*!
|
||||
* \brief Moves the SocketPoller into this
|
||||
* \return A reference to this
|
||||
*
|
||||
* \param socketPoller SocketPoller to move in this
|
||||
*/
|
||||
inline SocketPoller& SocketPoller::operator=(SocketPoller&& socketPoller)
|
||||
{
|
||||
m_impl = socketPoller.m_impl;
|
||||
socketPoller.m_impl = nullptr;
|
||||
|
||||
return *this;
|
||||
}
|
||||
}
|
||||
|
||||
#include <Nazara/Network/DebugOff.hpp>
|
||||
Reference in New Issue
Block a user