Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F386248
HistoryModule.cpp
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Size
1 KB
Referenced Files
None
Subscribers
None
HistoryModule.cpp
View Options
#include
"HistoryModule.h"
#include
"printError.h"
#include
<stdio.h>
#define MAX_HIST_LENGTH 1000
//using namespace std;
void
HistoryModule
::
initHistoryModule
()
{
if
(
MAX_HIST_LENGTH
<=
vHistory
.
max_size
())
{
historyLength
=
MAX_HIST_LENGTH
;
}
else
{
historyLength
=
vHistory
.
max_size
();
}
delimitationMode
=
DELIMITATE_MODE_SRWF
;
}
HistoryModule
::
HistoryModule
()
{
set_name
(
NO_NAME
);
initHistoryModule
();
}
HistoryModule
::
HistoryModule
(
const
char
*
name
)
{
initHistoryModule
();
set_name
(
name
);
}
bool
HistoryModule
::
set_maxHistoryLength
(
unsigned
int
length
)
{
if
(
length
<=
MAX_HIST_LENGTH
&&
length
<=
vHistory
.
max_size
())
{
//this->historyLength = historyLength;
historyLength
=
length
;
return
true
;
}
return
false
;
}
unsigned
int
HistoryModule
::
get_maxHistoryLength
()
{
return
historyLength
;
}
bool
HistoryModule
::
set_delimitationMode
(
int
delimitationMode
)
{
if
(
delimitationMode
>
DELIMITATE_MODE_LBOUND
&&
delimitationMode
<
DELIMITATE_MODE_UBOUND
)
{
this
->
delimitationMode
=
delimitationMode
;
return
true
;
}
return
false
;
}
int
HistoryModule
::
get_delimitationMode
()
{
return
delimitationMode
;
}
bool
HistoryModule
::
add_entry
(
float
entryValue
)
{
if
(
vHistory
.
size
()
<=
historyLength
)
{
HistoryEntry
*
historyEntry
=
new
HistoryEntry
();
if
(
historyEntry
!=
NULL
)
{
historyEntry
->
set_entryValue
(
entryValue
);
try
{
vHistory
.
push_back
(
historyEntry
);
return
true
;
}
catch
(
bad_alloc
&
error
)
{
printError
(
"bad_alloc caught: "
,
error
.
what
());
}
}
else
{
printError
(
"Couldn't create HistoryEntry!"
);
}
}
else
{
switch
(
delimitationMode
)
{
case
DELIMITATE_MODE_SRWF
:
printError
(
"History is already full!"
);
break
;
default
:
printError
(
"History is already full! DelimitationMode isn't set!"
);
break
;
}
}
return
false
;
}
unsigned
int
HistoryModule
::
get_numberOfEntries
()
{
return
vHistory
.
size
();
}
File Metadata
Details
Attached
Mime Type
text/x-c
Expires
Wed, Jul 2, 12:58 AM (5 h, 45 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
157107
Default Alt Text
HistoryModule.cpp (1 KB)
Attached To
Mode
R20 SoC_Rosa_repo
Attached
Detach File
Event Timeline
Log In to Comment