data: storing type modifiers in edges

- ASTVisitor uses DataType instead of string to pass on type information.
- Edges can have EdgeComponents.
- EdgeComponentDataType stores information that modifies the type a ...TYPE_OF edge points to.
- EdgeComponentDataType can create a complete DataType using it's internal information.
- Fixed a bug where DataTypeModifiers did not apply their qualifiers.
This commit is contained in:
malte_langkabel
2014-07-10 11:54:29 +02:00
parent 2eaecc4913
commit f1f2ea0ccd
25 changed files with 311 additions and 111 deletions
+31
View File
@@ -7,6 +7,7 @@
#include "data/graph/Token.h"
class Node;
class EdgeComponent;
class Edge: public Token
{
@@ -53,6 +54,15 @@ public:
std::string getAccessString() const;
std::string getAsString() const;
void addComponent(std::shared_ptr<EdgeComponent> component);
template <typename ComponentType>
std::shared_ptr<ComponentType> getComponent() const;
template <typename ComponentType>
bool hasComponent() const;
private:
// Constructor for plain copies.
Edge(Id id, EdgeType type, Node* from, Node* to);
@@ -64,8 +74,29 @@ private:
// Additional fields for different EdgeTypes.
AccessType m_access;
std::vector<std::shared_ptr<EdgeComponent>> m_components;
};
template <typename ComponentType>
std::shared_ptr<ComponentType> Edge::getComponent() const
{
std::shared_ptr<ComponentType> component;
for (std::shared_ptr<EdgeComponent> c: m_components)
{
component = std::dynamic_pointer_cast<ComponentType>(c);
if (component)
break;
}
return component;
}
template <typename ComponentType>
bool Edge::hasComponent() const
{
return (getComponent<ComponentType>());
}
std::ostream& operator<<(std::ostream& ostream, const Edge& edge);
#endif // EDGE_H