forked from RobotLocomotion/drake
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinput_port_base.cc
38 lines (30 loc) · 1.05 KB
/
input_port_base.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include "drake/systems/framework/input_port_base.h"
#include <stdexcept>
#include <utility>
#include <fmt/format.h>
#include "drake/common/drake_assert.h"
namespace drake {
namespace systems {
InputPortBase::InputPortBase(
internal::SystemMessageInterface* owning_system, std::string name,
InputPortIndex index, DependencyTicket ticket,
PortDataType data_type, int size,
const std::optional<RandomDistribution>& random_type,
EvalAbstractCallback eval)
: PortBase("Input", owning_system, std::move(name), index, ticket,
data_type, size),
eval_(std::move(eval)),
random_type_(random_type) {
if (is_random() && data_type != kVectorValued) {
throw std::logic_error("Random input ports must be vector valued.");
}
DRAKE_DEMAND(eval_ != nullptr);
}
InputPortBase::~InputPortBase() = default;
void InputPortBase::ThrowRequiredMissing() const {
throw std::logic_error(fmt::format(
"InputPort::Eval(): required {} is not connected",
GetFullDescription()));
}
} // namespace systems
} // namespace drake