LCOV - code coverage report
Current view: top level - libdbproxy - libdbproxy.h (source / functions) Hit Total Coverage
Test: coverage.info Lines: 0 1 0.0 %
Date: 2019-12-15 17:13:15 Functions: 0 1 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :  * Header:
       3             :  *      libsnapwebsites/src/libdbproxy/libdbproxy.h
       4             :  *
       5             :  * Description:
       6             :  *      Handling of the cassandra::CassandraClient and corresponding transports,
       7             :  *      protocols, sockets, etc.
       8             :  *
       9             :  * Documentation:
      10             :  *      See the corresponding .cpp file.
      11             :  *
      12             :  * License:
      13             :  *      Copyright (c) 2011-2019  Made to Order Software Corp.  All Rights Reserved
      14             :  * 
      15             :  *      https://snapwebsites.org/
      16             :  *      contact@m2osw.com
      17             :  * 
      18             :  *      Permission is hereby granted, free of charge, to any person obtaining a
      19             :  *      copy of this software and associated documentation files (the
      20             :  *      "Software"), to deal in the Software without restriction, including
      21             :  *      without limitation the rights to use, copy, modify, merge, publish,
      22             :  *      distribute, sublicense, and/or sell copies of the Software, and to
      23             :  *      permit persons to whom the Software is furnished to do so, subject to
      24             :  *      the following conditions:
      25             :  *
      26             :  *      The above copyright notice and this permission notice shall be included
      27             :  *      in all copies or substantial portions of the Software.
      28             :  *
      29             :  *      THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
      30             :  *      OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
      31             :  *      MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
      32             :  *      IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
      33             :  *      CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
      34             :  *      TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
      35             :  *      SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
      36             :  */
      37             : #pragma once
      38             : 
      39             : #include "libdbproxy/context.h"
      40             : #include "libdbproxy/exception.h"
      41             : #include "libdbproxy/version.h"
      42             : 
      43             : #include <casswrapper/schema.h>
      44             : 
      45             : #include <memory>
      46             : 
      47             : namespace libdbproxy
      48             : {
      49             : 
      50             : class KsDef;
      51             : class CfDef;
      52             : class ColumnDef;
      53             : 
      54             : // library used to send database commands to the dbproxy daemon
      55             : #pragma GCC diagnostic push
      56             : #pragma GCC diagnostic ignored "-Weffc++"
      57             : #pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
      58             : class libdbproxy
      59             :     : public QObject
      60             :     , public std::enable_shared_from_this<libdbproxy>
      61             : {
      62             : public:
      63             :     typedef std::shared_ptr<libdbproxy> pointer_t;
      64             : 
      65             :     static pointer_t            create();
      66             :     virtual                     ~libdbproxy();
      67             : 
      68             :     static int                  versionMajor();
      69             :     static int                  versionMinor();
      70             :     static int                  versionPatch();
      71             :     static char const *         version();
      72             : 
      73             :     // connection functions
      74             :     bool                        connect( QString const & host = "localhost", int const port = 4042 );
      75             :     void                        disconnect();
      76             :     bool                        isConnected() const;
      77             :     QString const &             clusterName() const;
      78             :     QString const &             protocolVersion() const;
      79             :     //const QCassandraClusterInformation& clusterInformation() const;
      80             :     QString const &             partitioner() const;
      81             : 
      82           0 :     proxy::pointer_t            getProxy() const { return f_proxy; }
      83             : 
      84             :     // context functions (the database [Cassandra keyspace])
      85             :     context::pointer_t          currentContext() const { return f_current_context; }
      86             :     context::pointer_t          getContext(QString const & context_name);
      87             :     contexts const &            getContexts(bool reset = false) const;
      88             : 
      89             :     context::pointer_t          findContext(QString const & context_name) const;
      90             :     context &                   operator[] (QString const & context_name);
      91             :     context const &             operator[] (QString const & context_name) const;
      92             : 
      93             :     void                        dropContext(const QString& context_name);
      94             : 
      95             :     // default consistency level
      96             :     consistency_level_t         defaultConsistencyLevel() const;
      97             :     void                        setDefaultConsistencyLevel(consistency_level_t default_consistency_level);
      98             : 
      99             :     // time stamp helper
     100             :     static int64_t              timeofday();
     101             : 
     102             : private:
     103             :                                 libdbproxy();
     104             : 
     105             :     void                        setCurrentContext(context::pointer_t c);
     106             :     void                        clearCurrentContextIf(const context& c);
     107             : 
     108             :     context::pointer_t          getContext( casswrapper::schema::KeyspaceMeta::pointer_t keyspace_meta );
     109             :     void                        retrieveContextMeta( context::pointer_t c, QString const & context_name ) const;
     110             : 
     111             :     friend class context;
     112             : 
     113             :     proxy::pointer_t            f_proxy = proxy::pointer_t();
     114             :     context::pointer_t          f_current_context = context::pointer_t();
     115             :     mutable bool                f_contexts_read = false;
     116             :     contexts                    f_contexts = contexts();
     117             :     QString                     f_cluster_name = QString();
     118             :     QString                     f_protocol_version = QString();
     119             :     QString                     f_partitioner = QString();
     120             :     consistency_level_t         f_default_consistency_level = CONSISTENCY_LEVEL_ONE;
     121             : };
     122             : #pragma GCC diagnostic pop
     123             : 
     124             : } // namespace libdbproxy
     125             : 
     126             : // vim: ts=4 sw=4 et

Generated by: LCOV version 1.13