2012-06-10 16:50:54 +00:00
|
|
|
/*
|
2018-01-27 21:48:17 +00:00
|
|
|
* barrier -- mouse and keyboard sharing utility
|
2016-09-07 14:24:00 +00:00
|
|
|
* Copyright (C) 2012-2016 Symless Ltd.
|
2012-09-04 02:09:56 +00:00
|
|
|
* Copyright (C) 2004 Chris Schoeneman
|
2012-06-10 16:50:54 +00:00
|
|
|
*
|
|
|
|
* This package is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
2015-05-03 02:33:52 +00:00
|
|
|
* found in the file LICENSE that should have accompanied this file.
|
2012-06-10 16:50:54 +00:00
|
|
|
*
|
|
|
|
* This package 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 <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2014-02-28 12:36:45 +00:00
|
|
|
#pragma once
|
2012-06-10 16:50:54 +00:00
|
|
|
|
2014-02-28 12:36:45 +00:00
|
|
|
#include "arch/IArchNetwork.h"
|
|
|
|
#include "common/IInterface.h"
|
2019-08-17 13:17:50 +00:00
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
class ISocketMultiplexerJob;
|
|
|
|
|
|
|
|
struct MultiplexerJobStatus
|
|
|
|
{
|
|
|
|
MultiplexerJobStatus(bool cont, std::unique_ptr<ISocketMultiplexerJob>&& nj) :
|
|
|
|
continue_servicing(cont), new_job(std::move(nj))
|
|
|
|
{}
|
|
|
|
|
|
|
|
bool continue_servicing = false;
|
|
|
|
std::unique_ptr<ISocketMultiplexerJob> new_job;
|
|
|
|
};
|
2012-06-10 16:50:54 +00:00
|
|
|
|
|
|
|
//! Socket multiplexer job
|
|
|
|
/*!
|
|
|
|
A socket multiplexer job handles events on a socket.
|
|
|
|
*/
|
|
|
|
class ISocketMultiplexerJob : public IInterface {
|
|
|
|
public:
|
2016-12-28 11:50:32 +00:00
|
|
|
//! @name manipulators
|
|
|
|
//@{
|
2012-06-10 16:50:54 +00:00
|
|
|
|
2016-12-28 11:50:32 +00:00
|
|
|
//! Handle socket event
|
|
|
|
/*!
|
2019-08-17 13:17:50 +00:00
|
|
|
Called by a socket multiplexer when the socket becomes readable, writable, or has an error.
|
|
|
|
The socket is readable if \p readable is true, writable if \p writable is true, and in error
|
|
|
|
if \p error is true.
|
|
|
|
|
|
|
|
The method returns false as the continue_servicing member of the returned struct if the socket
|
|
|
|
should no longer be served and true otherwise. Additionally, if the new_job member of the
|
|
|
|
returned pair is not empty, the socket should be serviced differently with the specified job.
|
2012-06-10 16:50:54 +00:00
|
|
|
|
2016-12-28 11:50:32 +00:00
|
|
|
This call must not attempt to directly change the job for this
|
|
|
|
socket by calling \c addSocket() or \c removeSocket() on the
|
|
|
|
multiplexer. It must instead return the new job. It can,
|
|
|
|
however, add or remove jobs for other sockets.
|
|
|
|
*/
|
2019-08-17 13:17:50 +00:00
|
|
|
virtual MultiplexerJobStatus run(bool readable, bool writable, bool error) = 0;
|
2012-06-10 16:50:54 +00:00
|
|
|
|
2016-12-28 11:50:32 +00:00
|
|
|
//@}
|
|
|
|
//! @name accessors
|
|
|
|
//@{
|
2012-06-10 16:50:54 +00:00
|
|
|
|
2016-12-28 11:50:32 +00:00
|
|
|
//! Get the socket
|
|
|
|
/*!
|
|
|
|
Return the socket to multiplex
|
|
|
|
*/
|
|
|
|
virtual ArchSocket getSocket() const = 0;
|
2012-06-10 16:50:54 +00:00
|
|
|
|
2016-12-28 11:50:32 +00:00
|
|
|
//! Check for interest in readability
|
|
|
|
/*!
|
|
|
|
Return true if the job is interested in being run if the socket
|
|
|
|
becomes readable.
|
|
|
|
*/
|
|
|
|
virtual bool isReadable() const = 0;
|
2012-06-10 16:50:54 +00:00
|
|
|
|
2016-12-28 11:50:32 +00:00
|
|
|
//! Check for interest in writability
|
|
|
|
/*!
|
|
|
|
Return true if the job is interested in being run if the socket
|
|
|
|
becomes writable.
|
|
|
|
*/
|
|
|
|
virtual bool isWritable() const = 0;
|
2012-06-10 16:50:54 +00:00
|
|
|
|
2019-08-17 13:17:50 +00:00
|
|
|
virtual bool isCursor() const { return false; }
|
2016-12-28 11:50:32 +00:00
|
|
|
//@}
|
2012-06-10 16:50:54 +00:00
|
|
|
};
|