tic
130
INdep
src
time
tic.130
loop.hxx
1
#ifndef _CPLRAW_LOOP_HXX
2
#define _CPLRAW_LOOP_HXX
3
4
#include <iostream>
5
#if defined(MMSYS_linux)
6
#include <fcntl.h>
7
#include <unistd.h>
8
#include <poll.h>
9
#else
10
#include <conio.h>
11
#endif
12
13
class
Loop
{
14
int
_fBreak;
15
int
_iLoop;
16
17
#if defined(MMSYS_linux)
18
int
kbhit()
19
{
20
struct
timeval tv = { 0L, 0L };
21
fd_set fds;
22
FD_ZERO(&fds);
23
FD_SET(0, &fds);
24
return
select(1, &fds, NULL, NULL, &tv);
25
}
26
#else
27
int
kbhit() {
return
_kbhit(); }
28
#endif
29
30
public
:
31
int
isBreak() {
return
_fBreak; }
32
33
int
proceed() {
34
const
char
*sz=
"-\\|/"
;
35
std::cout <<
'\r'
<< sz[_iLoop++ % 4] << std::flush ;
36
_fBreak=kbhit();
37
return
!_fBreak;
38
}
39
Loop
():_fBreak(0),_iLoop(0) { }
40
~
Loop
() {}
41
};
42
43
44
#endif
Loop
Definition:
loop.hxx:13
Generated by
1.8.13