Flexiport  2.0.0
logwriterport.h
Go to the documentation of this file.
1 /* Flexiport
2  *
3  * Header file for the LogWriterPort 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 __LOGWRITERPORT_H
30 #define __LOGWRITERPORT_H
31 
32 #include <flexiport/port.h>
33 
34 #include <map>
35 #include <string>
36 
41 namespace flexiport
42 {
43 
44 class LogFile;
45 
73 {
74  public:
75  LogWriterPort (std::map<std::string, std::string> options);
76  ~LogWriterPort ();
77 
79  void Open ();
81  void Close ();
83  ssize_t Read (void * const buffer, size_t count);
85  ssize_t ReadFull (void * const buffer, size_t count);
87  ssize_t Skip (size_t count);
90  ssize_t SkipUntil (uint8_t terminator, unsigned int count);
92  ssize_t BytesAvailable ();
94  ssize_t BytesAvailableWait ();
96  ssize_t Write (const void * const buffer, size_t count);
98  void Flush ();
100  void Drain ();
102  std::string GetStatus () const;
104  void SetTimeout (Timeout timeout);
106  void SetCanRead (bool canRead);
108  void SetCanWrite (bool canWrite);
110  bool IsOpen () const;
111 
112  private:
113  Port *_port;
114  LogFile *_logFile;
115  std::string _logFileName;
116 
117  void CheckPort (bool read);
118 };
119 
120 } // namespace flexiport
121 
124 #endif // __LOGWRITERPORT_H
125 
Logging implementation of the Port class.
Definition: logwriterport.h:72
#define FLEXIPORT_EXPORT
Definition: flexiport.h:44
Base Port class.
Definition: port.h:81
An object used to represent timeouts.
Definition: timeout.h:63