instant.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration |
5  \\ / A nd | Copyright (C) 2011-2013 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
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
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
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.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::instant
26 
27 Description
28  An instant of time. Contains the time value and name.
29 
30 SourceFiles
31  instant.C
32 
33 \*---------------------------------------------------------------------------*/
34 
35 #ifndef instant_H
36 #define instant_H
37 
38 #include "word.H"
39 #include "scalar.H"
40 
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
42 
43 namespace Foam
44 {
45 
46 // Forward declaration of friend functions and operators
47 
48 class instant;
49 
50 // Friend Operators
51 
52 bool operator==(const instant&, const instant&);
53 bool operator!=(const instant&, const instant&);
54 
55 // IOstream Operators
56 
57 Istream& operator>>(Istream&, instant&);
58 Ostream& operator<<(Ostream&, const instant&);
59 
60 
61 /*---------------------------------------------------------------------------*\
62  Class instant Declaration
63 \*---------------------------------------------------------------------------*/
64 
65 class instant
66 {
67  // Private data
68 
69  scalar value_;
70  word name_;
71 
72 public:
73 
74  // Public classes
75 
76  //- Less function class used in sorting instants
77  class less
78  {
79  public:
80 
81  bool operator()(const instant& a, const instant& b) const
82  {
83  return a.value() < b.value();
84  }
85  };
86 
87 
88  // Static data members
89 
90  static const char* const typeName;
91 
92 
93  // Constructors
94 
95  //- Construct null
96  instant();
97 
98  //- Construct from components
99  instant(const scalar, const word&);
100 
101  //- Construct from time value
102  explicit instant(const scalar);
103 
104  //- Construct from word
105  explicit instant(const word&);
106 
107 
108  // Member Functions
109 
110  // Access
111 
112  //- Value (const access)
113  scalar value() const
114  {
115  return value_;
116  }
117 
118  //- Value (non-const access)
119  scalar& value()
120  {
121  return value_;
122  }
123 
124  //- Name (const access)
125  const word& name() const
126  {
127  return name_;
128  }
129 
130  //- Name (non-const access)
131  word& name()
132  {
133  return name_;
134  }
135 
136  //- Comparison used for instants to be equal
137  bool equal(const scalar) const;
138 
139 
140  // Friend Operators
141 
142  friend bool operator==(const instant&, const instant&);
143  friend bool operator!=(const instant&, const instant&);
144 
145 
146  // IOstream Operators
147 
148  friend Istream& operator>>(Istream&, instant&);
149  friend Ostream& operator<<(Ostream&, const instant&);
150 };
151 
152 
153 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
154 
155 } // End namespace Foam
156 
157 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
158 
159 #endif
160 
161 // ************************************************************************* //
friend Ostream & operator<<(Ostream &, const instant &)
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
bool operator()(const instant &a, const instant &b) const
Definition: instant.H:80
const dimensionedScalar b
Wien displacement law constant: default SI units: [m.K].
Definition: createFields.H:28
friend bool operator!=(const instant &, const instant &)
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
A class for handling words, derived from string.
Definition: word.H:59
Ostream & operator<<(Ostream &, const edgeMesh &)
Definition: edgeMeshIO.C:133
Namespace for OpenFOAM.
scalar value() const
Value (const access)
Definition: instant.H:112
bool equal(const scalar) const
Comparison used for instants to be equal.
Definition: instant.C:59
bool operator!=(const particle &, const particle &)
Definition: particle.C:147
Less function class used in sorting instants.
Definition: instant.H:76
An instant of time. Contains the time value and name.
Definition: instant.H:64
friend Istream & operator>>(Istream &, instant &)
friend bool operator==(const instant &, const instant &)
static const char *const typeName
Definition: instant.H:89
instant()
Construct null.
Definition: instant.C:35
Istream & operator>>(Istream &, edgeMesh &)
Definition: edgeMeshIO.C:144
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:53
const word & name() const
Name (const access)
Definition: instant.H:124