cmake/Source/cmServerConnection.h

68 lines
1.5 KiB
C
Raw Normal View History

2016-10-30 18:24:19 +01:00
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#pragma once
2018-01-26 17:06:56 +01:00
#include "cmConfigure.h" // IWYU pragma: keep
2016-10-30 18:24:19 +01:00
2017-07-20 19:35:53 +02:00
#include <string>
2018-01-26 17:06:56 +01:00
#include "cmConnection.h"
#include "cmPipeConnection.h"
2018-04-23 21:13:27 +02:00
#include "cmUVHandlePtr.h"
2016-10-30 18:24:19 +01:00
2018-01-26 17:06:56 +01:00
class cmServerBase;
2017-07-20 19:35:53 +02:00
2018-01-26 17:06:56 +01:00
/***
* This connection buffer strategy accepts messages in the form of
* [== "CMake Server" ==[
{
... some JSON message ...
}
]== "CMake Server" ==]
* and only passes on the core json; it discards the envelope.
*/
class cmServerBufferStrategy : public cmConnectionBufferStrategy
{
2016-10-30 18:24:19 +01:00
public:
2018-01-26 17:06:56 +01:00
std::string BufferMessage(std::string& rawBuffer) override;
std::string BufferOutMessage(const std::string& rawBuffer) const override;
2016-10-30 18:24:19 +01:00
2018-01-26 17:06:56 +01:00
private:
std::string RequestBuffer;
};
2016-10-30 18:24:19 +01:00
2018-01-26 17:06:56 +01:00
/***
* Generic connection over std io interfaces -- tty
*/
class cmStdIoConnection : public cmEventBasedConnection
{
public:
cmStdIoConnection(cmConnectionBufferStrategy* bufferStrategy);
2016-10-30 18:24:19 +01:00
2018-01-26 17:06:56 +01:00
void SetServer(cmServerBase* s) override;
2016-10-30 18:24:19 +01:00
2018-01-26 17:06:56 +01:00
bool OnConnectionShuttingDown() override;
2016-10-30 18:24:19 +01:00
2018-01-26 17:06:56 +01:00
bool OnServeStart(std::string* pString) override;
2016-10-30 18:24:19 +01:00
private:
2018-04-23 21:13:27 +02:00
cm::uv_stream_ptr SetupStream(int file_id);
cm::uv_stream_ptr ReadStream;
2016-10-30 18:24:19 +01:00
};
2018-01-26 17:06:56 +01:00
/***
* These specific connections use the cmake server
* buffering strategy.
*/
class cmServerStdIoConnection : public cmStdIoConnection
2016-10-30 18:24:19 +01:00
{
public:
cmServerStdIoConnection();
};
2018-01-26 17:06:56 +01:00
class cmServerPipeConnection : public cmPipeConnection
2016-10-30 18:24:19 +01:00
{
public:
cmServerPipeConnection(const std::string& name);
};