Linux compile fix.

Needed to move the implementation of copyByType() out of the class definition.
This commit is contained in:
Jacob Storen 2015-06-29 03:37:02 -07:00
parent 00f8743cef
commit 3bd9360911

View File

@ -75,38 +75,7 @@ public:
}
template <typename T>
void createCopyByType(std::vector<PdmPointer<T> >* copyOfTypedObjects) const
{
std::vector<PdmPointer<T> > sourceTypedObjects;
objectsByType(&sourceTypedObjects);
QString encodedXml;
{
// Write original objects to XML file
PdmObjectGroup typedObjectGroup;
for (size_t i = 0; i < sourceTypedObjects.size(); i++)
{
typedObjectGroup.addObject(sourceTypedObjects[i]);
PdmDocument::setupBeforeSaveTraversal(sourceTypedObjects[i]);
}
QXmlStreamWriter xmlStream(&encodedXml);
xmlStream.setAutoFormatting(true);
typedObjectGroup.writeFields(xmlStream);
}
// Read back XML into object group, factory methods will be called that will create new objects
PdmObjectGroup destinationObjectGroup;
QXmlStreamReader xmlStream(encodedXml);
destinationObjectGroup.readFields(xmlStream);
for (size_t it = 0; it < destinationObjectGroup.objects.size(); it++)
{
T* obj = dynamic_cast<T*>(destinationObjectGroup.objects[it]);
if (obj) copyOfTypedObjects->push_back(obj);
}
}
void createCopyByType(std::vector<PdmPointer<T> >* copyOfTypedObjects) const;
};
//==================================================================================================
@ -135,6 +104,44 @@ class PdmDocument: public PdmObjectGroup
};
//--------------------------------------------------------------------------------------------------
///
//--------------------------------------------------------------------------------------------------
template <typename T>
void PdmObjectGroup::createCopyByType(std::vector<PdmPointer<T> >* copyOfTypedObjects) const
{
std::vector<PdmPointer<T> > sourceTypedObjects;
objectsByType(&sourceTypedObjects);
QString encodedXml;
{
// Write original objects to XML file
PdmObjectGroup typedObjectGroup;
for (size_t i = 0; i < sourceTypedObjects.size(); i++)
{
typedObjectGroup.addObject(sourceTypedObjects[i]);
PdmDocument::setupBeforeSaveTraversal(sourceTypedObjects[i]);
}
QXmlStreamWriter xmlStream(&encodedXml);
xmlStream.setAutoFormatting(true);
typedObjectGroup.writeFields(xmlStream);
}
// Read back XML into object group, factory methods will be called that will create new objects
PdmObjectGroup destinationObjectGroup;
QXmlStreamReader xmlStream(encodedXml);
destinationObjectGroup.readFields(xmlStream);
for (size_t it = 0; it < destinationObjectGroup.objects.size(); it++)
{
T* obj = dynamic_cast<T*>(destinationObjectGroup.objects[it]);
if (obj) copyOfTypedObjects->push_back(obj);
}
}
} // End of namespace caf