monotone

monotone Mtn Source Tree

Root/packet.hh

1#ifndef __PACKET_HH__
2#define __PACKET_HH__
3
4// Copyright (C) 2002 Graydon Hoare <graydon@pobox.com>
5//
6// This program is made available under the GNU GPL version 2.0 or
7// greater. See the accompanying file COPYING for details.
8//
9// This program is distributed WITHOUT ANY WARRANTY; without even the
10// implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
11// PURPOSE.
12
13#include "vocab.hh"
14
15struct cert;
16struct keypair;
17
18// the idea here is that monotone can produce and consume "packet streams",
19// where each packet is *informative* rather than transactional. that is to
20// say, they contain no information which needs to be replied to or processed
21// in any particular manner during some communication session.
22//
23// unlike nearly every other part of this program, the packet stream
24// interface is really *stream* oriented. the idea being that, while you
25// might be able to keep any one delta or file in memory at once, asking
26// you to keep *all* the deltas or files associated with a large chunk of
27// work, in memory, is a bit much.
28//
29// packet streams are ascii text, formatted for comfortable viewing on a
30// terminal or inclusion in an email / netnews post. they can be edited with
31// vi, filtered with grep, and concatenated with cat.
32//
33// there are currently 8 types of packets, though this can grow without
34// hurting anyone's feelings. if there's a backwards compatibility problem,
35// just introduce a new packet type.
36
37struct packet_consumer
38{
39public:
40 virtual ~packet_consumer() {}
41 virtual void consume_file_data(file_id const & ident,
42 file_data const & dat) = 0;
43 virtual void consume_file_delta(file_id const & id_old,
44 file_id const & id_new,
45 file_delta const & del) = 0;
46
47 virtual void consume_revision_data(revision_id const & ident,
48 revision_data const & dat) = 0;
49 virtual void consume_revision_cert(revision<cert> const & t) = 0;
50
51
52 virtual void consume_public_key(rsa_keypair_id const & ident,
53 rsa_pub_key const & k) = 0;
54 virtual void consume_key_pair(rsa_keypair_id const & ident,
55 keypair const & kp) = 0;
56 virtual void consume_old_private_key(rsa_keypair_id const & ident,
57 old_arc4_rsa_priv_key const & k) = 0;
58};
59
60// this writer writes packets into a stream
61
62struct packet_writer : public packet_consumer
63{
64 std::ostream & ost;
65 explicit packet_writer(std::ostream & o);
66 virtual ~packet_writer() {}
67 virtual void consume_file_data(file_id const & ident,
68 file_data const & dat);
69 virtual void consume_file_delta(file_id const & id_old,
70 file_id const & id_new,
71 file_delta const & del);
72
73 virtual void consume_revision_data(revision_id const & ident,
74 revision_data const & dat);
75 virtual void consume_revision_cert(revision<cert> const & t);
76
77 virtual void consume_public_key(rsa_keypair_id const & ident,
78 rsa_pub_key const & k);
79 virtual void consume_key_pair(rsa_keypair_id const & ident,
80 keypair const & kp);
81 virtual void consume_old_private_key(rsa_keypair_id const & ident,
82 old_arc4_rsa_priv_key const & k);
83};
84
85size_t read_packets(std::istream & in, packet_consumer & cons);
86
87// Local Variables:
88// mode: C++
89// fill-column: 76
90// c-file-style: "gnu"
91// indent-tabs-mode: nil
92// End:
93// vim: et:sw=2:sts=2:ts=2:cino=>2s,{s,\:s,+s,t0,g0,^-2,e-2,n-2,p2s,(0,=s:
94
95#endif

Archive Download this file

Branches

Tags

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