GCC Code Coverage Report | |||||||||||||||||||||
|
|||||||||||||||||||||
Line | Branch | Exec | Source |
1 |
/** |
||
2 |
* Copyright 2019 Max Planck Society. All rights reserved. |
||
3 |
* Julian Viereck |
||
4 |
*/ |
||
5 |
|||
6 |
#include "dg_tools/data/previous_value.hpp" |
||
7 |
|||
8 |
/* --------------------------------------------------------------------- */ |
||
9 |
/* --------------------------------------------------------------------- */ |
||
10 |
/* --------------------------------------------------------------------- */ |
||
11 |
#include <sot/core/debug.hh> |
||
12 |
#include <dynamic-graph/factory.h> |
||
13 |
#include <dynamic-graph/all-commands.h> |
||
14 |
|||
15 |
using namespace dg_tools; |
||
16 |
|||
17 |
✓✗✓✗ ✓✗✓✗ |
3 |
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(PreviousValue, "PreviousValue"); |
18 |
|||
19 |
/* --------------------------------------------------------------------- */ |
||
20 |
/* --------------------------------------------------------------------- */ |
||
21 |
/* --------------------------------------------------------------------- */ |
||
22 |
|||
23 |
1 |
PreviousValue::PreviousValue( const std::string & name ) |
|
24 |
:Entity(name) |
||
25 |
,size_(0) |
||
26 |
,is_initialized_(false) |
||
27 |
✓✗✓✗ |
2 |
,dataSIN(NULL,"PreviousValue("+name+")::input(vector)::sin") |
28 |
,dataSOUT( boost::bind(&PreviousValue::getInput,this,_1,_2), |
||
29 |
dataSIN, |
||
30 |
✓✗✓✗ |
2 |
"PreviousValue("+name+")::output(vector)::sout" ) |
31 |
,previousSOUT( boost::bind(&PreviousValue::getPrevious,this,_1,_2), |
||
32 |
dataSIN, |
||
33 |
✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ ✓✗✓✗ |
4 |
"PreviousValue("+name+")::output(vector)::sprev" ) |
34 |
{ |
||
35 |
✓✗✓✗ ✓✗ |
1 |
Entity::signalRegistration(dataSIN << dataSOUT << previousSOUT); |
36 |
|||
37 |
✓✗ | 3 |
addCommand ( |
38 |
"init", |
||
39 |
✓✗ | 1 |
dynamicgraph::command::makeCommandVoid1( |
40 |
*this, |
||
41 |
&PreviousValue::init, |
||
42 |
✓✗✓✗ ✓✗ |
2 |
dynamicgraph::command::docCommandVoid1( |
43 |
"Init the entity", |
||
44 |
"int: Dimension of the stored value.") |
||
45 |
) |
||
46 |
✓✗ | 1 |
); |
47 |
1 |
} |
|
48 |
|||
49 |
1 |
void PreviousValue::init(const int& size) |
|
50 |
{ |
||
51 |
1 |
internal_history_.resize(size); |
|
52 |
✓✗ | 1 |
internal_history_.fill(0.); |
53 |
1 |
} |
|
54 |
|||
55 |
|||
56 |
/* --------------------------------------------------------------------- */ |
||
57 |
/* --------------------------------------------------------------------- */ |
||
58 |
/* --------------------------------------------------------------------- */ |
||
59 |
|||
60 |
void PreviousValue::display( std::ostream& os ) const |
||
61 |
{ |
||
62 |
os << "PreviousValue " << getName(); |
||
63 |
os <<" (" << internal_history_.size() << ") "; |
||
64 |
} |
||
65 |
|||
66 |
1 |
dg::Vector& PreviousValue::getInput(dg::Vector& output, int time) |
|
67 |
{ |
||
68 |
1 |
output = dataSIN(time); |
|
69 |
✗✓ | 1 |
assert(output.size() == internal_history_.size()); |
70 |
1 |
internal_history_ = output; |
|
71 |
1 |
return output; |
|
72 |
} |
||
73 |
|||
74 |
2 |
dg::Vector& PreviousValue::getPrevious(dg::Vector& previous, int time) |
|
75 |
{ |
||
76 |
2 |
previous = internal_history_; |
|
77 |
2 |
return internal_history_; |
|
78 |
✓✗✓✗ |
6 |
} |
Generated by: GCOVR (Version 4.2) |