Flexiport 2.0.0
|
00001 /* Flexiport 00002 * 00003 * Header file for the LogWriterPort class. 00004 * 00005 * Copyright 2008-2011 Geoffrey Biggs geoffrey.biggs@aist.go.jp 00006 * RT-Synthesis Research Group 00007 * Intelligent Systems Research Institute, 00008 * National Institute of Advanced Industrial Science and Technology (AIST), 00009 * Japan 00010 * All rights reserved. 00011 * 00012 * This file is part of Flexiport. 00013 * 00014 * Flexiport is free software; you can redistribute it and/or modify it 00015 * under the terms of the GNU Lesser General Public License as published 00016 * by the Free Software Foundation; either version 2.1 of the License, 00017 * or (at your option) any later version. 00018 * 00019 * Flexiport is distributed in the hope that it will be useful, but 00020 * WITHOUT ANY WARRANTY; without even the implied warranty of 00021 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00022 * Lesser General Public License for more details. 00023 * 00024 * You should have received a copy of the GNU Lesser General Public 00025 * License along with Flexiport. If not, see 00026 * <http://www.gnu.org/licenses/>. 00027 */ 00028 00029 #ifndef __LOGWRITERPORT_H 00030 #define __LOGWRITERPORT_H 00031 00032 #include <flexiport/port.h> 00033 00034 #include <map> 00035 #include <string> 00036 00041 namespace flexiport 00042 { 00043 00044 class LogFile; 00045 00072 class FLEXIPORT_EXPORT LogWriterPort : public Port 00073 { 00074 public: 00075 LogWriterPort (std::map<std::string, std::string> options); 00076 ~LogWriterPort (); 00077 00079 void Open (); 00081 void Close (); 00083 ssize_t Read (void * const buffer, size_t count); 00085 ssize_t ReadFull (void * const buffer, size_t count); 00087 ssize_t Skip (size_t count); 00090 ssize_t SkipUntil (uint8_t terminator, unsigned int count); 00092 ssize_t BytesAvailable (); 00094 ssize_t BytesAvailableWait (); 00096 ssize_t Write (const void * const buffer, size_t count); 00098 void Flush (); 00100 void Drain (); 00102 std::string GetStatus () const; 00104 void SetTimeout (Timeout timeout); 00106 void SetCanRead (bool canRead); 00108 void SetCanWrite (bool canWrite); 00110 bool IsOpen () const; 00111 00112 private: 00113 Port *_port; 00114 LogFile *_logFile; 00115 std::string _logFileName; 00116 00117 void CheckPort (bool read); 00118 }; 00119 00120 } // namespace flexiport 00121 00124 #endif // __LOGWRITERPORT_H 00125