~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to drizzled/message/binary_log.h

  • Committer: Monty Taylor
  • Date: 2010-02-05 08:11:15 UTC
  • mfrom: (1283 build)
  • mto: (1273.13.43 fix_is)
  • mto: This revision was merged to the branch mainline in revision 1300.
  • Revision ID: mordred@inaugust.com-20100205081115-dr82nvrwv4lvw7sd
Merged trunk.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* -*- mode: c++; c-basic-offset: 2; indent-tabs-mode: nil; -*-
2
 
 *  vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
3
 
 *
4
 
 *  Copyright (C) 2009 Sun Microsystems
5
 
 *
6
 
 *  This program is free software; you can redistribute it and/or modify
7
 
 *  it under the terms of the GNU General Public License as published by
8
 
 *  the Free Software Foundation; version 2 of the License.
9
 
 *
10
 
 *  This program is distributed in the hope that it will be useful,
11
 
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
 
 *  GNU General Public License for more details.
14
 
 *
15
 
 *  You should have received a copy of the GNU General Public License
16
 
 *  along with this program; if not, write to the Free Software
17
 
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
18
 
 */
19
 
 
20
 
#ifndef DRIZZLED_MESSAGE_BINARY_LOG_H
21
 
#define DRIZZLED_MESSAGE_BINARY_LOG_H
22
 
 
23
 
#include <drizzled/message/binary_log.pb.h>
24
 
#include "binlog_encoding.h"
25
 
 
26
 
#include <google/protobuf/io/zero_copy_stream.h>
27
 
 
28
 
#include <iosfwd>
29
 
#include <stdexcept>
30
 
 
31
 
namespace BinaryLog {
32
 
 
33
 
  /**
34
 
     Wrapper class to wrap a protobuf event in a type tag and a length.
35
 
 
36
 
     The type tag is not part of the actual message, but is handled
37
 
     separately since it is needed to decode the events.
38
 
  */
39
 
  class Event {
40
 
  public:
41
 
    enum EventType {
42
 
      UNDEF,
43
 
      START,
44
 
      CHAIN,
45
 
      COMMIT,
46
 
      ROLLBACK,
47
 
      QUERY,
48
 
      COUNT
49
 
    };
50
 
 
51
 
    Event(EventType type, google::protobuf::Message *message)
52
 
      : m_type(type), m_message(message)
53
 
    {
54
 
    }
55
 
 
56
 
    Event()
57
 
      : m_type(UNDEF), m_message(0)
58
 
    {
59
 
    }
60
 
 
61
 
    ~Event() {
62
 
      delete m_message;
63
 
    }
64
 
 
65
 
    bool write(google::protobuf::io::CodedOutputStream* out) const;
66
 
    void print(std::ostream& out) const;
67
 
    bool read(google::protobuf::io::CodedInputStream* in);
68
 
 
69
 
  private:
70
 
    EventType m_type;
71
 
    google::protobuf::Message *m_message;
72
 
  };
73
 
}
74
 
 
75
 
#endif /* DRIZZLED_MESSAGE_BINARY_LOG_H */