make nodes more const friendly and prepare their functions for stateless work

Since the nodes won't be holding any rendering data themselves in this system,
we may as well enforce some level of non-write access by setting all the
functions to const. They were already const-friendly, they just weren't
labelled as such.
This commit is contained in:
itsmattkc
2019-12-04 20:10:42 +11:00
parent cbf4d5b8c7
commit bc0f01d9a3
30 changed files with 505 additions and 346 deletions
+65
View File
@@ -0,0 +1,65 @@
#ifndef VALUE_H
#define VALUE_H
#include <QString>
#include "input.h"
class NodeValue
{
public:
NodeValue(const NodeParam::DataType& type, const QVariant& data, const QString& tag = QString());
const NodeParam::DataType& type() const;
const QVariant& data() const;
const QString& tag() const;
private:
NodeParam::DataType type_;
QVariant data_;
QString tag_;
};
class NodeValueTable
{
public:
NodeValueTable();
QVariant Get(const NodeParam::DataType& type, const QString& tag = QString());
QVariant Take(const NodeParam::DataType& type, const QString& tag = QString());
void Push(const NodeValue& value);
void Push(const NodeParam::DataType& type, const QVariant& data, const QString& tag = QString());
void Prepend(const NodeValue& value);
void Prepend(const NodeParam::DataType& type, const QVariant& data, const QString& tag = QString());
const NodeValue& At(int index) const;
int Count() const;
bool isEmpty() const;
private:
QVariant GetInternal(const NodeParam::DataType& type, const QString& tag, bool remove);
QList<NodeValue> values_;
};
class NodeValueDatabase
{
public:
NodeValueDatabase();
NodeValueTable operator[](const QString& input_id) const;
NodeValueTable operator[](const NodeInput* input) const;
void Insert(const QString& key, const NodeValueTable &value);
void Insert(const NodeInput* key, const NodeValueTable& value);
NodeValueTable Merge() const;
private:
QHash<QString, NodeValueTable> tables_;
};
#endif // VALUE_H