logic: deep copy edge components
- added a copy method to EdgeComponents - added a copy method to DataTypeModifier fortune cookie message = Roem Rijkdom en Liefde liggen op je Weg.
This commit is contained in:
@@ -36,7 +36,7 @@ std::shared_ptr<Edge> Edge::createPlainCopy(Node* from, Node* to) const
|
||||
|
||||
for (std::shared_ptr<EdgeComponent> component: m_components)
|
||||
{
|
||||
edge->addComponent(component); // Todo: create a deep copy here
|
||||
edge->addComponent(component->copy());
|
||||
}
|
||||
|
||||
return edge;
|
||||
|
||||
@@ -10,6 +10,8 @@ public:
|
||||
EdgeComponent();
|
||||
virtual ~EdgeComponent();
|
||||
|
||||
virtual std::shared_ptr<EdgeComponent> copy() const = 0;
|
||||
|
||||
void setEdge(Edge* edge);
|
||||
|
||||
protected:
|
||||
|
||||
@@ -13,6 +13,11 @@ EdgeComponentDataType::~EdgeComponentDataType()
|
||||
{
|
||||
}
|
||||
|
||||
std::shared_ptr<EdgeComponent> EdgeComponentDataType::copy() const
|
||||
{
|
||||
return std::make_shared<EdgeComponentDataType>(m_qualifierList, m_modifierStack);
|
||||
}
|
||||
|
||||
DataType EdgeComponentDataType::getDataType() const
|
||||
{
|
||||
return DataType(getEdge()->getTo()->getName(), m_qualifierList, m_modifierStack);
|
||||
|
||||
@@ -14,6 +14,8 @@ public:
|
||||
EdgeComponentDataType(const DataTypeQualifierList qualifierList, const DataTypeModifierStack modifierStack);
|
||||
virtual ~EdgeComponentDataType();
|
||||
|
||||
virtual std::shared_ptr<EdgeComponent> copy() const;
|
||||
|
||||
DataType getDataType() const;
|
||||
|
||||
private:
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
struct ParseLocation;
|
||||
struct ParseVariable;
|
||||
struct DataType;
|
||||
class DataType;
|
||||
|
||||
class ParserClient
|
||||
{
|
||||
|
||||
@@ -4,26 +4,23 @@ DataTypeModifierStack::DataTypeModifierStack()
|
||||
{
|
||||
}
|
||||
|
||||
//DataTypeModifierStack::DataTypeModifierStack(const DataTypeModifierStack& o)
|
||||
//{
|
||||
// for (std::shared_ptr<DataTypeModifier> modifier: o.m_modifiers)
|
||||
// {
|
||||
// m_modifiers.push_back(modifier.);
|
||||
// }
|
||||
//}
|
||||
|
||||
DataTypeModifierStack::DataTypeModifierStack(const DataTypeModifierStack& o)
|
||||
{
|
||||
for (std::shared_ptr<DataTypeModifier> modifier: o.m_modifiers)
|
||||
{
|
||||
m_modifiers.push_back(modifier->copy());
|
||||
}
|
||||
}
|
||||
|
||||
DataTypeModifierStack::~DataTypeModifierStack()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void DataTypeModifierStack::push(std::shared_ptr<DataTypeModifier> modifier)
|
||||
{
|
||||
m_modifiers.push_back(modifier);
|
||||
}
|
||||
|
||||
|
||||
std::string DataTypeModifierStack::applyTo(const std::string& typeName) const
|
||||
{
|
||||
std::string modifiedTypeName = typeName;
|
||||
|
||||
@@ -11,7 +11,7 @@ class DataTypeModifierStack
|
||||
{
|
||||
public:
|
||||
DataTypeModifierStack();
|
||||
//DataTypeModifierStack(const DataTypeModifierStack& o);
|
||||
DataTypeModifierStack(const DataTypeModifierStack& o);
|
||||
~DataTypeModifierStack();
|
||||
|
||||
void push(std::shared_ptr<DataTypeModifier> modifier);
|
||||
|
||||
@@ -11,6 +11,8 @@ public:
|
||||
DataTypeModifier();
|
||||
virtual ~DataTypeModifier();
|
||||
|
||||
virtual std::shared_ptr<DataTypeModifier> copy() const = 0;
|
||||
|
||||
void applyTo(std::string& typeName) const;
|
||||
|
||||
void addQualifier(DataTypeQualifierList::QualifierType qualifier);
|
||||
|
||||
@@ -8,6 +8,11 @@ DataTypeModifierPointer::~DataTypeModifierPointer()
|
||||
{
|
||||
}
|
||||
|
||||
std::shared_ptr<DataTypeModifier> DataTypeModifierPointer::copy() const
|
||||
{
|
||||
return std::make_shared<DataTypeModifierPointer>();
|
||||
}
|
||||
|
||||
void DataTypeModifierPointer::doApplyTo(std::string& typeName) const
|
||||
{
|
||||
typeName.append(" *");
|
||||
|
||||
@@ -9,6 +9,8 @@ public:
|
||||
DataTypeModifierPointer();
|
||||
virtual ~DataTypeModifierPointer();
|
||||
|
||||
virtual std::shared_ptr<DataTypeModifier> copy() const;
|
||||
|
||||
private:
|
||||
virtual void doApplyTo(std::string& typeName) const;
|
||||
};
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#include "cxxtest/TestSuite.h"
|
||||
|
||||
#include "data/graph/Graph.h"
|
||||
#include "data/graph/edgeComponent/EdgeComponentDataType.h"
|
||||
#include "data/type/modifier/DataTypeModifierPointer.h"
|
||||
|
||||
class GraphTestSuite : public CxxTest::TestSuite
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user