Flexiport 2.0.0
timeout.h
Go to the documentation of this file.
1/* Flexiport
2 *
3 * Header file for the timeout object.
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 __TIMEOUT_H
30#define __TIMEOUT_H
31
32#if defined (WIN32)
33 #if defined (FLEXIPORT_STATIC)
34 #define FLEXIPORT_EXPORT
35 #elif defined (flexiport_EXPORTS)
36 #define FLEXIPORT_EXPORT __declspec (dllexport)
37 #else
38 #define FLEXIPORT_EXPORT __declspec (dllimport)
39 #endif
40 #if !defined (timespec)
41 // No timespec on Windows
42 typedef struct timespec
43 {
44 int tv_sec;
45 int tv_nsec;
46 } timespec;
47 #endif
48#else
49 #define FLEXIPORT_EXPORT
50#endif
51
52struct timeval;
53struct timespec;
54
59namespace flexiport
60{
61
64{
65 public:
66 Timeout (int sec, int usec) : _sec (sec), _usec (usec) {}
67 Timeout (const Timeout &rhs) : _sec (rhs._sec), _usec (rhs._usec) {}
68
69 void AsTimeval (struct timeval &dest) const;
70 void FromTimeval (const struct timeval &src);
71 void AsTimespec (struct timespec &dest) const;
72 void FromTimespec (const struct timespec &src);
73
74 Timeout& operator= (const Timeout &rhs);
75 Timeout& operator= (const struct timeval &rhs);
76 Timeout& operator= (const struct timespec &rhs);
77
78 int _sec;
79 int _usec;
80};
81
82} // namespace flexiport
83
86#endif // __TIMEOUT_H
87
An object used to represent timeouts.
Definition: timeout.h:64
void FromTimeval(const struct timeval &src)
void AsTimeval(struct timeval &dest) const
Timeout(const Timeout &rhs)
Definition: timeout.h:67
void AsTimespec(struct timespec &dest) const
void FromTimespec(const struct timespec &src)
Timeout(int sec, int usec)
Definition: timeout.h:66
#define FLEXIPORT_EXPORT
Definition: flexiport.h:44