data: Saving virtual abstraction of methods as TokenComponentAbstraction

This commit is contained in:
Eberhard Graether
2014-08-01 05:27:09 +02:00
parent 5893d0c776
commit 8950d679e1
14 changed files with 153 additions and 16 deletions
+17
View File
@@ -2,6 +2,7 @@
#include <sstream>
#include "data/graph/token_component/TokenComponentAbstraction.h"
#include "data/graph/token_component/TokenComponentConst.h"
#include "data/graph/token_component/TokenComponentStatic.h"
#include "data/graph/token_component/TokenComponentSignature.h"
@@ -196,6 +197,22 @@ bool Node::isEdge() const
return false;
}
void Node::addComponentAbstraction(std::shared_ptr<TokenComponentAbstraction> component)
{
if (getComponent<TokenComponentAbstraction>())
{
LOG_ERROR("TokenComponentAbstraction has been set before!");
}
else if (!isType(NODE_METHOD))
{
LOG_ERROR("TokenComponentAbstraction can't be set on node of type: " + getTypeString());
}
else
{
addComponent(component);
}
}
void Node::addComponentConst(std::shared_ptr<TokenComponentConst> component)
{
if (getComponent<TokenComponentConst>())
+2
View File
@@ -9,6 +9,7 @@
#include "data/graph/Edge.h"
#include "data/graph/Token.h"
class TokenComponentAbstraction;
class TokenComponentConst;
class TokenComponentStatic;
class TokenComponentSignature;
@@ -65,6 +66,7 @@ public:
virtual bool isEdge() const;
// Component setters.
void addComponentAbstraction(std::shared_ptr<TokenComponentAbstraction> component);
void addComponentConst(std::shared_ptr<TokenComponentConst> component);
void addComponentStatic(std::shared_ptr<TokenComponentStatic> component);
void addComponentSignature(std::shared_ptr<TokenComponentSignature> component);
@@ -0,0 +1,34 @@
#include "data/graph/token_component/TokenComponentAbstraction.h"
TokenComponentAbstraction::TokenComponentAbstraction(AbstractionType abstraction)
: m_abstraction(abstraction)
{
}
TokenComponentAbstraction::~TokenComponentAbstraction()
{
}
std::shared_ptr<TokenComponent> TokenComponentAbstraction::copy() const
{
return std::make_shared<TokenComponentAbstraction>(*this);
}
TokenComponentAbstraction::AbstractionType TokenComponentAbstraction::getAbstraction() const
{
return m_abstraction;
}
std::string TokenComponentAbstraction::getAbstractionString() const
{
switch (m_abstraction)
{
case ABSTRACTION_VIRTUAL:
return "virtual";
case ABSTRACTION_PURE_VIRTUAL:
return "pure virtual";
case ABSTRACTION_NONE:
return "";
}
return "";
}
@@ -0,0 +1,31 @@
#ifndef TOKEN_COMPONENT_ABSTRACTION_H
#define TOKEN_COMPONENT_ABSTRACTION_H
#include <string>
#include "data/graph/token_component/TokenComponent.h"
class TokenComponentAbstraction
: public TokenComponent
{
public:
enum AbstractionType
{
ABSTRACTION_VIRTUAL,
ABSTRACTION_PURE_VIRTUAL,
ABSTRACTION_NONE
};
TokenComponentAbstraction(AbstractionType abstraction);
virtual ~TokenComponentAbstraction();
virtual std::shared_ptr<TokenComponent> copy() const;
AbstractionType getAbstraction() const;
std::string getAbstractionString() const;
private:
const AbstractionType m_abstraction;
};
#endif // TOKEN_COMPONENT_ABSTRACTION_H
@@ -1,5 +1,5 @@
#ifndef TOKEN_COMPONENT_ACCESS
#define TOKEN_COMPONENT_ACCESS
#ifndef TOKEN_COMPONENT_ACCESS_H
#define TOKEN_COMPONENT_ACCESS_H
#include <string>
@@ -23,11 +23,10 @@ public:
virtual std::shared_ptr<TokenComponent> copy() const;
AccessType getAccess() const;
std::string getAccessString() const;
private:
const AccessType m_access;
};
#endif // TOKEN_COMPONENT_ACCESS
#endif // TOKEN_COMPONENT_ACCESS_H
@@ -1,5 +1,5 @@
#ifndef TOKEN_COMPONENT_CONST
#define TOKEN_COMPONENT_CONST
#ifndef TOKEN_COMPONENT_CONST_H
#define TOKEN_COMPONENT_CONST_H
#include "data/graph/token_component/TokenComponent.h"
@@ -10,4 +10,4 @@ public:
virtual std::shared_ptr<TokenComponent> copy() const;
};
#endif // TOKEN_COMPONENT_CONST
#endif // TOKEN_COMPONENT_CONST_H
@@ -1,5 +1,5 @@
#ifndef TOKEN_COMPONENT_DATA_TYPE
#define TOKEN_COMPONENT_DATA_TYPE
#ifndef TOKEN_COMPONENT_DATA_TYPE_H
#define TOKEN_COMPONENT_DATA_TYPE_H
#include "data/graph/token_component/TokenComponent.h"
#include "data/type/DataTypeModifierStack.h"
@@ -24,4 +24,4 @@ private:
const DataTypeModifierStack m_modifierStack;
};
#endif // TOKEN_COMPONENT_DATA_TYPE
#endif // TOKEN_COMPONENT_DATA_TYPE_H
@@ -1,5 +1,5 @@
#ifndef TOKEN_COMPONENT_SIGNATURE
#define TOKEN_COMPONENT_SIGNATURE
#ifndef TOKEN_COMPONENT_SIGNATURE_H
#define TOKEN_COMPONENT_SIGNATURE_H
#include <string>
@@ -20,4 +20,4 @@ private:
const std::string m_signature;
};
#endif // TOKEN_COMPONENT_SIGNATURE
#endif // TOKEN_COMPONENT_SIGNATURE_H
@@ -1,5 +1,5 @@
#ifndef TOKEN_COMPONENT_STATIC
#define TOKEN_COMPONENT_STATIC
#ifndef TOKEN_COMPONENT_STATIC_H
#define TOKEN_COMPONENT_STATIC_H
#include "data/graph/token_component/TokenComponent.h"
@@ -10,4 +10,4 @@ public:
virtual std::shared_ptr<TokenComponent> copy() const;
};
#endif // TOKEN_COMPONENT_STATIC
#endif // TOKEN_COMPONENT_STATIC_H