curve.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 | www.openfoam.com
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8  Copyright (C) 2011 OpenFOAM Foundation
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 Class
27  Foam::curve
28 
29 Description
30  A single curve in a graph.
31 
32 SourceFiles
33  curve.C
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef Foam_curve_H
38 #define Foam_curve_H
39 
40 #include "autoPtr.H"
41 #include "point.H"
42 #include "primitiveFields.H"
43 #include "word.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 // Forward Declarations
51 class curve;
52 Ostream& operator<<(Ostream&, const curve&);
53 
54 
55 /*---------------------------------------------------------------------------*\
56  Class curve Declaration
57 \*---------------------------------------------------------------------------*/
58 
59 class curve
60 :
61  public scalarField
62 {
63 public:
64 
65  //- The style (line, symbol, etc) of a curve
66  class curveStyle
67  {
68  public:
69 
70  //- Enumeration definitions
71  enum curveStyleNo
72  {
78  };
79 
80 
81  private:
82 
83  //- Private data
84  curveStyleNo CurveStyleNo;
85 
86 
87  public:
88 
89 
90  // Constructors
91 
92  //- Construct given a curveStyleNo
93  curveStyle(const curveStyleNo csn)
94  :
95  CurveStyleNo(csn)
96  {}
97 
98  //- Construct from Istream
99  curveStyle(Istream& is)
100  :
101  CurveStyleNo(curveStyleNo(readInt(is)))
102  {}
103 
105  // Ostream operator
106 
107  friend Ostream& operator<<(Ostream& os, const curveStyle& cs)
108  {
109  os << int(cs.CurveStyleNo);
110  return os;
111  }
112  };
113 
114 
115 private:
116 
117  // Private Data
118 
119  string name_;
120 
121  curveStyle style_;
122 
123 
124 public:
125 
126  // Constructors
127 
128  //- Construct from name, style and size
129  curve
130  (
131  const string& name,
132  const curveStyle& style,
133  const label l
134  );
135 
136  //- Construct from the components
137  curve
138  (
139  const string&,
140  const curveStyle&,
141  const scalarField& y
142  );
143 
144  autoPtr<curve> clone() const
145  {
146  return autoPtr<curve>::New(*this);
147  }
148 
149 
150  // Member Functions
151 
152  // Access
154  const string& name() const
155  {
156  return name_;
157  }
158 
159  const curveStyle& style() const
160  {
161  return style_;
162  }
164 
165  // Ostream operator
166 
167  friend Ostream& operator<<(Ostream&, const curve&);
168 };
169 
170 
171 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
172 
173 } // End namespace Foam
174 
175 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
176 
177 #endif
178 
179 // ************************************************************************* //
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
int readInt(Istream &is)
Read int from stream.
Definition: intIO.C:73
scalar y
The style (line, symbol, etc) of a curve.
Definition: curve.H:63
curve(const string &name, const curveStyle &style, const label l)
Construct from name, style and size.
Definition: curve.C:27
A single curve in a graph.
Definition: curve.H:54
curveStyleNo
Enumeration definitions.
Definition: curve.H:70
friend Ostream & operator<<(Ostream &, const curve &)
curveStyle(const curveStyleNo csn)
Construct given a curveStyleNo.
Definition: curve.H:96
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
OBJstream os(runTime.globalPath()/outputName)
friend Ostream & operator<<(Ostream &os, const curveStyle &cs)
Definition: curve.H:112
Specialisations of Field<T> for scalar, vector and tensor.
Ostream & operator<<(Ostream &, const boundaryPatch &p)
Write boundaryPatch as dictionary entries (without surrounding braces)
Definition: boundaryPatch.C:77
const curveStyle & style() const
Definition: curve.H:168
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
static autoPtr< T > New(Args &&... args)
Construct autoPtr with forwarding arguments.
Definition: autoPtr.H:178
Namespace for OpenFOAM.
const string & name() const
Definition: curve.H:163
autoPtr< curve > clone() const
Definition: curve.H:153