libQtCassandra 0.3.2

QCassandraRow.h

Go to the documentation of this file.
00001 /*
00002  * Header:
00003  *      QCassandraRow.h
00004  *
00005  * Description:
00006  *      Handling of a row to access colunms within that row.
00007  *
00008  * Documentation:
00009  *      See the corresponding .cpp file.
00010  *
00011  * License:
00012  *      Copyright (c) 2011 Made to Order Software Corp.
00013  * 
00014  *      http://snapwebsites.org/
00015  *      contact@m2osw.com
00016  * 
00017  *      Permission is hereby granted, free of charge, to any person obtaining a
00018  *      copy of this software and associated documentation files (the
00019  *      "Software"), to deal in the Software without restriction, including
00020  *      without limitation the rights to use, copy, modify, merge, publish,
00021  *      distribute, sublicense, and/or sell copies of the Software, and to
00022  *      permit persons to whom the Software is furnished to do so, subject to
00023  *      the following conditions:
00024  *
00025  *      The above copyright notice and this permission notice shall be included
00026  *      in all copies or substantial portions of the Software.
00027  *
00028  *      THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00029  *      OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00030  *      MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00031  *      IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
00032  *      CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
00033  *      TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
00034  *      SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00035  */
00036 #ifndef QCASSANDRA_ROW_H
00037 #define QCASSANDRA_ROW_H
00038 
00039 #include "QCassandraCell.h"
00040 #include "QCassandraColumnPredicate.h"
00041 
00042 namespace QtCassandra
00043 {
00044 
00045 class QCassandraTable;
00046 
00047 // Cassandra Row
00048 class QCassandraRow : public QObject
00049 {
00050 public:
00051     virtual ~QCassandraRow();
00052 
00053     QString rowName() const;
00054     const QByteArray& rowKey() const;
00055 
00056     int cellCount(const QCassandraColumnPredicate& column_predicate = QCassandraColumnPredicate());
00057     void readCells(const QCassandraColumnPredicate& column_predicate = QCassandraColumnPredicate());
00058 
00059     QSharedPointer<QCassandraCell> cell(const QString& column_name);
00060     QSharedPointer<QCassandraCell> cell(const QByteArray& column_key);
00061     const QCassandraCells& cells() const;
00062 
00063     QSharedPointer<QCassandraCell> findCell(const QString& column_name) const;
00064     QSharedPointer<QCassandraCell> findCell(const QByteArray& column_key) const;
00065     bool exists(const QString& column_name) const;
00066     bool exists(const QByteArray& column_key) const;
00067     QCassandraCell& operator [] (const QString& column_name);
00068     QCassandraCell& operator [] (const QByteArray& column_key);
00069     const QCassandraCell& operator [] (const QString& column_name) const;
00070     const QCassandraCell& operator [] (const QByteArray& column_key) const;
00071 
00072     void clearCache();
00073 
00074     void dropCell(const QByteArray& column_key, QCassandraValue::timestamp_mode_t mode = QCassandraValue::TIMESTAMP_MODE_AUTO, int64_t timestamp = 0);
00075     void dropCell(const QString& column_name, QCassandraValue::timestamp_mode_t mode = QCassandraValue::TIMESTAMP_MODE_AUTO, int64_t timestamp = 0);
00076 
00077 private:
00078     QCassandraRow(QCassandraTable *table, const QByteArray& row_key);
00079 
00080     void insertValue(const QByteArray& column_key, const QCassandraValue& value);
00081     void getValue(const QByteArray& column_key, QCassandraValue& value);
00082     void unparent();
00083 
00084     friend class QCassandraTable;
00085     friend class QCassandraCell;
00086 
00087     // f_table is a parent that has a strong shared pointer over us so it
00088     // cannot disappear before we do, thus only a bare pointer is enough here
00089     // (there isn't a need to use a QWeakPointer or QPointer either)
00090     QCassandraTable *       f_table;
00091     QByteArray              f_key;
00092     QCassandraCells         f_cells;
00093 };
00094 
00095 // array of rows
00096 typedef QMap<QByteArray, QSharedPointer<QCassandraRow> > QCassandraRows;
00097 
00098 
00099 
00100 } // namespace QtCassandra
00101 #endif
00102 //#ifndef QCASSANDRA_ROW_H
00103 // vim: ts=4 sw=4 et
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines

This document is part of the libQtCassandra Project.

Copyright by Made to Order Software Corp.