-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
abstract_value_cloner.h
38 lines (28 loc) · 1.04 KB
/
abstract_value_cloner.h
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
#pragma once
#include <memory>
#include "drake/common/copyable_unique_ptr.h"
#include "drake/common/drake_copyable.h"
#include "drake/common/value.h"
namespace drake {
namespace systems {
namespace internal {
/* Provies a ValueProducer::AllocateCallback functor that clones the given
model_value. */
class AbstractValueCloner final {
public:
DRAKE_DEFAULT_COPY_AND_MOVE_AND_ASSIGN(AbstractValueCloner)
/* Creates a clone functor for the given model value. */
template <typename SomeOutput>
explicit AbstractValueCloner(const SomeOutput& model_value)
: AbstractValueCloner(AbstractValue::Make<SomeOutput>(model_value)) {}
~AbstractValueCloner();
/* Returns a Clone of the model_value passed into the constructor. */
std::unique_ptr<AbstractValue> operator()() const;
private:
/* Creates a clone functor for the given model value. */
explicit AbstractValueCloner(std::unique_ptr<AbstractValue> model_value);
copyable_unique_ptr<AbstractValue> model_value_;
};
} // namespace internal
} // namespace systems
} // namespace drake