diff options
| author | Tim Redfern <tim@eclectronics.org> | 2013-12-29 12:19:38 +0000 |
|---|---|---|
| committer | Tim Redfern <tim@eclectronics.org> | 2013-12-29 12:19:38 +0000 |
| commit | f7813a5324be39d13ab536c245d15dfc602a7849 (patch) | |
| tree | fad99148b88823d34a5df2f0a25881a002eb291b /NT/src/rotor.cpp | |
| parent | b7a5a477b8ff4d4e3028b9dfb9a9df0a41463f92 (diff) | |
basic type mechanism working
Diffstat (limited to 'NT/src/rotor.cpp')
| -rw-r--r-- | NT/src/rotor.cpp | 36 |
1 files changed, 32 insertions, 4 deletions
diff --git a/NT/src/rotor.cpp b/NT/src/rotor.cpp index 056736d..ca15423 100644 --- a/NT/src/rotor.cpp +++ b/NT/src/rotor.cpp @@ -5,15 +5,43 @@ using namespace std; using namespace Rotor; +template <class T> +void Rotor::Variable_type<T>::init(std::string s){ + std::istringstream cur(s); +cur >> value; + //std::cout<<s<<" "<<value<<std::endl; + } + +template <class T> +bool Rotor::Variable_type<T>::connect(Node* target){ + if (connectable){ + if (dynamic_cast<Node_type<T>*>(target)){ + connection=target; + return true; + } + } + return false; + } + +template <class T> +const T& Rotor::Variable_type<T>::get(const Frame_parameters &frame){ + if (connection){ + return (dynamic_cast<Node_type<T>*>(connection))->get_output(frame); + } + return value; + } + int main(){ Rotor::time t; multiply m; map<string,string> settings={{"value","2"}}; m.init(settings); - if (m.connect("inlet",&t)) printf("connected!\n"); - else printf("not connected...\n"); + if (!m.connect("inlet",&t)) printf("not connected...\n"); +Rotor::print p; +if (!p.connect("inlet",&m)) printf("not connected...\n"); for (double t=0;t<10.0;t+=0.765){ Frame_parameters f=Frame_parameters(t,25.0,10.0,640,360); - printf() + printf("%04f %s\n",t,p.get_output(f).c_str()); + } -}
\ No newline at end of file +} |
