FTestCell.hpp 3.37 KB
Newer Older
1
// ===================================================================================
2
3
4
5
6
7
8
9
10
11
12
13
14
// Copyright ScalFmm 2011 INRIA, Olivier Coulaud, Bérenger Bramas, Matthias Messner
// olivier.coulaud@inria.fr, berenger.bramas@inria.fr
// This software is a computer program whose purpose is to compute the FMM.
//
// This software is governed by the CeCILL-C and LGPL licenses and
// abiding by the rules of distribution of free software.  
// 
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public and CeCILL-C Licenses for more details.
// "http://www.cecill.info". 
// "http://www.gnu.org/licenses".
15
// ===================================================================================
16
17
#ifndef FTESTCELL_HPP
#define FTESTCELL_HPP
18

19
#include <cstddef>
20
21
22
23
#include "FBasicCell.hpp"

/**
* @author Berenger Bramas (berenger.bramas@inria.fr)
BRAMAS Berenger's avatar
BRAMAS Berenger committed
24
25
* @class FBasicCell*
* @brief This class is used in the FTestKernels, please look at this class to know how to customize a cell.
26
*
BRAMAS Berenger's avatar
BRAMAS Berenger committed
27
28
* This cell simply store the data when up/down.
* It also shows how to be restored and saved, etc.
29
30
*/
class FTestCell : public FBasicCell  {
31
protected:
32
    // To store data during upward and downward pass
33
    long long int dataUp, dataDown;
34
35
36
37
38
39
public:
    FTestCell(): dataUp(0) , dataDown(0){
    }
    /** Default destructor */
    virtual ~FTestCell(){
    }
berenger-bramas's avatar
berenger-bramas committed
40
    /** When doing the upward pass */
41
    long long int getDataUp() const {
42
43
        return this->dataUp;
    }
berenger-bramas's avatar
berenger-bramas committed
44
    /** When doing the upward pass */
45
    void setDataUp(const long long int inData){
46
47
        this->dataUp = inData;
    }
berenger-bramas's avatar
berenger-bramas committed
48
    /** When doing the downard pass */
49
    long long int getDataDown() const {
50
51
        return this->dataDown;
    }
berenger-bramas's avatar
berenger-bramas committed
52
    /** When doing the downard pass */
53
    void setDataDown(const long long int inData){
54
55
        this->dataDown = inData;
    }
56

57
58
59
60
61
62
    /** Make it like the begining */
    void resetToInitialState(){
        this->dataDown = 0;
        this->dataUp = 0;
    }

63
64
65
    /////////////////////////////////////////////////

    /** Save the current cell in a buffer */
BRAMAS Berenger's avatar
BRAMAS Berenger committed
66
67
    template <class BufferWriterClass>
    void save(BufferWriterClass& buffer) const{
68
69
70
        FBasicCell::save(buffer);
        buffer << dataDown << dataUp;
    }
71
72

    /** Restore the current cell from a buffer */
BRAMAS Berenger's avatar
BRAMAS Berenger committed
73
74
    template <class BufferReaderClass>
    void restore(BufferReaderClass& buffer){
75
76
77
78
        FBasicCell::restore(buffer);
        buffer >> dataDown >> dataUp;
    }

79
  static size_t GetSize(){
80
81
82
    return sizeof(long long int)*2;
  }

83
84
85
    /////////////////////////////////////////////////

    /** Serialize only up data in a buffer */
BRAMAS Berenger's avatar
BRAMAS Berenger committed
86
87
    template <class BufferWriterClass>
    void serializeUp(BufferWriterClass& buffer) const {
88
89
        buffer << this->dataUp;
    }
90
    /** Deserialize only up data in a buffer */
BRAMAS Berenger's avatar
BRAMAS Berenger committed
91
92
    template <class BufferReaderClass>
    void deserializeUp(BufferReaderClass& buffer){
93
94
95
        buffer >> this->dataUp;
    }

96
    /** Serialize only down data in a buffer */
BRAMAS Berenger's avatar
BRAMAS Berenger committed
97
98
    template <class BufferWriterClass>
    void serializeDown(BufferWriterClass& buffer) const {
99
100
        buffer << this->dataDown;
    }
101
    /** Deserialize only up data in a buffer */
BRAMAS Berenger's avatar
BRAMAS Berenger committed
102
103
    template <class BufferReaderClass>
    void deserializeDown(BufferReaderClass& buffer){
104
105
        buffer >> this->dataDown;
    }
106

107
108
109
110
111
};


#endif //FTESTCELL_HPP

112