libQtCassandra 0.3.2

QCassandraPrivate.h

Go to the documentation of this file.
00001 /*
00002  * Text:
00003  *      QCassandraPrivate.h
00004  *
00005  * Description:
00006  *      Allows the context and table objects to access the cassandra server.
00007  *
00008  * Documentation:
00009  *      See the QCassandra.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_PRIVATE_H
00037 #define QCASSANDRA_PRIVATE_H
00038 
00039 #include "QtCassandra/QCassandra.h"
00040 #include "QtCassandra/QCassandraColumnPredicate.h"
00041 #include "thrift-gencpp-cassandra/Cassandra.h"
00042 #include "thrift-gencpp-cassandra/cassandra_types.h"
00043 #include <stdexcept>
00044 
00045 namespace QtCassandra
00046 {
00047 
00048 class QCassandraPrivate
00049 {
00050 public:
00051     QCassandraPrivate(QCassandra *parent);
00052     ~QCassandraPrivate();
00053 
00054     bool connect(const QString& host, int port);
00055     void disconnect();
00056     bool isConnected() const;
00057 
00058     QString clusterName() const;
00059     QString protocolVersion() const;
00060 
00061     void setContext(const QString& context);
00062     void contexts() const;
00063     void createContext(const QCassandraContext& context);
00064     void updateContext(const QCassandraContext& context);
00065     void dropContext(const QCassandraContext& context);
00066 
00067     void createTable(const QCassandraTable *table);
00068     void updateTable(const QCassandraTable *table);
00069     void dropTable(const QString& table_name);
00070     void truncateTable(const QCassandraTable *table);
00071 
00072     void insertValue(const QString& table_name, const QByteArray& row_key, const QByteArray& column_key, const QCassandraValue& value);
00073     void getValue(const QString& table_name, const QByteArray& row_key, const QByteArray& column_key, QCassandraValue& value);
00074     int32_t getCellCount(const QString& table_name, const QByteArray& row_key, const QCassandraColumnPredicate& column_predicate);
00075     void getColumnSlice(QCassandraTable& table, const QByteArray& row_key, const QCassandraColumnPredicate& column_predicate);
00076     void remove(const QString& table_name, const QByteArray& row_key, const QByteArray& column_key, int64_t timestamp, consistency_level_t consistency_level);
00077     uint32_t getRowSlices(QCassandraTable& table, const QCassandraRowPredicate& row_predicate);
00078 
00079 private:
00080     // forbid direct copies
00081     QCassandraPrivate(const QCassandraPrivate&) {}
00082 
00083     void mustBeConnected() const throw(std::runtime_error);
00084 
00085     // we are tightly coupled with our parent so we can use a bare pointer
00086     QCassandra *                                                f_parent;
00087     boost::shared_ptr<apache::thrift::transport::TTransport>    f_socket;
00088     boost::shared_ptr<apache::thrift::transport::TTransport>    f_transport;
00089     boost::shared_ptr<apache::thrift::protocol::TProtocol>      f_protocol;
00090     boost::shared_ptr<org::apache::cassandra::CassandraClient>  f_client;
00091 };
00092 
00093 } // namespace QtCassandra
00094 #endif
00095 //#ifdef QCASSANDRA_PRIVATE_H
00096 // 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.