INTRODUCTION Overview Download and Install Documentation Publications REPOSITORY Libraries DEVELOPER Dev Guide Dashboard PEOPLE Contributors Users Project Download Mailing lists
|
timeout.h00001 /* 00002 * GearBox Project: Peer-Reviewed Open-Source Libraries for Robotics 00003 * http://gearbox.sf.net/ 00004 * Copyright (c) 2008 Geoffrey Biggs 00005 * 00006 * flexiport flexible hardware data communications library. 00007 * 00008 * This distribution is licensed to you under the terms described in the LICENSE file included in 00009 * this distribution. 00010 * 00011 * This work is a product of the National Institute of Advanced Industrial Science and Technology, 00012 * Japan. Registration number: H20PRO-881 00013 * 00014 * This file is part of flexiport. 00015 * 00016 * flexiport is free software: you can redistribute it and/or modify it under the terms of the GNU 00017 * Lesser General Public License as published by the Free Software Foundation, either version 3 of 00018 * the License, or (at your option) any later version. 00019 * 00020 * flexiport is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without 00021 * even the implied warranty of 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 License along with flexiport. 00025 * If not, see <http://www.gnu.org/licenses/>. 00026 */ 00027 00028 #ifndef __TIMEOUT_H 00029 #define __TIMEOUT_H 00030 00031 #if defined (WIN32) 00032 #if defined (FLEXIPORT_STATIC) 00033 #define FLEXIPORT_EXPORT 00034 #elif defined (FLEXIPORT_EXPORTS) 00035 #define FLEXIPORT_EXPORT __declspec (dllexport) 00036 #else 00037 #define FLEXIPORT_EXPORT __declspec (dllimport) 00038 #endif 00039 #if !defined (timespec) 00040 // No timespec on Windows 00041 typedef struct timespec 00042 { 00043 int tv_sec; 00044 int tv_nsec; 00045 } timespec; 00046 #endif 00047 #else 00048 #define FLEXIPORT_EXPORT 00049 #endif 00050 00051 struct timeval; 00052 struct timespec; 00053 00058 namespace flexiport 00059 { 00060 00062 class FLEXIPORT_EXPORT Timeout 00063 { 00064 public: 00065 Timeout (int sec, int usec) : _sec (sec), _usec (usec) {} 00066 Timeout (const Timeout &rhs) : _sec (rhs._sec), _usec (rhs._usec) {} 00067 00068 void AsTimeval (struct timeval &dest) const; 00069 void FromTimeval (const struct timeval &src); 00070 void AsTimespec (struct timespec &dest) const; 00071 void FromTimespec (const struct timespec &src); 00072 00073 Timeout& operator= (const Timeout &rhs); 00074 Timeout& operator= (const struct timeval &rhs); 00075 Timeout& operator= (const struct timespec &rhs); 00076 00077 int _sec; 00078 int _usec; 00079 }; 00080 00081 } // namespace flexiport 00082 00085 #endif // __TIMEOUT_H |