LCOV - code coverage report
Current view: top level - libdbproxy - table.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/table.h
       4             :  *
       5             :  * Description:
       6             :  *      Handling of Cassandra Tables.
       7             :  *
       8             :  * Documentation:
       9             :  *      See the corresponding .cpp file.
      10             :  *
      11             :  * License:
      12             :  *      Copyright (c) 2011-2019  Made to Order Software Corp.  All Rights Reserved
      13             :  * 
      14             :  *      https://snapwebsites.org/
      15             :  *      contact@m2osw.com
      16             :  * 
      17             :  *      Permission is hereby granted, free of charge, to any person obtaining a
      18             :  *      copy of this software and associated documentation files (the
      19             :  *      "Software"), to deal in the Software without restriction, including
      20             :  *      without limitation the rights to use, copy, modify, merge, publish,
      21             :  *      distribute, sublicense, and/or sell copies of the Software, and to
      22             :  *      permit persons to whom the Software is furnished to do so, subject to
      23             :  *      the following conditions:
      24             :  *
      25             :  *      The above copyright notice and this permission notice shall be included
      26             :  *      in all copies or substantial portions of the Software.
      27             :  *
      28             :  *      THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
      29             :  *      OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
      30             :  *      MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
      31             :  *      IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
      32             :  *      CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
      33             :  *      TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
      34             :  *      SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
      35             :  */
      36             : #pragma once
      37             : 
      38             : #include "libdbproxy/consistency_level.h"
      39             : #include "libdbproxy/predicate.h"
      40             : #include "libdbproxy/proxy.h"
      41             : #include "libdbproxy/row.h"
      42             : 
      43             : #include <casswrapper/schema.h>
      44             : 
      45             : #include <cstdint>
      46             : #include <memory>
      47             : 
      48             : namespace libdbproxy
      49             : {
      50             : 
      51             : class context;
      52             : 
      53             : 
      54             : // Cassandra Column Family
      55             : #pragma GCC diagnostic push
      56             : #pragma GCC diagnostic ignored "-Weffc++"
      57             : #pragma GCC diagnostic ignored "-Wnon-virtual-dtor"
      58             : class table
      59             :     : public QObject
      60             :     , public std::enable_shared_from_this<table>
      61             : {
      62             : public:
      63             :     typedef std::shared_ptr<table> pointer_t;
      64             : 
      65             :     virtual             ~table();
      66             : 
      67           0 :     proxy::pointer_t    getProxy() const { return f_proxy; }
      68             : 
      69             :     // context name
      70             :     const QString&      contextName() const;
      71             :     QString             tableName()   const;
      72             : 
      73             :     // fields
      74             :     //
      75             :     const casswrapper::schema::Value::map_t& fields() const;
      76             :     casswrapper::schema::Value::map_t&       fields();
      77             : 
      78             :     // handling
      79             :     void                create();
      80             :     //void                update();
      81             :     void                truncate();
      82             :     void                clearCache();
      83             : 
      84             :     // row handling
      85             :     uint32_t            readRows(row_predicate::pointer_t row_predicate );
      86             : 
      87             :     row::pointer_t      getRow(const char *      row_name);
      88             :     row::pointer_t      getRow(const QString&    row_name);
      89             :     row::pointer_t      getRow(const QByteArray& row_name);
      90             :     const rows&         getRows();
      91             : 
      92             :     row::pointer_t      findRow(const char * row_name) const;
      93             :     row::pointer_t      findRow(const QString& row_name) const;
      94             :     row::pointer_t      findRow(const QByteArray& row_name) const;
      95             :     bool                exists(const char* row_name) const;
      96             :     bool                exists(const QString& row_name) const;
      97             :     bool                exists(const QByteArray& row_name) const;
      98             :     row&                operator [] (const char * row_name);
      99             :     row&                operator [] (const QString& row_name);
     100             :     row&                operator [] (const QByteArray& row_name);
     101             :     const row&          operator [] (const char * row_name) const;
     102             :     const row&          operator [] (const QString& row_name) const;
     103             :     const row&          operator [] (const QByteArray& row_name) const;
     104             : 
     105             :     void                dropRow(const char *      row_name);
     106             :     void                dropRow(const QString&    row_name);
     107             :     void                dropRow(const QByteArray& row_name);
     108             : 
     109             :     std::shared_ptr<context> parentContext() const;
     110             : 
     111             :     void                startBatch();
     112             :     void                commitBatch();
     113             :     void                rollbackBatch();
     114             : 
     115             : private:
     116             :     friend class context;
     117             :     friend class row;
     118             : 
     119             :                         table(std::shared_ptr<context> context, const QString& table_name);
     120             : 
     121             :     void                setFromCassandra();
     122             :     void                parseTableDefinition( casswrapper::schema::TableMeta::pointer_t table_meta );
     123             :     void                insertValue(const QByteArray& row_key, const QByteArray& column_key, const value& value);
     124             :     bool                getValue(const QByteArray& row_key, const QByteArray& column_key, value& value);
     125             :     void                assignRow(const QByteArray& row_key, const QByteArray& column_key, const value& value);
     126             :     int32_t             getCellCount(const QByteArray& row_key, cell_predicate::pointer_t column_predicate);
     127             :     void                remove
     128             :                             ( const QByteArray& row_key
     129             :                             , const QByteArray& column_key
     130             :                             , consistency_level_t consistency_level = CONSISTENCY_LEVEL_DEFAULT
     131             :                             );
     132             :     void                remove( const QByteArray& row_key );
     133             :     void                closeCursor();
     134             : 
     135             :     bool                isCounterClass();
     136             : 
     137             :     void                loadTables();
     138             :     void                addRow( const QByteArray& row_key, const QByteArray& column_key, const QByteArray& data );
     139             : 
     140             :     QString             getTableOptions() const;
     141             : 
     142             :     casswrapper::schema::TableMeta::pointer_t
     143             :                             f_schema = casswrapper::schema::TableMeta::pointer_t();
     144             : 
     145             :     bool                    f_from_cassandra = false;
     146             :     std::weak_ptr<context>  f_context = std::weak_ptr<context>();
     147             :     QString                 f_context_name = QString();
     148             :     QString                 f_table_name = QString();
     149             :     rows                    f_rows = rows();
     150             : 
     151             :     proxy::pointer_t        f_proxy = proxy::pointer_t();
     152             :     int32_t                 f_cursor_index = -1;
     153             :     int32_t                 f_batch_index  = -1;
     154             : };
     155             : #pragma GCC diagnostic pop
     156             : 
     157             : // list of table definitions mapped against their name (see tableName())
     158             : typedef QMap<QString, table::pointer_t > tables;
     159             : 
     160             : } // namespace libdbproxy
     161             : 
     162             : // vim: ts=4 sw=4 et

Generated by: LCOV version 1.13