summaryrefslogtreecommitdiff
path: root/NT/src/rotor.h
diff options
context:
space:
mode:
authorTim Redfern <tim@eclectronics.org>2013-12-26 00:51:22 +0000
committerTim Redfern <tim@eclectronics.org>2013-12-26 00:51:22 +0000
commitcbf26b93d097cd4304de2fa037675b3211629a62 (patch)
tree1c09b5faafd292a64e64d336fecda866718cdcea /NT/src/rotor.h
parent7dbe0f92adac6d437f76843c0ea72c3fbe57c371 (diff)
making string initialisers for variables
Diffstat (limited to 'NT/src/rotor.h')
-rw-r--r--NT/src/rotor.h44
1 files changed, 31 insertions, 13 deletions
diff --git a/NT/src/rotor.h b/NT/src/rotor.h
index 6835d01..6e82e80 100644
--- a/NT/src/rotor.h
+++ b/NT/src/rotor.h
@@ -1,7 +1,10 @@
#include <string>
+#include <sstream>
#include <map>
#include <unordered_map>
+#include "utils.h"
+
namespace Rotor {
class Node;
@@ -11,15 +14,26 @@ namespace Rotor {
public:
virtual void init(std::string s){};
virtual ~Variable(){};
+ Node* connection;
+ bool connectable;
};
template <class T> class Variable_type : public Variable {
public:
- Node* connection;
T* get(Frame_parameters frame);
- bool connectable;
T value;
};
//type specialisations deal with string conversion
+ template <> class Variable_type <double> : public Variable {
+ public:
+ void init(std::string s){
+ double x = 0;
+ std::istringstream cur(s);
+ cur >> x;
+ (*value)= x;
+ };
+ double* get(Frame_parameters frame);
+ double *value;
+ };
//what happens if we want to link an unlinked attribute at runtime
@@ -33,16 +47,18 @@ namespace Rotor {
//does the gui need a hint for the "basic" mode inlets so they stand out?
class Node { //base type for node pointers
- };
- template <class NT> class Node_type : public Node {
public:
- std::unordered_map<std::string,Variable*> vars;
- NT* get_output(Frame_parameters frame);
- virtual ~Node_type(){
+ virtual ~Node(){
for (auto v:vars){
delete v.second;
}
}
+ protected:
+ std::unordered_map<std::string,Variable*> vars;
+ };
+ template <class NT> class Node_type : public Node {
+ public:
+ NT* get_output(Frame_parameters frame);
void init(std::map<std::string,std::string> settings){
for (auto s:settings) {
if (vars.find(s.first)){
@@ -57,12 +73,14 @@ namespace Rotor {
};
class a_node: public Node_type<double> {
- a_node(){
- delay=create_inlet<int>("delay");
- //initialise the pointer to point at the instance variable
- //how to delete the vars ???
- };
- int *delay;
+ public:
+ a_node(){
+ delay=create_inlet<int>("delay");
+ //initialise the pointer to point at the instance variable
+ //how to delete the vars ???
+ };
+ private:
+ int *delay;
};
}