Flexiport  2.0.0
logreaderport.h
Go to the documentation of this file.
1 /* Flexiport
2  *
3  * Header file for the LogReaderPort class.
4  *
5  * Copyright 2008-2011 Geoffrey Biggs geoffrey.biggs@aist.go.jp
6  * RT-Synthesis Research Group
7  * Intelligent Systems Research Institute,
8  * National Institute of Advanced Industrial Science and Technology (AIST),
9  * Japan
10  * All rights reserved.
11  *
12  * This file is part of Flexiport.
13  *
14  * Flexiport is free software; you can redistribute it and/or modify it
15  * under the terms of the GNU Lesser General Public License as published
16  * by the Free Software Foundation; either version 2.1 of the License,
17  * or (at your option) any later version.
18  *
19  * Flexiport is distributed in the hope that it will be useful, but
20  * WITHOUT ANY WARRANTY; without even the implied warranty of
21  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22  * Lesser General Public License for more details.
23  *
24  * You should have received a copy of the GNU Lesser General Public
25  * License along with Flexiport. If not, see
26  * <http://www.gnu.org/licenses/>.
27  */
28 
29 #ifndef __LOGREADERPORT_H
30 #define __LOGREADERPORT_H
31 
32 #include <flexiport/port.h>
33 
34 #include <map>
35 #include <string>
36 
41 namespace flexiport
42 {
43 
44 class LogFile;
45 
83 {
84  public:
85  LogReaderPort (std::map<std::string, std::string> options);
87 
89  void Open ();
91  void Close ();
93  ssize_t Read (void * const buffer, size_t count);
95  ssize_t ReadFull (void * const buffer, size_t count);
97  ssize_t BytesAvailable ();
99  ssize_t BytesAvailableWait ();
101  ssize_t Write (const void * const buffer, size_t count);
103  void Flush ();
105  void Drain ();
107  std::string GetStatus () const;
109  void SetTimeout (Timeout timeout);
111  void SetCanRead (bool canRead);
113  void SetCanWrite (bool canWrite);
115  bool IsOpen () const;
116 
117  private:
118  LogFile *_logFile;
119  std::string _logFileName;
120  unsigned int _strictness;
121  int _jitter;
122  bool _ignoreTimes;
123  bool _open;
124 
125  bool ProcessOption (const std::string &option, const std::string &value);
126  void CheckPort (bool read);
127 };
128 
129 } // namespace flexiport
130 
133 #endif // __LOGREADERPORT_H
134 
FLEXIPORT_EXPORT
#define FLEXIPORT_EXPORT
Definition: flexiport.h:44
flexiport::LogReaderPort::~LogReaderPort
~LogReaderPort()
port.h
flexiport::LogReaderPort::ReadFull
ssize_t ReadFull(void *const buffer, size_t count)
Read the requested quantity of data from the port.
flexiport
Definition: flexiport.h:52
flexiport::LogReaderPort
Simulated port using a log file.
Definition: logreaderport.h:83
flexiport::LogReaderPort::BytesAvailable
ssize_t BytesAvailable()
Get the number of bytes waiting to be read at the port. Returns immediatly.
flexiport::LogReaderPort::SetCanRead
void SetCanRead(bool canRead)
Set the read permissions of the port.
flexiport::LogReaderPort::GetStatus
std::string GetStatus() const
Get the status of the port (type, device, etc).
flexiport::LogReaderPort::Open
void Open()
Open the port.
flexiport::LogReaderPort::SetTimeout
void SetTimeout(Timeout timeout)
Set the timeout value in milliseconds.
flexiport::LogReaderPort::Flush
void Flush()
Flush the port's input and output buffers, discarding all data.
flexiport::LogFile
Definition: logfile.h:48
flexiport::LogReaderPort::LogReaderPort
LogReaderPort(std::map< std::string, std::string > options)
flexiport::LogReaderPort::Read
ssize_t Read(void *const buffer, size_t count)
Read from the port.
flexiport::LogReaderPort::SetCanWrite
void SetCanWrite(bool canWrite)
Set the write permissions of the port.
flexiport::LogReaderPort::BytesAvailableWait
ssize_t BytesAvailableWait()
Get the number of bytes waiting after blocking for the timeout.
flexiport::Port
Base Port class.
Definition: port.h:82
flexiport::LogReaderPort::Write
ssize_t Write(const void *const buffer, size_t count)
Write data to the port.
flexiport::LogReaderPort::IsOpen
bool IsOpen() const
Check if the port is open.
flexiport::LogReaderPort::Close
void Close()
Close the port.
flexiport::Timeout
An object used to represent timeouts.
Definition: timeout.h:64
flexiport::LogReaderPort::Drain
void Drain()
Drain the port's input and output buffers.