Instrument Neutral Distributed Interface INDI  2.0.2
ConnectionMock.h
Go to the documentation of this file.
1 /*******************************************************************************
2  Copyright(c) 2022 Ludovic Pollet. All rights reserved.
3 
4  This library is free software; you can redistribute it and/or
5  modify it under the terms of the GNU Library General Public
6  License version 2 as published by the Free Software Foundation.
7 
8  This library is distributed in the hope that it will be useful,
9  but WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  Library General Public License for more details.
12 
13  You should have received a copy of the GNU Library General Public License
14  along with this library; see the file COPYING.LIB. If not, write to
15  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16  Boston, MA 02110-1301, USA.
17 *******************************************************************************/
18 
19 #ifndef CONNECTION_MOCK_H_
20 #define CONNECTION_MOCK_H_ 1
21 
22 #include <string>
23 #include <list>
24 
25 class SharedBuffer;
26 
31 {
32  int fds[2];
33  std::list<int> receivedFds;
34  bool bufferReceiveAllowed;
35  ssize_t read(void * buff, size_t count);
36  char readChar(const std::string &expected);
37 
38  void release();
39  std::string receiveMore();
40 
41  // On error, contains data that were not returned
42  std::string pendingData;
43  public:
46  void setFds(int rd, int wr);
47  // shutdown part of the socket
48  void shutdown(bool rd, bool wr);
49 
50  void expect(const std::string &content);
51  void expectXml(const std::string &xml);
52  void send(const std::string &content);
53  void send(const std::string &content, const SharedBuffer &buff);
54  void send(const std::string &content, const SharedBuffer ** buffers);
55 
56  void allowBufferReceive(bool state);
58 };
59 
60 
61 #endif // CONNECTION_MOCK_H_
void allowBufferReceive(bool state)
void expectBuffer(SharedBuffer &fd)
void shutdown(bool rd, bool wr)
void expect(const std::string &content)
void send(const std::string &content)
void setFds(int rd, int wr)
void expectXml(const std::string &xml)
int fd
Definition: intelliscope.c:43