1 | #ifndef morpheo_behavioural_generic_sort_Types_h |
---|
2 | #define morpheo_behavioural_generic_sort_Types_h |
---|
3 | |
---|
4 | /* |
---|
5 | * $Id: Types.h 82 2008-05-01 16:48:45Z rosiere $ |
---|
6 | * |
---|
7 | * [ Description ] |
---|
8 | * |
---|
9 | */ |
---|
10 | |
---|
11 | #include "Behavioural/include/Types.h" |
---|
12 | |
---|
13 | namespace morpheo { |
---|
14 | namespace behavioural { |
---|
15 | namespace generic { |
---|
16 | namespace sort { |
---|
17 | |
---|
18 | // typedef uint32_t Taddress_t; |
---|
19 | typedef uint32_t Tdata_t; |
---|
20 | |
---|
21 | class sort_t |
---|
22 | { |
---|
23 | public : Tcontrol_t val ; |
---|
24 | public : Tdata_t data ; |
---|
25 | public : Taddress_t index; |
---|
26 | |
---|
27 | bool operator<(const sort_t & x) const |
---|
28 | { |
---|
29 | int test = (((val)?1:0)<<1) + ((x.val)?1:0); |
---|
30 | bool res; |
---|
31 | switch (test) |
---|
32 | { |
---|
33 | case 1 : {res = false; break;} /* 01 - a not valid, b valid */ |
---|
34 | case 2 : {res = true ; break;} /* 10 - a valid, b not valid */ |
---|
35 | default : {res = data < x.data; break;} /* 00 - a not valid, b not valid */ |
---|
36 | /* 11 - a valid, b valid */ |
---|
37 | } |
---|
38 | // cout << *this << "\t" << x << "\ttest : " << test << " - res : " << res << endl; |
---|
39 | |
---|
40 | return res; |
---|
41 | } |
---|
42 | |
---|
43 | // bool operator>(const sort_t & x) const |
---|
44 | // { |
---|
45 | // int test = (((val)?1:0)<<1) + ((x.val)?1:0); |
---|
46 | |
---|
47 | // switch (test) |
---|
48 | // { |
---|
49 | // case 1 : {return true ; } /* 01 - a not valid, b valid */ |
---|
50 | // case 2 : {return false; } /* 10 - a valid, b not valid */ |
---|
51 | // default : {return data > x.data;} /* 00 - a not valid, b not valid */ |
---|
52 | // /* 11 - a valid, b valid */ |
---|
53 | // } |
---|
54 | // } |
---|
55 | |
---|
56 | friend std::ostream& operator<< (std::ostream& output_stream, const sort_t & x) |
---|
57 | { |
---|
58 | output_stream << "[" << x.index << "] " << x.val << " - " << x.data; |
---|
59 | |
---|
60 | return output_stream; |
---|
61 | } |
---|
62 | }; |
---|
63 | |
---|
64 | }; // end namespace sort |
---|
65 | }; // end namespace generic |
---|
66 | }; // end namespace behavioural |
---|
67 | }; // end namespace morpheo |
---|
68 | |
---|
69 | #endif |
---|