monotone

monotone Mtn Source Tree

Root/botan/filter.h

1/*************************************************
2* Filter Header File *
3* (C) 1999-2006 The Botan Project *
4*************************************************/
5
6#ifndef BOTAN_FILTER_H__
7#define BOTAN_FILTER_H__
8
9#include <botan/base.h>
10#include <vector>
11
12namespace Botan {
13
14/*************************************************
15* Filter Base Class *
16*************************************************/
17class Filter
18 {
19 public:
20 virtual void write(const byte[], u32bit) = 0;
21 virtual void start_msg() {}
22 virtual void end_msg() {}
23 virtual bool attachable() { return true; }
24 void new_msg();
25 void finish_msg();
26 virtual ~Filter() {}
27 protected:
28 void send(const byte[], u32bit);
29 void send(byte input) { send(&input, 1); }
30 void send(const MemoryRegion<byte>& in) { send(in.begin(), in.size()); }
31 Filter();
32 private:
33 Filter(const Filter&) {}
34 Filter& operator=(const Filter&) { return (*this); }
35
36 friend class Pipe;
37 friend class Fanout_Filter;
38
39 u32bit total_ports() const;
40 u32bit current_port() const { return port_num; }
41 void set_port(u32bit);
42
43 u32bit owns() const { return filter_owns; }
44
45 void attach(Filter*);
46 void set_next(Filter*[], u32bit);
47 Filter* get_next() const;
48
49 SecureVector<byte> write_queue;
50 std::vector<Filter*> next;
51 u32bit port_num, filter_owns;
52 bool owned;
53 };
54
55/*************************************************
56* Fanout Filter Base Class *
57*************************************************/
58class Fanout_Filter : public Filter
59 {
60 protected:
61 void incr_owns() { ++filter_owns; }
62
63 void set_port(u32bit n) { Filter::set_port(n); }
64 void set_next(Filter* f[], u32bit n) { Filter::set_next(f, n); }
65 void attach(Filter* f) { Filter::attach(f); }
66 };
67
68}
69
70#endif

Archive Download this file

Branches

Tags

Quick Links:     www.monotone.ca    -     Downloads    -     Documentation    -     Wiki    -     Code Forge    -     Build Status