source: rtems/c/src/lib/include/rtems++/rtemsEvent.h @ b29378e

4.104.114.84.95
Last change on this file since b29378e was 0074691a, checked in by Joel Sherrill <joel.sherrill@…>, on 07/31/97 at 22:13:29

Merged very large and much appreciated patch from Chris Johns
<cjohns@…>. This patch includes the ods68302 bsp,
the RTEMS++ class library, and the rtems++ test.

  • Property mode set to 100644
File size: 4.0 KB
Line 
1/*
2  ------------------------------------------------------------------------
3  $Id$
4  ------------------------------------------------------------------------
5
6  COPYRIGHT (c) 1997
7  Objective Design Systems Ltd Pty (ODS)
8  All rights reserved (R) Objective Design Systems Ltd Pty
9 
10  The license and distribution terms for this file may be found in the
11  file LICENSE in this distribution or at
12  http://www.OARcorp.com/rtems/license.html.
13
14  ------------------------------------------------------------------------
15
16  rtemsEvent class.
17
18  This class allows the user to send and receive RTEMS events to a task.
19
20  ------------------------------------------------------------------------ */
21
22#if !defined(_rtemsEvent_h_)
23#define _rtemsEvent_h_
24
25#include <rtems++/rtemsStatusCode.h>
26#include <rtems++/rtemsTask.h>
27
28/* ----
29    rtemsEvent
30*/
31
32class rtemsEvent
33  : public rtemsStatusCode
34{
35public:
36  // attribute a task can have
37 
38  enum WaitMode { wait = RTEMS_WAIT,
39                  no_wait = RTEMS_NO_WAIT};
40  enum Condition { any = RTEMS_EVENT_ANY,
41                   all = RTEMS_EVENT_ALL};
42 
43  // only the first 4 characters of the name are taken 
44
45  // connect to a task
46  rtemsEvent(const char* name, rtems_unsigned32 node = RTEMS_SEARCH_ALL_NODES);
47
48  // copy and default constructors
49  rtemsEvent(const rtemsEvent& event);
50  rtemsEvent();
51 
52  virtual ~rtemsEvent();   
53 
54  // connect to an existing task object, will not be the owner
55  const rtemsEvent& operator=(const rtemsEvent& event);
56  virtual const rtems_status_code connect(const char *name,
57                                          const rtems_unsigned32 node = RTEMS_SEARCH_ALL_NODES);
58 
59  // send an event
60  inline const rtems_status_code send(const rtems_id task,
61                                      const rtems_event_set events);
62  inline const rtems_status_code send(const rtemsTask& task,
63                                      const rtems_event_set events) ;
64  inline const rtems_status_code send(const rtems_event_set events);
65
66  // receive an event, can block a task if no events waiting
67  inline const rtems_status_code receive(const rtems_event_set event_in,
68                                         rtems_event_set& event_out,
69                                         const rtems_interval micro_secs = 0,
70                                         const WaitMode wait = wait,
71                                         const Condition condition = any);
72
73  // object id, and name
74  const rtems_id task_id_is() const { return id; }
75  const rtems_name task_name_is() const { return name; }
76 
77private:   
78  // task name
79  rtems_name name;
80
81  // the rtems task id, object handle
82  rtems_id id;
83
84};
85
86const rtems_status_code rtemsEvent::send(const rtems_id task,
87                                         const rtems_event_set events)
88{
89  set_status_code(rtems_event_send(task, events));
90  return last_status_code();
91}
92
93const rtems_status_code rtemsEvent::send(const rtemsTask& task,
94                                         const rtems_event_set events)
95{
96  set_status_code(rtems_event_send(task.id_is(), events));
97  return last_status_code();
98}
99
100const rtems_status_code rtemsEvent::send(const rtems_event_set events)
101{
102  set_status_code(rtems_event_send(id, events));
103  return last_status_code();
104}
105
106const rtems_status_code rtemsEvent::receive(const rtems_event_set event_in,
107                                            rtems_event_set& event_out,
108                                            const rtems_interval micro_secs,
109                                            const WaitMode wait,
110                                            const Condition condition)
111{
112  rtems_interval usecs =
113    micro_secs && (micro_secs < _TOD_Microseconds_per_tick) ?
114    _TOD_Microseconds_per_tick : micro_secs;
115  set_status_code(rtems_event_receive(event_in,
116                                      wait | condition,
117                                      TOD_MICROSECONDS_TO_TICKS(usecs),
118                                      &event_out));
119  return last_status_code();
120}
121
122#endif  // _rtemsEvent_h_
123
124
125
126
127
Note: See TracBrowser for help on using the repository browser.