Commit 950a6e6a authored by Jan Möbius's avatar Jan Möbius

Copy perObjectData when object itself is copied

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@7987 383ad7c9-94d9-4d36-a494-682f7c89f535
parent e1772357
......@@ -85,9 +85,23 @@ BaseObject::BaseObject(const BaseObject& _object) :
childItems_.clear();
name_ = "Copy of " + _object.name_;
///@todo Maybe copy per Object Data
dataMap_.clear();
// Iterate over all per Object datas and try to copy them
QMap< QString, PerObjectData* >::const_iterator mapIter = _object.dataMap_.begin();
while ( mapIter != _object.dataMap_.end() ) {
// Try to get a copy of the object.
PerObjectData* copiedData = mapIter.value()->copyPerObjectData();
if ( copiedData ) {
dataMap_.insert(mapIter.key(),copiedData);
} else {
std::cerr << "Failed to copy per Object Data: " << mapIter.key().toStdString() << std::endl;
}
mapIter++;
}
// If the pointer is 0 then we are creating the objectroot
if ( PluginFunctions::objectRoot() ) {
setParent(PluginFunctions::objectRoot());
......
......@@ -45,6 +45,8 @@
#include "perObjectData.hh"
#include <iostream>
//== TYPEDEFS =================================================================
......@@ -56,9 +58,12 @@ PerObjectData()
}
PerObjectData*
PerObjectData::
PerObjectData(const PerObjectData& _b ) {
std::cerr << "Please implement a copy constructor for your perObjectData!"
copyPerObjectData( )
{
std::cerr << "Please implement a copy constructor for your perObjectData!" << std::endl;
return 0;
}
PerObjectData::
......
......@@ -85,10 +85,19 @@ class DLLEXPORT PerObjectData {
/** \brief Copy Constructor
* You have to reimplement this copy constructor for your object to get copied by the core. Otherwise,
* per Object data will not be copied when the core creates a copy of your object.
*
* If you reimplemented the function, set copyOk_ at the end of the function.
*/
PerObjectData(const PerObjectData& _b );
virtual ~PerObjectData();
/** \brief Copy Function
* You have to reimplement this function to create a copy of your Object.
* By default it will return 0;
*/
virtual PerObjectData* copyPerObjectData( );
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment