Flexiport 2.0.0
|
00001 /* Flexiport 00002 * 00003 * Header file for the timeout object. 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 __TIMEOUT_H 00030 #define __TIMEOUT_H 00031 00032 #if defined (WIN32) 00033 #if defined (FLEXIPORT_STATIC) 00034 #define FLEXIPORT_EXPORT 00035 #elif defined (flexiport_EXPORTS) 00036 #define FLEXIPORT_EXPORT __declspec (dllexport) 00037 #else 00038 #define FLEXIPORT_EXPORT __declspec (dllimport) 00039 #endif 00040 #if !defined (timespec) 00041 // No timespec on Windows 00042 typedef struct timespec 00043 { 00044 int tv_sec; 00045 int tv_nsec; 00046 } timespec; 00047 #endif 00048 #else 00049 #define FLEXIPORT_EXPORT 00050 #endif 00051 00052 struct timeval; 00053 struct timespec; 00054 00059 namespace flexiport 00060 { 00061 00063 class FLEXIPORT_EXPORT Timeout 00064 { 00065 public: 00066 Timeout (int sec, int usec) : _sec (sec), _usec (usec) {} 00067 Timeout (const Timeout &rhs) : _sec (rhs._sec), _usec (rhs._usec) {} 00068 00069 void AsTimeval (struct timeval &dest) const; 00070 void FromTimeval (const struct timeval &src); 00071 void AsTimespec (struct timespec &dest) const; 00072 void FromTimespec (const struct timespec &src); 00073 00074 Timeout& operator= (const Timeout &rhs); 00075 Timeout& operator= (const struct timeval &rhs); 00076 Timeout& operator= (const struct timespec &rhs); 00077 00078 int _sec; 00079 int _usec; 00080 }; 00081 00082 } // namespace flexiport 00083 00086 #endif // __TIMEOUT_H 00087