COSA
An Object-Oriented Platform for Arduino Programming
Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
IOEvent.hh
Go to the documentation of this file.
1
21
#ifndef COSA_IOEVENT_HH
22
#define COSA_IOEVENT_HH
23
24
#include "
Cosa/Types.h
"
25
#include "
Cosa/Event.hh
"
26
#include "
Cosa/IOStream.hh
"
27
35
template
<
typename
DEVICE>
36
class
IOEvent
:
public
DEVICE {
37
public
:
41
IOEvent
(
Event::Handler
* handler) : DEVICE(),
m_handler
(handler) {}
42
49
virtual
int
putchar
(
char
c)
50
{
51
int
res = DEVICE::putchar(c);
52
if
(
UNLIKELY
(c ==
'\n'
|| DEVICE::room() == 0))
53
Event::push
(
Event::RECEIVE_COMPLETED_TYPE
,
m_handler
,
this
);
54
return
(res);
55
}
56
62
virtual
int
getchar
()
63
{
64
int
res = DEVICE::getchar();
65
if
(
UNLIKELY
(res ==
IOStream::EOF
))
66
Event::push
(
Event::SEND_COMPLETED_TYPE
,
m_handler
,
this
);
67
return
(res);
68
}
69
70
protected
:
71
Event::Handler
*
m_handler
;
72
};
73
74
#endif
Event.hh
Types.h
IOEvent::m_handler
Event::Handler * m_handler
Definition:
IOEvent.hh:71
IOEvent
Definition:
IOEvent.hh:36
IOEvent::putchar
virtual int putchar(char c)
Definition:
IOEvent.hh:49
IOStream.hh
IOEvent::IOEvent
IOEvent(Event::Handler *handler)
Definition:
IOEvent.hh:41
Event::SEND_COMPLETED_TYPE
Definition:
Event.hh:76
IOStream::EOF
static const int EOF
Definition:
IOStream.hh:33
IOEvent::getchar
virtual int getchar()
Definition:
IOEvent.hh:62
Event::RECEIVE_COMPLETED_TYPE
Definition:
Event.hh:74
UNLIKELY
#define UNLIKELY(x)
Definition:
Types.h:153
Event::push
static bool push(uint8_t type, Handler *target, uint16_t value=0)
Definition:
Event.hh:180
Event::Handler
Definition:
Event.hh:98
cores
cosa
Cosa
IOEvent.hh
Generated on Thu Aug 31 2017 17:02:02 for COSA by
1.8.11