VRWGraphList.H 4.28 KB
Newer Older
Franjo's avatar
Franjo committed
1 2 3 4 5 6 7 8
/*---------------------------------------------------------------------------*\
  =========                 |
  \\      /  F ield         | cfMesh: A library for mesh generation
   \\    /   O peration     |
    \\  /    A nd           | Author: Franjo Juretic (franjo.juretic@c-fields.com)
     \\/     M anipulation  | Copyright (C) Creative Fields, Ltd.
-------------------------------------------------------------------------------
License
Andrew Heather's avatar
Andrew Heather committed
9
    This file is part of OpenFOAM.
Franjo's avatar
Franjo committed
10

Andrew Heather's avatar
Andrew Heather committed
11 12 13 14
    OpenFOAM is free software: you can redistribute it and/or modify it
    under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
Franjo's avatar
Franjo committed
15

Andrew Heather's avatar
Andrew Heather committed
16
    OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
Franjo's avatar
Franjo committed
17 18 19 20 21
    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    for more details.

    You should have received a copy of the GNU General Public License
Andrew Heather's avatar
Andrew Heather committed
22
    along with OpenFOAM.  If not, see <http://www.gnu.org/licenses/>.
Franjo's avatar
Franjo committed
23 24

Class
25
    Foam::Module::VRWGraphList
Franjo's avatar
Franjo committed
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46

Description
    This class is an implementation of a list of graphs
    with variable column width. The implementation is memory efficient.

SourceFiles
    VRWGraphListI.H
    VRWGraphList.C

\*---------------------------------------------------------------------------*/

#ifndef VRWGraphList_H
#define VRWGraphList_H

#include "VRWGraph.H"
#include "subGraph.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

namespace Foam
{
47 48
namespace Module
{
Franjo's avatar
Franjo committed
49

50 51 52 53
// Forward declarations
class VRWGraphList;
Ostream& operator<<(Ostream&, const VRWGraphList&);

Franjo's avatar
Franjo committed
54
/*---------------------------------------------------------------------------*\
Andrew Heather's avatar
Andrew Heather committed
55
                        Class VRWGraphList Declaration
Franjo's avatar
Franjo committed
56 57 58 59 60
\*---------------------------------------------------------------------------*/

class VRWGraphList
{
    // Private data
Andrew Heather's avatar
Andrew Heather committed
61

Franjo's avatar
Franjo committed
62 63
        //- graph containing the data
        VRWGraph data_;
Andrew Heather's avatar
Andrew Heather committed
64

Franjo's avatar
Franjo committed
65 66 67
        //- number of rows
        LongList<rowElement> rows_;

Andrew Heather's avatar
Andrew Heather committed
68

Franjo's avatar
Franjo committed
69
    // Private member functions
Andrew Heather's avatar
Andrew Heather committed
70

Franjo's avatar
Franjo committed
71 72 73 74 75 76 77
        //- check index
        inline void checkIndex
        (
            const label i,
            const label j,
            const label k
        ) const;
Andrew Heather's avatar
Andrew Heather committed
78 79


Franjo's avatar
Franjo committed
80 81 82 83 84 85 86
public:

    // Constructors

        //- Construct null
        inline VRWGraphList();

Andrew Heather's avatar
Andrew Heather committed
87
        //- Copy constructor
Franjo's avatar
Franjo committed
88 89 90
        inline VRWGraphList(const VRWGraphList&);


Andrew Heather's avatar
Andrew Heather committed
91
    //- Destructor
92
    ~VRWGraphList() = default;
Andrew Heather's avatar
Andrew Heather committed
93

Franjo's avatar
Franjo committed
94 95 96 97 98 99 100

    // Member Functions

        // Access

            //- Returns the number of graphs
            inline label size() const;
Andrew Heather's avatar
Andrew Heather committed
101

Franjo's avatar
Franjo committed
102 103
            //- Returns the number of rows in the graph at that position
            inline label sizeOfGraph(const label posI) const;
Andrew Heather's avatar
Andrew Heather committed
104

Franjo's avatar
Franjo committed
105 106 107 108 109 110
            //- Return the number of element in the row at the given position
            inline label sizeOfRow(const label posI, const label rowI) const;

            //- Clear the graph
            inline void clear();

Andrew Heather's avatar
Andrew Heather committed
111

Franjo's avatar
Franjo committed
112 113 114 115 116
    // Member Operators

        //- Append a graph at the end of the graphList
        template<class GraphType>
        inline void appendGraph(const GraphType& l);
Andrew Heather's avatar
Andrew Heather committed
117

Franjo's avatar
Franjo committed
118 119 120 121 122 123 124
        //- get and set operators
        inline label operator()
        (
            const label i,
            const label j,
            const label k
        ) const;
Andrew Heather's avatar
Andrew Heather committed
125

Franjo's avatar
Franjo committed
126
        inline label& operator()(const label i, const label j, const label k);
Andrew Heather's avatar
Andrew Heather committed
127

Franjo's avatar
Franjo committed
128
        inline const subGraph<const VRWGraph> operator[](const label i) const;
Andrew Heather's avatar
Andrew Heather committed
129

Franjo's avatar
Franjo committed
130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150
        //- Assignment operator
        inline void operator=(const VRWGraphList&);


    // IOstream operators

        // Write VRWGraphList to Ostream.
        friend Ostream& operator<<(Ostream&, const VRWGraphList&);

        //- Read from Istream, discarding contents of existing VRWGraphList.
/*        friend Istream& operator>> <T, width>
        (
            Istream&,
            VRWGraphList<T, width>&
        );
*/
};


// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

151
} // End namespace Module
Franjo's avatar
Franjo committed
152 153 154 155 156 157 158 159 160 161 162
} // End namespace Foam

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

#include "VRWGraphListI.H"

// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

#endif

// ************************************************************************* //