Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F23080356
Lookuptable.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Size
2 KB
Referenced Files
None
Subscribers
None
Lookuptable.cpp
View Options
#include
"Lookuptable.h"
#include
<stdio.h>
Lookuptable
::
Lookuptable
()
{
set_name
(
NO_NAME
);
num_of_ranges
=
0
;
}
Lookuptable
::
Lookuptable
(
char
*
name
)
{
set_name
(
name
);
num_of_ranges
=
0
;
}
bool
Lookuptable
::
add_range_to_lookuptable
(
int
score
,
float
lower_boundary
,
bool
flag_lower_boundary_included
,
float
upper_boundary
,
bool
flag_upper_boundary_included
)
{
//TODO: possibility of lower_boundary = upper_boundary is maybe needed in one case
if
(
num_of_ranges
<
MAX_NUM_OF_RANGES
&&
lower_boundary
<
upper_boundary
)
{
Range
range
(
score
,
lower_boundary
,
flag_lower_boundary_included
,
upper_boundary
,
flag_upper_boundary_included
);
list_of_ranges
[
num_of_ranges
]
=
range
;
//printf("eigene range %f - %f\n\n", lower_boundary, upper_boundary);
for
(
unsigned
int
r_ix
=
0
;
r_ix
<
num_of_ranges
;
r_ix
++
)
{
//printf("list_of_ranges[r_ix].get_lower_boundary() = %f\nlist_of_ranges[num_of_ranges].get_upper_boundary() = %f\n\n", list_of_ranges[r_ix].get_lower_boundary(), list_of_ranges[num_of_ranges].get_upper_boundary());
if
(
list_of_ranges
[
r_ix
].
get_lower_boundary
()
==
list_of_ranges
[
num_of_ranges
].
get_upper_boundary
())
{
//printf("drinnen1\n");
list_of_ranges
[
r_ix
].
set_range_below
(
&
list_of_ranges
[
num_of_ranges
]);
list_of_ranges
[
num_of_ranges
].
set_range_upon
(
&
list_of_ranges
[
r_ix
]);
}
//printf("list_of_ranges[r_ix].get_upper_boundary() = %f\nlist_of_ranges[num_of_ranges].get_lower_boundary() = %f\n\n", list_of_ranges[r_ix].get_upper_boundary(), list_of_ranges[num_of_ranges].get_lower_boundary());
if
(
list_of_ranges
[
r_ix
].
get_upper_boundary
()
==
list_of_ranges
[
num_of_ranges
].
get_lower_boundary
())
{
//printf("drinnen2\n");
list_of_ranges
[
r_ix
].
set_range_upon
(
&
list_of_ranges
[
num_of_ranges
]);
list_of_ranges
[
num_of_ranges
].
set_range_below
(
&
list_of_ranges
[
r_ix
]);
}
}
num_of_ranges
++
;
return
true
;
}
return
false
;
}
bool
Lookuptable
::
check_sort_and_activate
()
{
if
(
num_of_ranges
>
0
)
{
return
list_of_ranges
[
0
].
check_lut_correctness
(
num_of_ranges
);
}
return
false
;
}
bool
Lookuptable
::
get_lookuptable_is_correct_and_active
()
{
return
lookuptable_is_correct_and_active
;
}
int
Lookuptable
::
get_score
(
float
input
)
{
//TODO: WHEN ACTIVATED!?
return
list_of_ranges
[
0
].
check_belong_to_range
(
input
);
}
void
Lookuptable
::
printf_ranges
()
{
for
(
unsigned
int
i
=
0
;
i
<
num_of_ranges
;
i
++
)
{
if
(
list_of_ranges
[
i
].
get_range_below
()
!=
nullptr
)
printf
(
"%i ist unten verbunden
\n
"
,
i
);
else
printf
(
"%i ist unten NICHT verbunden
\n
"
,
i
);
if
(
list_of_ranges
[
i
].
get_range_upon
()
!=
nullptr
)
printf
(
"%i ist oben verbunden
\n
"
,
i
);
else
printf
(
"%i ist oben NICHT verbunden
\n
"
,
i
);
}
printf
(
"blub
\n
"
);
getchar
();
}
File Metadata
Details
Attached
Mime Type
text/x-c
Expires
Sun, Aug 2, 2:08 AM (17 h, 12 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
328142
Default Alt Text
Lookuptable.cpp (2 KB)
Attached To
Mode
R20 SoC_Rosa_repo
Attached
Detach File
Event Timeline
Log In to Comment