~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/serialize/binary_log.h

  • Committer: Monty Taylor
  • Date: 2008-11-16 06:29:53 UTC
  • mto: (584.1.9 devel)
  • mto: This revision was merged to the branch mainline in revision 589.
  • Revision ID: monty@inaugust.com-20081116062953-ivdltjmfe009b5fr
Moved stuff into item/

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
// -*- Mode: C++ -*-
 
2
 
 
3
#ifndef BINARY_LOG_H_INCLUDED
 
4
#define BINARY_LOG_H_INCLUDED
 
5
 
 
6
#include "binary_log.pb.h"
 
7
#include "binlog_encoding.h"
 
8
 
 
9
#include <google/protobuf/io/zero_copy_stream.h>
 
10
 
 
11
#include <iosfwd>
 
12
#include <stdexcept>
 
13
 
 
14
namespace BinaryLog {
 
15
  using namespace google::protobuf;
 
16
  using namespace google::protobuf::io;
 
17
 
 
18
  /**
 
19
     Wrapper class to wrap a protobuf event in a type tag and a length.
 
20
 
 
21
     The type tag is not part of the actual message, but is handled
 
22
     separately since it is needed to decode the events.
 
23
  */
 
24
  class Event {
 
25
  public:
 
26
    enum EventType {
 
27
      UNDEF,
 
28
      START,
 
29
      CHAIN,
 
30
      COMMIT,
 
31
      ROLLBACK,
 
32
      QUERY,
 
33
      COUNT
 
34
    };
 
35
 
 
36
    Event(EventType type, Message *message)
 
37
      : m_type(type), m_message(message)
 
38
    {
 
39
    }
 
40
 
 
41
    Event()
 
42
      : m_type(UNDEF), m_message(0)
 
43
    {
 
44
    }
 
45
 
 
46
    ~Event() {
 
47
      delete m_message;
 
48
    }
 
49
 
 
50
    bool write(CodedOutputStream* out) const;
 
51
    void print(std::ostream& out) const;
 
52
    bool read(CodedInputStream* in);
 
53
 
 
54
  private:
 
55
    EventType m_type;
 
56
    Message *m_message;
 
57
  };
 
58
}
 
59
 
 
60
#endif /* BINARY_LOG_H_INCLUDED */