libQtCassandra 0.3.2

QCassandraColumnPredicate.h

Go to the documentation of this file.
00001 /*
00002  * Header:
00003  *      QCassandraColumnPredicate.h
00004  *
00005  * Description:
00006  *      Handling of the cassandra::SlicePredicate to retrieve a set of columns
00007  *      all at once.
00008  *
00009  * Documentation:
00010  *      See the corresponding .cpp file.
00011  *
00012  * License:
00013  *      Copyright (c) 2011 Made to Order Software Corp.
00014  * 
00015  *      http://snapwebsites.org/
00016  *      contact@m2osw.com
00017  *
00018  *      Permission is hereby granted, free of charge, to any person obtaining a
00019  *      copy of this software and associated documentation files (the
00020  *      "Software"), to deal in the Software without restriction, including
00021  *      without limitation the rights to use, copy, modify, merge, publish,
00022  *      distribute, sublicense, and/or sell copies of the Software, and to
00023  *      permit persons to whom the Software is furnished to do so, subject to
00024  *      the following conditions:
00025  *
00026  *      The above copyright notice and this permission notice shall be included
00027  *      in all copies or substantial portions of the Software.
00028  *
00029  *      THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00030  *      OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00031  *      MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
00032  *      IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
00033  *      CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
00034  *      TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
00035  *      SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00036  */
00037 #ifndef QCASSANDRA_COLUMN_PREDICATE_H
00038 #define QCASSANDRA_COLUMN_PREDICATE_H
00039 
00040 #include "QCassandraConsistencyLevel.h"
00041 #include <controlled_vars/controlled_vars_limited_auto_init.h>
00042 #include <QtCore/QByteArray>
00043 #include <QtCore/QVector>
00044 
00045 namespace QtCassandra
00046 {
00047 
00048 class QCassandraPrivate;
00049 
00050 // count must be positive and defaults to 100
00051 typedef controlled_vars::limited_auto_init<int32_t, 1, INT_MAX, 100> cassandra_count_t;
00052 
00053 // Predicates for the Cassandra get_slice() function
00054 
00055 // common predicate information
00056 class QCassandraColumnPredicate : public QObject
00057 {
00058 public:
00059     QCassandraColumnPredicate();
00060 
00061     consistency_level_t consistencyLevel() const;
00062     void setConsistencyLevel(consistency_level_t consistency_level);
00063 
00064 private:
00065     virtual void toPredicate(void *data) const;
00066 
00067     friend class QCassandraPrivate;
00068 
00069     consistency_level_t     f_consistency_level;
00070 };
00071 
00072 // name based predicate (specific names)
00073 class QCassandraColumnNamePredicate : public QCassandraColumnPredicate
00074 {
00075 public:
00076     typedef QVector<QByteArray> QCassandraColumnKeys;
00077 
00078     QCassandraColumnNamePredicate();
00079 
00080     void clearColumns();
00081     void addColumnName(const QString& column_name);
00082     void addColumnKey(const QByteArray& column_key);
00083     const QCassandraColumnKeys& columnKeys() const;
00084 
00085 private:
00086     virtual void toPredicate(void *data) const;
00087 
00088     QCassandraColumnKeys        f_column_keys;
00089 };
00090 
00091 // range based predicate (all columns between a specific range)
00092 class QCassandraColumnRangePredicate : public QCassandraColumnPredicate
00093 {
00094 public:
00095     QCassandraColumnRangePredicate();
00096 
00097     QString startColumnName() const;
00098     void setStartColumnName(const QString& column_name);
00099     const QByteArray& startColumnKey() const;
00100     void setStartColumnKey(const QByteArray& column_key);
00101 
00102     QString endColumnName() const;
00103     void setFinishColumnName(const QString& column_name);
00104     const QByteArray& endColumnKey() const;
00105     void setFinishColumnKey(const QByteArray& column_key);
00106 
00107     bool reversed() const;
00108     void setReversed(bool reversed = true);
00109 
00110     int32_t count() const;
00111     void setCount(int32_t count = 100);
00112 
00113 private:
00114     virtual void toPredicate(void *data) const;
00115 
00116     QByteArray                  f_start_column;
00117     QByteArray                  f_end_column;
00118     controlled_vars::zbool_t    f_reversed;
00119     cassandra_count_t           f_count;
00120 };
00121 
00122 } // namespace QtCassandra
00123 #endif
00124 //#ifndef QCASSANDRA_COLUMN_PREDICATE_H
00125 // 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.