summaryrefslogtreecommitdiffhomepage
path: root/flowgraph
diff options
context:
space:
mode:
Diffstat (limited to 'flowgraph')
-rw-r--r--flowgraph/data.h5
-rw-r--r--flowgraph/node.cpp2
-rw-r--r--flowgraph/node.h11
3 files changed, 11 insertions, 7 deletions
diff --git a/flowgraph/data.h b/flowgraph/data.h
index 1ed4964..abf046d 100644
--- a/flowgraph/data.h
+++ b/flowgraph/data.h
@@ -8,7 +8,7 @@
namespace FlowGraph {
// Explicitely not including size
- enum class DataType
+ enum class DataType: int
{
Size,
Int,
@@ -27,8 +27,9 @@ namespace FlowGraph {
class Data
{
public:
- Data(DataType type, std::shared_ptr<Storage> storage):m_type(type) {}
+ Data(DataType type, std::shared_ptr<Storage> storage): m_type(type), m_storage(storage) {}
DataType type() const { return m_type; }
+ std::shared_ptr<Storage> storage() { return m_storage; }
private:
const DataType m_type;
std::shared_ptr<Storage> m_storage;
diff --git a/flowgraph/node.cpp b/flowgraph/node.cpp
index 81217ce..795a252 100644
--- a/flowgraph/node.cpp
+++ b/flowgraph/node.cpp
@@ -9,7 +9,7 @@ using namespace FlowGraph;
// 4 byte for now
Data FlowGraph::MakeConstantInt(int i)
{
- std::vector<uint8_t> value(size_t(4));
+ std::vector<uint8_t> value(size_t(4), uint8_t(0));
*(reinterpret_cast<int32_t*>(value.data())) = boost::endian::native_to_little(static_cast<int32_t>(i));
return Data(DataType::Int, std::make_shared<Constant>(value));
}
diff --git a/flowgraph/node.h b/flowgraph/node.h
index 89f6088..853b017 100644
--- a/flowgraph/node.h
+++ b/flowgraph/node.h
@@ -17,7 +17,12 @@ namespace FlowGraph {
class Node
{
public:
+ Node(){}
+ Node(std::vector<Data> operands): mOperands(operands) {}
+ std::vector<Data>& operands() { return mOperands; }
virtual ~Node() {}; // force class to be polymorphic (e.g. in a container)
+ private:
+ std::vector<Data> mOperands;
};
// Memory on Heap: new and delete
@@ -146,13 +151,11 @@ namespace FlowGraph {
{
public:
BinaryOperation(BinaryOperationType type, Data& destination, Data& source0, Data& source1):
- m_type(type), m_destination(destination), m_source0(source0), m_source1(source1)
+ Node(std::vector<Data>({destination, source0, source1})), m_type(type)
{}
+ BinaryOperationType type() {return m_type;}
private:
BinaryOperationType m_type;
- Data m_destination;
- Data m_source0;
- Data m_source1;
};
} // namespace FlowGraph