src/port.cpp

00001 #include "port.h"
00002 
00003 namespace  DiscreteTimeSystems {
00004 
00005   using namespace std;
00006 
00007   InputPort::InputPort(int n) : _size(n), _port(NULL)
00008   {
00009   }
00010 
00011   void InputPort::connect(OutputPort *p)
00012   {
00013     if (_size != p->getSize()) {
00014       exit(-1);
00015     }
00016 
00017     _port = p;
00018   }
00019 
00020   vector<double> InputPort::getData()
00021   {
00022     if (_port) 
00023       return _port->getData();
00024     else 
00025       exit(-1);
00026   }
00027 
00028   OutputPort::OutputPort(int n) : _array(n), _size(n)
00029   {
00030     for (int i=0; i<n; ++i) _array.push_back(0);
00031   }
00032 
00033   vector<double> OutputPort::getData()
00034   {
00035     return _array;
00036   }
00037 
00038   void OutputPort::setData(const vector<double> &v)
00039   {
00040     if (v.size() != _size) 
00041       exit(-1);
00042     _array = v;
00043   }
00044 }
00045 

Generated on Tue Dec 4 16:12:27 2007 for Project by  doxygen 1.5.1