~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/command_log/command_log_reader.h

Adds a new plugin class interface for a reader of Command messages, 
drizzled::plugin::CommandReader.

Adds two new classes to the command_log module:

* CommandLogReader implements the CommandReader plugin interface for reading
  Command messages from the CommandLog.

* CommandLogIndex is a simple indexing class for a log file

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) 2008-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; either version 2 of the License, or
 
9
 *  (at your option) any later version.
 
10
 *
 
11
 *  This program is distributed in the hope that it will be useful,
 
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
14
 *  GNU General Public License for more details.
 
15
 *
 
16
 *  You should have received a copy of the GNU General Public License
 
17
 *  along with this program; if not, write to the Free Software
 
18
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 
19
 */
 
20
 
 
21
/**
 
22
 * @file
 
23
 *
 
24
 * Defines the API of a simple reader of Command messages from the
 
25
 * Command log file.  
 
26
 *
 
27
 * @details
 
28
 *
 
29
 * This class is used by other plugins, for instance
 
30
 * the async_replication module, in order to read the command log and
 
31
 * return Command messages.
 
32
 */
 
33
 
 
34
#ifndef DRIZZLE_PLUGIN_COMMAND_LOG_READER_H
 
35
#define DRIZZLE_PLUGIN_COMMAND_LOG_READER_H
 
36
 
 
37
#include "command_log.h"
 
38
 
 
39
#include <drizzled/server_includes.h>
 
40
#include <drizzled/plugin/command_reader.h>
 
41
 
 
42
/**
 
43
 * A class which reads Command messages from the Command log file
 
44
 */
 
45
class CommandLogReader :public drizzled::plugin::CommandReader
 
46
{
 
47
private:
 
48
  /** The Command log object this reader uses */
 
49
  const CommandLog &log;
 
50
public:
 
51
  CommandLogReader(const CommandLog &in_log)
 
52
    :log(in_log)
 
53
  {}
 
54
 
 
55
  /** Destructor */
 
56
  ~CommandLogReader() {}
 
57
  /**
 
58
   * Read and fill a Command message with the supplied
 
59
   * Command message global transaction ID.
 
60
   *
 
61
   * @param[in] Global transaction ID to find
 
62
   * @param[out] Pointer to a command message to fill
 
63
   *
 
64
   * @retval
 
65
   *  true if Command message was read successfully and the supplied pointer to message was filled
 
66
   * @retval
 
67
   *  false if not found or read successfully
 
68
   */
 
69
  bool read(const drizzled::ReplicationServices::GlobalTransactionId &to_read_trx_id, 
 
70
            drizzled::message::Command *to_fill);
 
71
};
 
72
 
 
73
#endif /* DRIZZLE_PLUGIN_COMMAND_LOG_READER_H */