initial commit for version 1.6.x patch release
[OpenFOAM-1.6.x.git] / src / OpenFOAM / primitives / ints / uLabel / uLabel.H
blob2851ee75dd48a123400ec0cee8f2666ee2491136
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 Typedef
26     Foam::uLabel
28 Description
29     A uLabel is an unsigned label.
31 SeeAlso
32     label.H
34 \*---------------------------------------------------------------------------*/
36 #ifndef uLabel_H
37 #define uLabel_H
39 #include <climits>
40 #include <cstdlib>
42 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 #if FOAM_LABEL64
46 #    define FOAM_ULABEL_MAX 18000000000000000000
47 #else
48 #    define FOAM_ULABEL_MAX 4000000000
49 #endif
52 #if UINT_MAX > FOAM_ULABEL_MAX
54 // Define uLabel as an unsigned int
56 # undef  FOAM_ULABEL_MAX
57 # define FOAM_ULABEL_MAX UINT_MAX
59 # include "uint.H"
61 namespace Foam
63     typedef unsigned int uLabel;
65     static const uLabel uLabelMin = 0;
66     static const uLabel uLabelMax = UINT_MAX;
68     inline uLabel readULabel(Istream& is)
69     {
70         return readUint(is);
71     }
73 } // End namespace Foam
76 #elif ULONG_MAX > FOAM_ULABEL_MAX
78 // Define uLabel as an unsigned long
80 # undef  FOAM_ULABEL_MAX
81 # define FOAM_ULABEL_MAX ULONG_MAX
83 # include "uint.H"
84 # include "ulong.H"
86 namespace Foam
88     typedef unsigned long uLabel;
90     static const uLabel uLabelMin = 0;
91     static const uLabel uLabelMax = ULONG_MAX;
93     inline uLabel readULabel(Istream& is)
94     {
95         return readUlong(is);
96     }
98 } // End namespace Foam
101 #elif ULLONG_MAX > FOAM_ULABEL_MAX
103 // Define uLabel as an unsigned long long
105 # undef  FOAM_ULABEL_MAX
107 # error "Not implemented yet"
109 #endif
112 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
114 #include "pTraits.H"
115 #include "direction.H"
117 namespace Foam
120 //- template specialization for pTraits<uLabel>
121 template<>
122 class pTraits<uLabel>
124     uLabel p_;
126 public:
128     //- Component type
129     typedef uLabel cmptType;
131     // Member constants
133         enum
134         {
135             dim = 3,         // Dimensionality of space
136             rank = 0,        // Rank of uLabel is 0
137             nComponents = 1  // Number of components in uLabel is 1
138         };
140     // Static data members
142         static const char* const typeName;
143         static const char* componentNames[];
144         static const uLabel zero;
145         static const uLabel one;
146         static const uLabel max;
147         static const uLabel min;
149     // Constructors
151         //- Construct from Istream
152         pTraits(Istream&);
155     // Member Functions
157         operator uLabel() const
158         {
159             return p_;
160         }
164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
166 inline uLabel& setComponent(uLabel& l, const direction)
168     return l;
171 inline uLabel component(const uLabel l, const direction)
173     return l;
177 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
179 } // End namespace Foam
181 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
183 #endif
185 // ************************************************************************* //