Last change
on this file since 120 was
85,
checked in by rosiere, 17 years ago
|
- Ifetch_unit : systemC test ok
- modif shell script and makefile.tools : SHELL=/bin/bash
|
-
Property svn:keywords set to
Id
|
File size:
1.5 KB
|
Line | |
---|
1 | #ifndef ENVIRONMENT_QUEUE_QUEUE_H |
---|
2 | #define ENVIRONMENT_QUEUE_QUEUE_H |
---|
3 | |
---|
4 | #include <stdint.h> |
---|
5 | #include <iostream> |
---|
6 | #include "Slot.h" |
---|
7 | |
---|
8 | namespace environment { |
---|
9 | namespace queue { |
---|
10 | |
---|
11 | template <class T> |
---|
12 | class Queue |
---|
13 | { |
---|
14 | protected : std::string _name; |
---|
15 | protected : uint32_t _nb_slot; // number of slot |
---|
16 | protected : uint32_t _size; // size of queue |
---|
17 | protected : slot_t<T> * _slot; |
---|
18 | |
---|
19 | public : Queue (std::string name, |
---|
20 | uint32_t size) |
---|
21 | { |
---|
22 | _name = name; |
---|
23 | _nb_slot = 0; |
---|
24 | _size = size; |
---|
25 | _slot = new slot_t<T> [size]; |
---|
26 | }; |
---|
27 | |
---|
28 | public : virtual ~Queue () |
---|
29 | { |
---|
30 | delete [] _slot; |
---|
31 | }; |
---|
32 | |
---|
33 | // *****[ empty ]***** |
---|
34 | // Test if the queue is empty |
---|
35 | public : bool empty () |
---|
36 | { |
---|
37 | return (_nb_slot == 0); |
---|
38 | } |
---|
39 | |
---|
40 | // *****[ full ]***** |
---|
41 | // Test if the queue is full |
---|
42 | public : bool full () |
---|
43 | { |
---|
44 | return (_nb_slot == _size); |
---|
45 | } |
---|
46 | |
---|
47 | // *****[ nb_slot_free ]***** |
---|
48 | // return the number of free slot |
---|
49 | public : uint32_t nb_slot_free () |
---|
50 | { |
---|
51 | return (_size-_nb_slot); |
---|
52 | } |
---|
53 | |
---|
54 | // *****[ nb_slot_use ]***** |
---|
55 | // return the number of use slot |
---|
56 | public : uint32_t nb_slot_use () |
---|
57 | { |
---|
58 | return (_nb_slot); |
---|
59 | } |
---|
60 | |
---|
61 | // *****[ pop ]***** |
---|
62 | // read the queue, and update the pointer |
---|
63 | public : virtual T pop (uint32_t num=0) = 0; |
---|
64 | |
---|
65 | // *****[ push ]***** |
---|
66 | // Push a new value (they must have a slot free) |
---|
67 | public : virtual bool push (T val) = 0; |
---|
68 | |
---|
69 | }; // Queue |
---|
70 | |
---|
71 | }; |
---|
72 | }; |
---|
73 | #endif |
---|
74 | |
---|
Note: See
TracBrowser
for help on using the repository browser.