INTRODUCTION
Overview
Download and Install
Documentation
Publications

REPOSITORY
Libraries

DEVELOPER
Dev Guide
Dashboard

PEOPLE
Contributors
Users

SourceForge.net Logo
Project
Download
Mailing lists

 

         
logwriterport.h
1 /*
2  * GearBox Project: Peer-Reviewed Open-Source Libraries for Robotics
3  * http://gearbox.sf.net/
4  * Copyright (c) 2008 Geoffrey Biggs
5  *
6  * flexiport flexible hardware data communications library.
7  *
8  * This distribution is licensed to you under the terms described in the LICENSE file included in
9  * this distribution.
10  *
11  * This work is a product of the National Institute of Advanced Industrial Science and Technology,
12  * Japan. Registration number: H20PRO-881
13  *
14  * This file is part of flexiport.
15  *
16  * flexiport is free software: you can redistribute it and/or modify it under the terms of the GNU
17  * Lesser General Public License as published by the Free Software Foundation, either version 3 of
18  * the License, or (at your option) any later version.
19  *
20  * flexiport is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
21  * even the implied warranty of 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 License along with flexiport.
25  * If not, see <http://www.gnu.org/licenses/>.
26  */
27 
28 #ifndef __LOGWRITERPORT_H
29 #define __LOGWRITERPORT_H
30 
31 #include "port.h"
32 
33 #include <map>
34 #include <string>
35 
40 namespace flexiport
41 {
42 
43 class LogFile;
44 
68 class FLEXIPORT_EXPORT LogWriterPort : public Port
69 {
70  public:
71  LogWriterPort (std::map<std::string, std::string> options);
72  ~LogWriterPort ();
73 
75  void Open ();
77  void Close ();
79  ssize_t Read (void * const buffer, size_t count);
81  ssize_t ReadFull (void * const buffer, size_t count);
83  ssize_t Skip (size_t count);
86  ssize_t SkipUntil (uint8_t terminator, unsigned int count);
88  ssize_t BytesAvailable ();
90  ssize_t BytesAvailableWait ();
92  ssize_t Write (const void * const buffer, size_t count);
94  void Flush ();
96  void Drain ();
98  std::string GetStatus () const;
100  void SetTimeout (Timeout timeout);
102  void SetCanRead (bool canRead);
104  void SetCanWrite (bool canWrite);
106  bool IsOpen () const;
107 
108  private:
109  Port *_port;
110  LogFile *_logFile;
111  std::string _logFileName;
112 
113  void CheckPort (bool read);
114 };
115 
116 } // namespace flexiport
117 
120 #endif // __LOGWRITERPORT_H
void Flush()
Flush the port's input and output buffers, discarding all data.
Definition: logwriterport.cpp:265
void SetCanWrite(bool canWrite)
Set the write permissions of the port.
Definition: logwriterport.cpp:300
void SetCanRead(bool canRead)
Set the read permissions of the port.
Definition: logwriterport.cpp:294
virtual void Flush()=0
Flush the port's input and output buffers, discarding all data.
void Drain()
Drain the port's input and output buffers.
Definition: logwriterport.cpp:270
Logging implementation of the Port class. An underlying Port object is used to perform the actual com...
Definition: logwriterport.h:68
virtual bool IsOpen() const =0
Check if the port is open.
FlexiPort data communications library.
ssize_t SkipUntil(uint8_t terminator, unsigned int count)
Read and dump data until the specified termination character has been seen count times.
Definition: logwriterport.cpp:188
virtual void Open()=0
Open the port.
bool IsOpen() const
Check if the port is open.
Definition: logwriterport.cpp:306
virtual bool CanWrite() const
Get the write permissions of the port.
Definition: port.h:291
virtual ssize_t BytesAvailableWait()=0
Get the number of bytes waiting after blocking for the timeout.
Exception thrown by the Port class and its derivatives.
Definition: flexiport.h:54
void Open()
Open the port.
Definition: logwriterport.cpp:92
virtual void SetCanRead(bool canRead)=0
Set the read permissions of the port.
virtual bool IsBlocking() const
Get the blocking property of the port. If the timeout is non-zero, the port will block.
Definition: port.h:282
virtual void SetTimeout(Timeout timeout)=0
Set the timeout value. Set seconds to -1 to disable timeouts and block forever.
std::string GetStatus() const
Get the status of the port (type, device, etc).
Definition: logwriterport.cpp:279
An object used to represent timeouts.
Definition: timeout.h:62
ssize_t Write(const void *const buffer, size_t count)
Write data to the port.
Definition: logwriterport.cpp:250
ssize_t Read(void *const buffer, size_t count)
Read from the port.
Definition: logwriterport.cpp:119
ssize_t BytesAvailable()
Get the number of bytes waiting to be read at the port. Returns immediatly.
Definition: logwriterport.cpp:236
virtual ssize_t BytesAvailable()=0
Get the number of bytes waiting to be read at the port. Returns immediatly.
void SetTimeout(Timeout timeout)
Set the timeout value in milliseconds.
Definition: logwriterport.cpp:289
ssize_t ReadFull(void *const buffer, size_t count)
Read the requested quantity of data from the port.
Definition: logwriterport.cpp:134
virtual void Close()=0
Close the port.
virtual ssize_t Read(void *const buffer, size_t count)=0
Read from the port.
void Close()
Close the port.
Definition: logwriterport.cpp:104
ssize_t BytesAvailableWait()
Get the number of bytes waiting after blocking for the timeout.
Definition: logwriterport.cpp:241
virtual void Drain()=0
Drain the port's output buffers.
ssize_t Skip(size_t count)
Dump data until the specified number of bytes have been read.
Definition: logwriterport.cpp:149
virtual ssize_t ReadFull(void *const buffer, size_t count)=0
Read the requested quantity of data from the port.
virtual void SetCanWrite(bool canWrite)=0
Set the write permissions of the port.
virtual ssize_t Write(const void *const buffer, size_t count)=0
Write data to the port.
Base Port class.
Definition: port.h:79
virtual std::string GetStatus() const
Get the status of the port (type, device, etc).
Definition: port.cpp:352
virtual bool CanRead() const
Get the read permissions of the port.
Definition: port.h:287
 

Generated for GearBox by  doxygen 1.4.5