1234567891011121314151617181920212223242526272829303132333435363738 |
- #include "timebuf.hh"
- #include <iostream>
- using namespace std;
- class MyClass
- {
- private:
- int value;
- public:
- MyClass(): value(0xdeadbeef) {};
- int getv() { return value; }
- void setv(int v) { value = v; }
- };
- int main()
- {
- // we can access data generated in the last 3 time units
- // and 0 time units in the future
- TimeBuffer<MyClass> mybuf(3, 0);
- TimeBuffer<MyClass>::wire toNext = mybuf.getWire(0);
- TimeBuffer<MyClass>::wire fromPrev = mybuf.getWire(-3);
- toNext->setv(0x55aaaa55);
- cout << fromPrev->getv() << endl;
- mybuf.advance();
- cout << fromPrev->getv() << endl;
- mybuf.advance();
- cout << fromPrev->getv() << endl;
- mybuf.advance();
- cout << fromPrev->getv() << endl;
- mybuf.advance();
- cout << fromPrev->getv() << endl;
- }
|