LCOV - code coverage report
Current view: top level - home/snapwebsites/snapcpp/snapwebsites/snapdatabase/snapdatabase/database - 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             : // Copyright (c) 2019  Made to Order Software Corp.  All Rights Reserved
       2             : //
       3             : // https://snapwebsites.org/project/snapdatabase
       4             : // contact@m2osw.com
       5             : //
       6             : // This program is free software; you can redistribute it and/or modify
       7             : // it under the terms of the GNU General Public License as published by
       8             : // the Free Software Foundation; either version 2 of the License, or
       9             : // (at your option) any later version.
      10             : //
      11             : // This program is distributed in the hope that it will be useful,
      12             : // but WITHOUT ANY WARRANTY; without even the implied warranty of
      13             : // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
      14             : // GNU General Public License for more details.
      15             : //
      16             : // You should have received a copy of the GNU General Public License along
      17             : // with this program; if not, write to the Free Software Foundation, Inc.,
      18             : // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
      19             : #pragma once
      20             : 
      21             : 
      22             : /** \file
      23             :  * \brief Table file header.
      24             :  *
      25             :  * The table class handles the settings of the table and the files where the
      26             :  * data is saved.
      27             :  *
      28             :  * The _main file_ is used to save the schema. That's where we read it from.
      29             :  * This file also includes all the table settings, information about indexes,
      30             :  * etc.
      31             :  *
      32             :  * The table knows how to find all the files, create dbfile objects and
      33             :  * request those files to load blocks and thus the settings and data saved
      34             :  * in those files.
      35             :  *
      36             :  * A table is owned by a context.
      37             :  */
      38             : 
      39             : // self
      40             : //
      41             : #include    "snapdatabase/data/schema.h"
      42             : #include    "snapdatabase/data/xml.h"
      43             : 
      44             : 
      45             : 
      46             : namespace snapdatabase
      47             : {
      48             : 
      49             : 
      50             : 
      51             : namespace detail
      52             : {
      53             : class table_impl;
      54             : } // detail namespace
      55             : 
      56             : 
      57             : constexpr size_t const                          BLOCK_HEADER_SIZE = 4 + 4;  // magic + version (32 bits each)
      58             : 
      59             : class context;
      60             : class dbfile;
      61             : typedef std::shared_ptr<dbfile>                 dbfile_pointer_t;
      62             : class block;
      63             : typedef std::shared_ptr<block>                  block_pointer_t;
      64             : 
      65           0 : class table
      66             :     : public std::enable_shared_from_this<table>
      67             : {
      68             : public:
      69             :     typedef std::shared_ptr<table>              pointer_t;
      70             :     typedef std::weak_ptr<table>                weak_pointer_t;
      71             :     typedef std::map<std::string, pointer_t>    map_t;
      72             : 
      73             :                                                 table(
      74             :                                                       context * c
      75             :                                                     , xml_node::pointer_t x
      76             :                                                     , xml_node::map_t complex_types);
      77             : 
      78             :     void                                        load_extension(xml_node::pointer_t e);
      79             : 
      80             :     pointer_t                                   get_pointer();
      81             :     dbfile_pointer_t                            get_dbfile() const;
      82             :     version_t                                   version() const;
      83             :     std::string                                 name() const;
      84             :     model_t                                     model() const;
      85             :     column_ids_t                                row_key() const;
      86             :     schema_column::pointer_t                    column(std::string const & name) const;
      87             :     schema_column::pointer_t                    column(column_id_t id) const;
      88             :     schema_column::map_by_id_t                  columns_by_id() const;
      89             :     schema_column::map_by_name_t                columns_by_name() const;
      90             :     bool                                        is_sparse() const;
      91             :     bool                                        is_secure() const;
      92             :     std::string                                 description() const;
      93             :     size_t                                      get_size() const; // total size of the file right now
      94             :     size_t                                      get_page_size() const; // size of one block in bytes including the magic
      95             :     block_pointer_t                             get_block(reference_t offset);
      96             :     block_pointer_t                             allocate_new_block(dbtype_t type);
      97             :     void                                        free_block(block_pointer_t block, bool clear_block = true);
      98             :     bool                                        verify_schema();
      99             : 
     100             : private:
     101             :     std::shared_ptr<detail::table_impl>         f_impl;
     102             : };
     103             : 
     104             : 
     105             : 
     106             : } // namespace snapdatabase
     107             : // vim: ts=4 sw=4 et

Generated by: LCOV version 1.13