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);
86  ~LogReaderPort ();
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 
Simulated port using a log file.
Definition: logreaderport.h:82
#define FLEXIPORT_EXPORT
Definition: flexiport.h:44
Base Port class.
Definition: port.h:81
An object used to represent timeouts.
Definition: timeout.h:63