initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / memory / tmp / refCount.H
blob6af7317cedc4179bf27a4bee3c2d71d6b7d4ad73
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
4    \\    /   O peration     |
5     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
6      \\/     M anipulation  |
7 -------------------------------------------------------------------------------
8 License
9     This file is part of OpenFOAM.
11     OpenFOAM is free software; you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation; either version 2 of the License, or (at your
14     option) any later version.
16     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
19     for more details.
21     You should have received a copy of the GNU General Public License
22     along with OpenFOAM; if not, write to the Free Software Foundation,
23     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
25 Class
26     Foam::refCount
28 Description
29     Reference counter for tmp\<field\>.
31 \*---------------------------------------------------------------------------*/
33 #ifndef refCount_H
34 #define refCount_H
36 #include "bool.H"
38 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 namespace Foam
43 /*---------------------------------------------------------------------------*\
44                           Class refCount Declaration
45 \*---------------------------------------------------------------------------*/
47 class refCount
49     // Private data
51         int count_;
53     // Private member functions
55         //- Dissallow copy
56         refCount(const refCount&);
58         //- Dissallow bitwise assignment
59         void operator=(const refCount&);
62 public:
64     // Constructors
66         //- Construct null with zero count
67         refCount()
68         :
69             count_(0)
70         {}
73     // Member Functions
75         //- Return the reference count
76         int count() const
77         {
78             return count_;
79         }
82         //- Return true if the reference count is zero
83         bool okToDelete() const
84         {
85             return !count_;
86         }
89         //- Reset the reference count to zero
90         void resetRefCount()
91         {
92             count_ = 0;
93         }
96     // Member Operators
98         //- Increment the reference count
99         void operator++()
100         {
101             count_++;
102         }
104         //- Increment the reference count
105         void operator++(int)
106         {
107             count_++;
108         }
110         //- Decrement the reference count
111         void operator--()
112         {
113             count_--;
114         }
116         //- Decrement the reference count
117         void operator--(int)
118         {
119             count_--;
120         }
124 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
126 } // End namespace Foam
128 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
130 #endif
132 // ************************************************************************* //