LCOV - code coverage report
Current view: top level - include/journal - absjournal.h (source / functions) Hit Total Coverage
Test: CoherentDB code coverage Lines: 3 3 100.0 %
Date: 2011-02-13 Functions: 6 9 66.7 %

          Line data    Source code
       1             : /*
       2             :  * (C) Copyright 2011 Marek Dopiera
       3             :  * 
       4             :  * This file is part of CoherentDB.
       5             :  * 
       6             :  * CoherentDB is free software: you can redistribute it and/or modify it
       7             :  * under the terms of the GNU General Public License as published by
       8             :  * the Free Software Foundation, either version 3 of the License, or
       9             :  * (at your option) any later version.
      10             :  * 
      11             :  * CoherentDB is distributed in the hope that it will be useful, but
      12             :  * WITHOUT ANY WARRANTY; without even the implied warranty of
      13             :  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
      14             :  * General Public License for more details.
      15             :  * 
      16             :  * You should have received a copy of the GNU General Public
      17             :  * License along with CoherentDB. If not, see
      18             :  * http://www.gnu.org/licenses/.
      19             :  */
      20             : 
      21             : #ifndef ABSJOURNAL_H_5316
      22             : #define ABSJOURNAL_H_5316
      23             : 
      24             : #include <stdint.h>
      25             : 
      26             : #include <exception>
      27             : 
      28             : #include <boost/noncopyable.hpp>
      29             : 
      30             : #include <util/misc.h>
      31             : #include <util/multi_buffer.h>
      32             : 
      33             : namespace coherent {
      34             : namespace journal {
      35             : 
      36             : class abs_journal :
      37             :         public util::virtual_dest,
      38             :         private boost::noncopyable
      39             : {
      40           2 : public:
      41             :         typedef uint32_t owner_id_t;
      42             :         typedef uint32_t handle_t;
      43             : 
      44             :         //XXX replace with something reasonable
      45             :         typedef std::exception recovery_except;
      46             : 
      47             :         struct insert_cb : public util::virtual_dest
      48             :         {
      49          30 :                 virtual void insert_success(
      50             :                         owner_id_t owner,
      51             :                         util::multi_buffer const & buf,
      52             :                         handle_t handle
      53             :                         ) throw() = 0;
      54             :                 virtual void insert_failure(
      55             :                         owner_id_t owner,
      56             :                         util::multi_buffer const & buf,
      57             :                         int err
      58             :                         ) throw() = 0;
      59             :         };
      60             :         typedef boost::shared_ptr<insert_cb> insert_cb_ptr;
      61             : 
      62             :         struct erase_cb : public util::virtual_dest
      63             :         {
      64          30 :                 virtual void erase_success(
      65             :                         owner_id_t owner,
      66             :                         handle_t handle
      67             :                         ) throw() = 0;
      68             :                 virtual void erase_failure(
      69             :                         owner_id_t owner,
      70             :                         handle_t handle,
      71             :                         int err
      72             :                         ) throw() = 0;
      73             :         };
      74             :         
      75             :         struct recovery_dispatcher : public util::virtual_dest
      76             :         {
      77             :                 virtual void dispatch(
      78             :                         owner_id_t owner,
      79             :                         handle_t handle,
      80             :                         util::multi_buffer const & buffer
      81             :                 ) throw() = 0;
      82             :         };
      83             : 
      84             :         virtual void insert(
      85             :                 owner_id_t owner,
      86             :                 util::multi_buffer const & buf,
      87             :                 insert_cb & cb
      88             :                 ) throw() = 0;
      89             : 
      90             :         virtual void erase(
      91             :                 owner_id_t owner,
      92             :                 handle_t handle,
      93             :                 erase_cb & erase
      94             :                 ) throw() = 0;
      95             : 
      96             :         // should be called before any insert or erase
      97             :         virtual void recover(
      98             :                 recovery_dispatcher & dispatcher
      99             :                 ) throw(recovery_dispatcher) = 0;
     100             : 
     101             : };
     102             : 
     103             : } // namespace journal 
     104             : } // namespace coherent
     105             : 
     106             : #endif /* ABSJOURNAL_H_5316 */
     107             : 

Generated by: LCOV version 1.9