[Groonga-commit] groonga/grnxx at 2ce4317 [master] Modify Cursor to have const Table * instead of Table *.

Back to archive index

susumu.yata null+****@clear*****
Tue Jul 8 16:05:14 JST 2014


susumu.yata	2014-07-08 16:05:14 +0900 (Tue, 08 Jul 2014)

  New Revision: 2ce4317c6740c95460b15fa0f4250d9060e35517
  https://github.com/groonga/grnxx/commit/2ce4317c6740c95460b15fa0f4250d9060e35517

  Message:
    Modify Cursor to have const Table * instead of Table *.

  Modified files:
    include/grnxx/cursor.hpp
    include/grnxx/table.hpp
    lib/grnxx/table.cpp

  Modified: include/grnxx/cursor.hpp (+3 -3)
===================================================================
--- include/grnxx/cursor.hpp    2014-07-08 16:01:31 +0900 (9f0df0e)
+++ include/grnxx/cursor.hpp    2014-07-08 16:05:14 +0900 (1650a3f)
@@ -21,11 +21,11 @@ struct CursorOptions {
 
 class Cursor {
  public:
-  explicit Cursor(Table *table) : table_(table) {}
+  explicit Cursor(const Table *table) : table_(table) {}
   virtual ~Cursor() {}
 
   // Return the associated table.
-  Table *table() const {
+  const Table *table() const {
     return table_;
   }
 
@@ -42,7 +42,7 @@ class Cursor {
                    RecordSet *record_set) = 0;
 
  protected:
-  Table *table_;
+  const Table *table_;
 };
 
 }  // namespace grnxx

  Modified: include/grnxx/table.hpp (+1 -1)
===================================================================
--- include/grnxx/table.hpp    2014-07-08 16:01:31 +0900 (774b339)
+++ include/grnxx/table.hpp    2014-07-08 16:05:14 +0900 (27265c4)
@@ -168,7 +168,7 @@ class Table {
   // "error" != nullptr.
   unique_ptr<Cursor> create_cursor(
       Error *error,
-      const CursorOptions &options);
+      const CursorOptions &options) const;
 
   // Create an object to build expressions.
   //

  Modified: lib/grnxx/table.cpp (+5 -8)
===================================================================
--- lib/grnxx/table.cpp    2014-07-08 16:01:31 +0900 (c9ba1e4)
+++ lib/grnxx/table.cpp    2014-07-08 16:05:14 +0900 (caa9ba9)
@@ -16,9 +16,6 @@ class TableCursor : public Cursor {
 
   ~TableCursor() {}
 
-  Table *table() const {
-    return table_;
-  }
   Int read(Error *error, Int max_count, RecordSet *record_set);
 
   // -- Internal API --
@@ -29,7 +26,7 @@ class TableCursor : public Cursor {
   // On failure, returns nullptr and stores error information into "*error" if
   // "error" != nullptr.
   static unique_ptr<TableCursor> create(Error *error,
-                                        Table *table,
+                                        const Table *table,
                                         const CursorOptions &options);
 
   // Read records in regular order.
@@ -44,7 +41,7 @@ class TableCursor : public Cursor {
   OrderType order_type_;
   Int next_row_id_;
 
-  explicit TableCursor(Table *table);
+  explicit TableCursor(const Table *table);
 };
 
 Int TableCursor::read(Error *error, Int max_count, RecordSet *record_set) {
@@ -66,7 +63,7 @@ Int TableCursor::read(Error *error, Int max_count, RecordSet *record_set) {
 }
 
 unique_ptr<TableCursor> TableCursor::create(Error *error,
-                                            Table *table,
+                                            const Table *table,
                                             const CursorOptions &options) {
   unique_ptr<TableCursor> cursor(new (nothrow) TableCursor(table));
   if (!cursor) {
@@ -94,7 +91,7 @@ unique_ptr<TableCursor> TableCursor::create(Error *error,
   return cursor;
 }
 
-TableCursor::TableCursor(Table *table)
+TableCursor::TableCursor(const Table *table)
     : Cursor(table),
       offset_left_(),
       limit_left_(),
@@ -379,7 +376,7 @@ Int Table::find_row(Error *error, const Datum &key) const {
 
 unique_ptr<Cursor> Table::create_cursor(
     Error *error,
-    const CursorOptions &options) {
+    const CursorOptions &options) const {
   return TableCursor::create(error, this, options);
 }
 
-------------- next part --------------
HTML����������������������������...
Download 



More information about the Groonga-commit mailing list
Back to archive index