dummyport.cpp
1 /***************************************************************************
2  Copyright (C) 2002-2015 Kentaro Kitagawa
3  kitagawa@phys.s.u-tokyo.ac.jp
4 
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Library General Public
7  License as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later version.
9 
10  You should have received a copy of the GNU Library General
11  Public License and a list of authors along with this program;
12  see the files COPYING and AUTHORS.
13 ***************************************************************************/
14 #include "dummyport.h"
15 
16 #if defined __WIN32__ || defined WINDOWS || defined _WIN32
17  #define DUMMYPORT_FILENAME "kamedummyport.log"
18 #else
19  #define DUMMYPORT_FILENAME "/tmp/kamedummyport.log"
20 #endif
21 
22 XDummyPort::XDummyPort(XCharInterface *interface) :
23  XPort(interface),
24  m_stream()
25 {
26 }
27 XDummyPort::~XDummyPort()
28 {
29  m_stream.close();
30 }
31 void
32 XDummyPort::open(const XCharInterface *pInterface) throw (XInterface::XCommError &)
33 {
34  m_stream.open(DUMMYPORT_FILENAME, std::ios::out);
35 }
36 void
37 XDummyPort::send(const char *str) throw (XInterface::XCommError &)
38 {
39  m_stream << "send:"
40  << str << std::endl;
41 }
42 void
43 XDummyPort::write(const char *sendbuf, int size) throw (XInterface::XCommError &)
44 {
45  m_stream << "write:";
46  m_stream.write(sendbuf, size);
47  m_stream << std::endl;
48 }
49 void
50 XDummyPort::receive() throw (XInterface::XCommError &)
51 {
52  m_stream << "receive:"
53  << std::endl;
54  buffer().resize(1);
55  buffer()[0] = '\0';
56 }
57 void
58 XDummyPort::receive(unsigned int length) throw (XInterface::XCommError &)
59 {
60  m_stream << "receive length = :"
61  << length << std::endl;
62  buffer().resize(length);
63  buffer()[0] = '\0';
64 }

Generated for KAME4 by  doxygen 1.8.3