-
-
Save karlnapf/e7e286568bfeb6c985973de8d35b0914 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
CSGObject* CSGObject::clone() | |
{ | |
SG_DEBUG("Starting to clone %s at %p.\n", get_name(), this); | |
SG_DEBUG("Constructing an empty instance of %s.\n", get_name()); | |
CSGObject* clone = create_empty(); | |
SG_DEBUG("Empty instance of %s created at %p.\n", get_name(), clone); | |
REQUIRE( | |
clone, "Could not create empty instance of %s. The reason for " | |
"this usually is that get_name() of the class returns something " | |
"wrong, that a class has a wrongly set generic type, or that it " | |
"lies outside the main source tree and does not have " | |
"CSGObject::create_empty() overridden.\n", | |
get_name()); | |
for (const auto it : self->map) | |
{ | |
auto tag = it.first; | |
auto own = it.second; | |
auto given = clone->get_parameter(tag); | |
SG_SDEBUG( | |
"Cloning parameter %s::%s of type %s.\n", this->get_name(), | |
tag.name().c_str(), own.get_value().type().c_str()); | |
own.get_value().clone_from(given.get_value()); | |
} | |
SG_DEBUG("Done cloning %s at %p, new object at %p.\n", get_name(), this, clone); | |
return clone; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment