instant.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2011-2019 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 bool operator<(const instant&, const instant&);
55 bool operator>(const instant&, const instant&);
56 
57 // IOstream Operators
58 
59 Istream& operator>>(Istream&, instant&);
60 Ostream& operator<<(Ostream&, const instant&);
61 
62 
63 /*---------------------------------------------------------------------------*\
64  Class instant Declaration
65 \*---------------------------------------------------------------------------*/
66 
67 class instant
68 {
69  // Private Data
70 
71  scalar value_;
72  word name_;
73 
74 public:
75 
76  // Public classes
77 
78  //- Less function class used in sorting instants
79  class less
80  {
81  public:
82 
83  bool operator()(const instant& a, const instant& b) const
84  {
85  return a.value() < b.value();
86  }
87  };
88 
89 
90  // Static Data Members
91 
92  static const char* const typeName;
93 
94 
95  // Constructors
96 
97  //- Construct null
98  instant();
99 
100  //- Construct from components
101  instant(const scalar, const word&);
102 
103  //- Construct from time value
104  explicit instant(const scalar);
105 
106  //- Construct from word
107  explicit instant(const word&);
108 
109 
110  // Member Functions
111 
112  // Access
113 
114  //- Value (const access)
115  scalar value() const
116  {
117  return value_;
118  }
119 
120  //- Value (non-const access)
121  scalar& value()
122  {
123  return value_;
124  }
125 
126  //- Name (const access)
127  const word& name() const
128  {
129  return name_;
130  }
131 
132  //- Name (non-const access)
133  word& name()
134  {
135  return name_;
136  }
137 
138  //- Comparison used for instants to be equal
139  bool equal(const scalar) const;
140 
141 
142  // Friend Operators
143 
144  friend bool operator==(const instant&, const instant&);
145  friend bool operator!=(const instant&, const instant&);
146  friend bool operator<(const instant&, const instant&);
147  friend bool operator>(const instant&, const instant&);
148 
149 
150  // IOstream Operators
151 
152  friend Istream& operator>>(Istream&, instant&);
153  friend Ostream& operator<<(Ostream&, const instant&);
154 };
155 
156 
157 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
158 
159 } // End namespace Foam
160 
161 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
162 
163 #endif
164 
165 // ************************************************************************* //
const word & name() const
Name (const access)
Definition: instant.H:126
Less function class used in sorting instants.
Definition: instant.H:78
bool operator<(const instant &, const instant &)
Definition: instant.C:79
friend Istream & operator>>(Istream &, instant &)
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
const dimensionedScalar b
Wien displacement law constant: default SI units: [m K].
Definition: createFields.H:27
bool operator()(const instant &a, const instant &b) const
Definition: instant.H:82
friend bool operator<(const instant &, const instant &)
friend Ostream & operator<<(Ostream &, const instant &)
tmp< fvMatrix< Type > > operator==(const fvMatrix< Type > &, const fvMatrix< Type > &)
A class for handling words, derived from string.
Definition: word.H:59
instant()
Construct null.
Definition: instant.C:35
Istream & operator>>(Istream &, directionInfo &)
friend bool operator>(const instant &, const instant &)
static const char *const typeName
Definition: instant.H:91
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:54
bool operator>(const instant &, const instant &)
Definition: instant.C:85
scalar value() const
Value (const access)
Definition: instant.H:114
An instant of time. Contains the time value and name.
Definition: instant.H:66
Ostream & operator<<(Ostream &, const ensightPart &)
friend bool operator!=(const instant &, const instant &)
friend bool operator==(const instant &, const instant &)
bool operator!=(const particle &, const particle &)
Definition: particle.C:1205
bool equal(const scalar) const
Comparison used for instants to be equal.
Definition: instant.C:59
Namespace for OpenFOAM.