19#ifndef HEDGEHOG_COPYABLE_ABSTRACTION_H_
20#define HEDGEHOG_COPYABLE_ABSTRACTION_H_
23#include "../../../tools/concepts.h"
31namespace abstraction {
35template<tool::CopyableNode CopyableNode>
39 std::unique_ptr<std::set<std::shared_ptr<CopyableNode>>>
nodeCopies_ =
nullptr;
46 nodeCopies_(std::make_unique<std::set<std::shared_ptr<CopyableNode>>>()){}
59 if (copy ==
nullptr) {
60 std::ostringstream oss;
63 <<
"A copy for the node \"" << node->name()
64 <<
"\" has been invoked but return nullptr. To fix this error, overload the "
65 << tool::typeToStr<CopyableNode>()
66 <<
"::copy function and return a valid object.";
69 <<
"A copy for the node has been invoked but return nullptr. To fix this error, overload the "
70 << tool::typeToStr<CopyableNode>()
71 <<
"::copy function and return a valid object.";
73 throw (std::runtime_error(oss.str()));
77 std::ostringstream oss;
79 oss <<
"A copy for the node \"" << node->name()
80 <<
"\" has been invoked and return a copy already registered. Each copy of a node should be different.";
82 oss <<
"A copy for the node has been invoked and return a copy already registered. Each copy of a node "
83 "should be different.";
85 throw (std::runtime_error(oss.str()));
Core abstraction for copyable nodes.
CopyableAbstraction(CopyableNode *const copyableNode)
Constructor using a node abstraction.
std::shared_ptr< CopyableNode > callCopy()
Interface to call user-defined copy method.
std::unique_ptr< std::set< std::shared_ptr< CopyableNode > > > nodeCopies_
Set of copies of the node.
virtual ~CopyableAbstraction()=default
Default destructor.
CopyableNode *const copyableNode_
Pointer to copyable node abstraction.
Base core node abstraction.