GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: tests/custom_entity.cpp Lines: 35 38 92.1 %
Date: 2022-09-30 08:22:45 Branches: 50 108 46.3 %

Line Branch Exec Source
1
/* Copyright 2010-2019 LAAS, CNRS
2
 * Thomas Moulard.
3
 *
4
 */
5
6
#define ENABLE_RT_LOG
7
8
#include "custom_entity.h"
9
10
#include <dynamic-graph/command-bind.h>
11
#include <dynamic-graph/entity.h>
12
#include <dynamic-graph/exception-factory.h>
13
#include <dynamic-graph/factory.h>
14
#include <dynamic-graph/pool.h>
15
#include <dynamic-graph/real-time-logger.h>
16
#include <dynamic-graph/signal-ptr.h>
17
#include <dynamic-graph/signal-time-dependent.h>
18
19
#include <boost/bind.hpp>
20
21
namespace dynamicgraph {
22
23
5
CustomEntity::CustomEntity(const std::string n)
24
    : Entity(n),
25
10
      m_sigdSIN(NULL, "CustomEntity(" + name + ")::input(double)::in_double"),
26
      m_sigdTimeDepSOUT(boost::bind(&CustomEntity::update, this, _1, _2),
27
                        m_sigdSIN,
28




15
                        "CustomEntity(" + name + ")::input(double)::out_double")
29
30
{
31
5
  addSignal();
32
33
  using namespace dynamicgraph::command;
34
35

5
  this->addCommand("act",
36
5
                   makeCommandVoid0(*this, &CustomEntity::act,
37

10
                                    docCommandVoid0("act on input signal")));
38
5
}
39
40
5
void CustomEntity::addSignal() {
41
5
  signalRegistration(m_sigdSIN << m_sigdTimeDepSOUT);
42
5
}
43
44
void CustomEntity::rmValidSignal() {
45
  signalDeregistration("in_double");
46
  signalDeregistration("out_double");
47
}
48
49
25
double &CustomEntity::update(double &res, const int &inTime) {
50
25
  const double &aDouble = m_sigdSIN(inTime);
51
25
  res = aDouble;
52


25
  logger().stream(MSG_TYPE_ERROR) << "start update " << res << '\n';
53

50
  DYNAMIC_GRAPH_ENTITY_DEBUG(*this)
54
25
      << "This is a message of level MSG_TYPE_DEBUG\n";
55

50
  DYNAMIC_GRAPH_ENTITY_INFO(*this)
56
25
      << "This is a message of level MSG_TYPE_INFO\n";
57

50
  DYNAMIC_GRAPH_ENTITY_WARNING(*this)
58
25
      << "This is a message of level MSG_TYPE_WARNING\n";
59

50
  DYNAMIC_GRAPH_ENTITY_ERROR(*this)
60
25
      << "This is a message of level MSG_TYPE_ERROR\n";
61

50
  DYNAMIC_GRAPH_ENTITY_DEBUG_STREAM(*this)
62
25
      << "This is a message of level MSG_TYPE_DEBUG_STREAM\n";
63

50
  DYNAMIC_GRAPH_ENTITY_INFO_STREAM(*this)
64
25
      << "This is a message of level MSG_TYPE_INFO_STREAM\n";
65

50
  DYNAMIC_GRAPH_ENTITY_WARNING_STREAM(*this)
66
25
      << "This is a message of level MSG_TYPE_WARNING_STREAM\n";
67

50
  DYNAMIC_GRAPH_ENTITY_ERROR_STREAM(*this)
68
25
      << "This is a message of level MSG_TYPE_ERROR_STREAM\n";
69

25
  logger().stream(MSG_TYPE_ERROR) << "end update\n";
70
25
  return res;
71
}
72
73
2
void CustomEntity::act() { m_sigdSIN.accessCopy(); }
74
75

5
DYNAMICGRAPH_FACTORY_ENTITY_PLUGIN(CustomEntity, "CustomEntity");
76
}  // namespace dynamicgraph