Aikido
TestableOutcome-impl.hpp
Go to the documentation of this file.
1 #include <sstream>
2 #include <stdexcept>
3 #include <typeinfo>
4 
5 namespace aikido {
6 namespace constraint {
7 
8 //==============================================================================
9 template <class Child>
11 {
12  if (!outcome)
13  return nullptr;
14 
15  auto childPtr = dynamic_cast<Child*>(outcome);
16  if (!childPtr)
17  {
18  std::stringstream message;
19  message << "TestableOutcome pointer is not of type " << typeid(Child).name()
20  << ".";
21  throw std::invalid_argument(message.str());
22  }
23 
24  return childPtr;
25 }
26 
27 } // namespace constraint
28 } // namespace aikido
aikido::constraint::dynamic_cast_or_throw
Child * dynamic_cast_or_throw(TestableOutcome *outcome)
Helper function.
Definition: TestableOutcome-impl.hpp:10
aikido
Format of serialized trajectory in YAML.
Definition: algorithm.hpp:4
aikido::constraint::TestableOutcome
Base class for constraint outcomes.
Definition: TestableOutcome.hpp:13