]> git.tdb.fi Git - netvis.git/blobdiff - source/history.h
Add a traffic history graph
[netvis.git] / source / history.h
diff --git a/source/history.h b/source/history.h
new file mode 100644 (file)
index 0000000..65deec7
--- /dev/null
@@ -0,0 +1,48 @@
+/* $Id$
+
+This file is part of NetVis
+Copyright @ 2008 Mikko Rasa, Mikkosoft Productions
+Distributed unter the GPL
+*/
+
+#ifndef HISTORY_H_
+#define HISTORY_H_
+
+#include <msp/gl/mesh.h>
+#include <msp/gl/texture2d.h>
+#include <msp/time/timestamp.h>
+#include "ringbuffer.h"
+
+class NetVis;
+
+class History
+{
+private:
+       struct Bandwidth
+       {
+               unsigned down;
+               unsigned up;
+
+               Bandwidth();
+       };
+
+       NetVis &netvis;
+       unsigned width;
+       unsigned height;
+       Bandwidth accum;
+       RingBuffer<Bandwidth> buffer;
+       Msp::Time::TimeStamp next_push;
+       unsigned scale;
+       Msp::GL::Texture2D texture;
+       Msp::GL::Mesh mesh;
+
+public:
+       History(NetVis &, unsigned, unsigned);
+       void activity(unsigned, unsigned);
+       void tick(const Msp::Time::TimeStamp &);
+       void render() const;
+private:
+       void create_texture();
+};
+
+#endif