libQtCassandra 0.3.2
|
00001 /* 00002 * Header: 00003 * QCassandra.h 00004 * 00005 * Description: 00006 * Handling of the cassandra::CassandraClient and corresponding transports, 00007 * protocols, sockets, etc. 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_H 00038 #define QCASSANDRA_H 00039 00040 #include "QtCassandra/QCassandraContext.h" 00041 00042 namespace QtCassandra 00043 { 00044 00045 // that needs to go in something like the QCassandra.h file instead? 00046 static const int QT_CASSANDRA_LIBRARY_VERSION_MAJOR = @LIBQTCASSANDRA_VERSION_MAJOR@; 00047 static const int QT_CASSANDRA_LIBRARY_VERSION_MINOR = @LIBQTCASSANDRA_VERSION_MINOR@; 00048 static const int QT_CASSANDRA_LIBRARY_VERSION_PATCH = @LIBQTCASSANDRA_VERSION_PATCH@; 00049 static const char *QT_CASSANDRA_LIBRARY_VERSION_STRING = "@LIBQTCASSANDRA_VERSION_MAJOR@.@LIBQTCASSANDRA_VERSION_MINOR@.@LIBQTCASSANDRA_VERSION_PATCH@"; 00050 00051 class QCassandraPrivate; 00052 00053 00054 // Handling of the transport and CassandraClient objects 00055 class QCassandra : public QObject 00056 { 00057 public: 00058 QCassandra(); 00059 virtual ~QCassandra(); 00060 00061 static int versionMajor(); 00062 static int versionMinor(); 00063 static int versionPatch(); 00064 static const char *version(); 00065 00066 // connection functions 00067 bool connect(const QString& host = "localhost", int port = 9160); 00068 void disconnect(); 00069 bool isConnected() const; 00070 const QString& clusterName() const; 00071 const QString& protocolVersion() const; 00072 00073 // context functions (the database [Cassandra keyspace]) 00074 QSharedPointer<QCassandraContext> context(const QString& context_name); 00075 const QCassandraContexts& contexts() const; 00076 00077 QSharedPointer<QCassandraContext> findContext(const QString& context_name) const; 00078 QCassandraContext& operator[] (const QString& context_name); 00079 const QCassandraContext& operator[] (const QString& context_name) const; 00080 00081 void dropContext(const QString& context_name); 00082 00083 // default consistency level 00084 consistency_level_t defaultConsistencyLevel() const; 00085 void setDefaultConsistencyLevel(consistency_level_t default_consistency_level); 00086 00087 // time stamp helper 00088 static int64_t timeofday(); 00089 00090 private: 00091 //QSharedPointer<QCassandraContext> currentContext() const; 00092 void setCurrentContext(QSharedPointer<QCassandraContext> c); 00093 void clearCurrentContextIf(const QCassandraContext& c); 00094 QCassandraPrivate *getPrivate(); 00095 00096 friend class QCassandraPrivate; 00097 friend class QCassandraContext; 00098 00099 std::auto_ptr<QCassandraPrivate> f_private; 00100 QSharedPointer<QCassandraContext> f_current_context; 00101 mutable controlled_vars::zbool_t f_contexts_read; 00102 QCassandraContexts f_contexts; 00103 QString f_cluster_name; 00104 QString f_protocol_version; 00105 consistency_level_t f_default_consistency_level; 00106 }; 00107 00108 } // namespace QtCassandra 00109 #endif 00110 //#ifndef QCASSANDRA_H 00111 // vim: ts=4 sw=4 et
This document is part of the libQtCassandra Project.
Copyright by Made to Order Software Corp.