OpenFOAM logo
The Open Source CFD Toolbox
  Source Guide OpenCFD Solutions Contact OpenFOAM

uLabel.H

Go to the documentation of this file.
00001 /*---------------------------------------------------------------------------*\
00002   =========                 |
00003   \\      /  F ield         | OpenFOAM: The Open Source CFD Toolbox
00004    \\    /   O peration     |
00005     \\  /    A nd           | Copyright (C) 1991-2009 OpenCFD Ltd.
00006      \\/     M anipulation  |
00007 -------------------------------------------------------------------------------
00008 License
00009     This file is part of OpenFOAM.
00010 
00011     OpenFOAM is free software; you can redistribute it and/or modify it
00012     under the terms of the GNU General Public License as published by the
00013     Free Software Foundation; either version 2 of the License, or (at your
00014     option) any later version.
00015 
00016     OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
00017     ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018     FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
00019     for more details.
00020 
00021     You should have received a copy of the GNU General Public License
00022     along with OpenFOAM; if not, write to the Free Software Foundation,
00023     Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
00024 
00025 Typedef
00026     Foam::uLabel
00027 
00028 Description
00029     A uLabel is an unsigned label.
00030 
00031 SeeAlso
00032     label.H
00033 
00034 \*---------------------------------------------------------------------------*/
00035 
00036 #ifndef uLabel_H
00037 #define uLabel_H
00038 
00039 #include <climits>
00040 #include <cstdlib>
00041 
00042 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00043 
00044 
00045 #if FOAM_LABEL64
00046 #    define FOAM_ULABEL_MAX 18000000000000000000
00047 #else
00048 #    define FOAM_ULABEL_MAX 4000000000
00049 #endif
00050 
00051 
00052 #if UINT_MAX > FOAM_ULABEL_MAX
00053 
00054 // Define uLabel as an unsigned int
00055 
00056 # undef  FOAM_ULABEL_MAX
00057 # define FOAM_ULABEL_MAX UINT_MAX
00058 
00059 # include "uint.H"
00060 
00061 namespace Foam
00062 {
00063     typedef unsigned int uLabel;
00064 
00065     static const uLabel uLabelMin = 0;
00066     static const uLabel uLabelMax = UINT_MAX;
00067 
00068     inline uLabel readULabel(Istream& is)
00069     {
00070         return readUint(is);
00071     }
00072 
00073 } // End namespace Foam
00074 
00075 
00076 #elif ULONG_MAX > FOAM_ULABEL_MAX
00077 
00078 // Define uLabel as an unsigned long
00079 
00080 # undef  FOAM_ULABEL_MAX
00081 # define FOAM_ULABEL_MAX ULONG_MAX
00082 
00083 # include "uint.H"
00084 # include "ulong.H"
00085 
00086 namespace Foam
00087 {
00088     typedef unsigned long uLabel;
00089 
00090     static const uLabel uLabelMin = 0;
00091     static const uLabel uLabelMax = ULONG_MAX;
00092 
00093     inline uLabel readULabel(Istream& is)
00094     {
00095         return readUlong(is);
00096     }
00097 
00098 } // End namespace Foam
00099 
00100 
00101 #elif ULLONG_MAX > FOAM_ULABEL_MAX
00102 
00103 // Define uLabel as an unsigned long long
00104 
00105 # undef  FOAM_ULABEL_MAX
00106 
00107 # error "Not implemented yet"
00108 
00109 #endif
00110 
00111 
00112 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00113 
00114 #include "pTraits.H"
00115 #include "direction.H"
00116 
00117 namespace Foam
00118 {
00119 
00120 //- template specialization for pTraits<uLabel>
00121 template<>
00122 class pTraits<uLabel>
00123 {
00124     uLabel p_;
00125 
00126 public:
00127 
00128     //- Component type
00129     typedef uLabel cmptType;
00130 
00131     // Member constants
00132 
00133         enum
00134         {
00135             dim = 3,         // Dimensionality of space
00136             rank = 0,        // Rank of uLabel is 0
00137             nComponents = 1  // Number of components in uLabel is 1
00138         };
00139 
00140     // Static data members
00141 
00142         static const char* const typeName;
00143         static const char* componentNames[];
00144         static const uLabel zero;
00145         static const uLabel one;
00146         static const uLabel max;
00147         static const uLabel min;
00148 
00149     // Constructors
00150 
00151         //- Construct from Istream
00152         pTraits(Istream&);
00153 
00154 
00155     // Member Functions
00156 
00157         operator uLabel() const
00158         {
00159             return p_;
00160         }
00161 };
00162 
00163 
00164 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00165 
00166 inline uLabel& setComponent(uLabel& l, const direction)
00167 {
00168     return l;
00169 }
00170 
00171 inline uLabel component(const uLabel l, const direction)
00172 {
00173     return l;
00174 }
00175 
00176 
00177 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00178 
00179 } // End namespace Foam
00180 
00181 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00182 
00183 #endif
00184 
00185 // ************************************************************************* //
Copyright © 2000-2009 OpenCFD Ltd