FreeFOAM The Cross-Platform CFD Toolkit
Hosted by SourceForge:
Get FreeFOAM at SourceForge.net.
            Fast, secure and Free Open Source software downloads

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-2010 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
00013     the Free Software Foundation, either version 3 of the License, or
00014     (at your 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, see <http://www.gnu.org/licenses/>.
00023 
00024 Typedef
00025     Foam::uLabel
00026 
00027 Description
00028     A uLabel is an unsigned label.
00029 
00030 SeeAlso
00031     label.H
00032 
00033 \*---------------------------------------------------------------------------*/
00034 
00035 #ifndef uLabel_H
00036 #define uLabel_H
00037 
00038 #include <climits>
00039 #include <cstdlib>
00040 
00041 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00042 
00043 
00044 #if FOAM_LABEL64
00045 #    define FOAM_ULABEL_MAX 18000000000000000000
00046 #else
00047 #    define FOAM_ULABEL_MAX 4000000000
00048 #endif
00049 
00050 
00051 #if UINT_MAX > FOAM_ULABEL_MAX
00052 
00053 // Define uLabel as an unsigned int
00054 
00055 # undef  FOAM_ULABEL_MAX
00056 # define FOAM_ULABEL_MAX UINT_MAX
00057 
00058 # include <OpenFOAM/uint.H>
00059 
00060 namespace Foam
00061 {
00062     typedef unsigned int uLabel;
00063 
00064     static const uLabel uLabelMin = 0;
00065     static const uLabel uLabelMax = UINT_MAX;
00066 
00067     inline uLabel readULabel(Istream& is)
00068     {
00069         return readUint(is);
00070     }
00071 
00072 } // End namespace Foam
00073 
00074 
00075 #elif ULONG_MAX > FOAM_ULABEL_MAX
00076 
00077 // Define uLabel as an unsigned long
00078 
00079 # undef  FOAM_ULABEL_MAX
00080 # define FOAM_ULABEL_MAX ULONG_MAX
00081 
00082 # include <OpenFOAM/uint.H>
00083 # include <OpenFOAM/ulong.H>
00084 
00085 namespace Foam
00086 {
00087     typedef unsigned long uLabel;
00088 
00089     static const uLabel uLabelMin = 0;
00090     static const uLabel uLabelMax = ULONG_MAX;
00091 
00092     inline uLabel readULabel(Istream& is)
00093     {
00094         return readUlong(is);
00095     }
00096 
00097 } // End namespace Foam
00098 
00099 
00100 #elif ULLONG_MAX > FOAM_ULABEL_MAX
00101 
00102 // Define uLabel as an unsigned long long
00103 
00104 # undef  FOAM_ULABEL_MAX
00105 
00106 # error "Not implemented yet"
00107 
00108 #endif
00109 
00110 
00111 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00112 
00113 #include <OpenFOAM/pTraits.H>
00114 #include <OpenFOAM/direction.H>
00115 
00116 namespace Foam
00117 {
00118 
00119 //- template specialization for pTraits<uLabel>
00120 template<>
00121 class pTraits<uLabel>
00122 {
00123     uLabel p_;
00124 
00125 public:
00126 
00127     //- Component type
00128     typedef uLabel cmptType;
00129 
00130     // Member constants
00131 
00132         enum
00133         {
00134             dim = 3,         // Dimensionality of space
00135             rank = 0,        // Rank of uLabel is 0
00136             nComponents = 1  // Number of components in uLabel is 1
00137         };
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 
00150     // Constructors
00151 
00152         //- Construct from uLabel
00153         pTraits(const uLabel ul)
00154         {
00155             p_ = ul;
00156         }
00157 
00158         //- Construct from Istream
00159         pTraits(Istream&);
00160 
00161 
00162     // Member Functions
00163 
00164         operator uLabel() const
00165         {
00166             return p_;
00167         }
00168 
00169         operator uLabel&()
00170         {
00171             return p_;
00172         }
00173 };
00174 
00175 
00176 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00177 
00178 inline uLabel& setComponent(uLabel& l, const direction)
00179 {
00180     return l;
00181 }
00182 
00183 inline uLabel component(const uLabel l, const direction)
00184 {
00185     return l;
00186 }
00187 
00188 
00189 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00190 
00191 } // End namespace Foam
00192 
00193 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
00194 
00195 #endif
00196 
00197 // ************************ vim: set sw=4 sts=4 et: ************************ //
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines