Forward compatibility: flex
[foam-extend-3.2.git] / src / foam / global / profiling / profilingInfo.H
blob858c5086bad4bfa7e63c7da66491f2edcd45853b
1 /*---------------------------------------------------------------------------*\
2   =========                 |
3   \\      /  F ield         | foam-extend: Open Source CFD
4    \\    /   O peration     | Version:     3.2
5     \\  /    A nd           | Web:         http://www.foam-extend.org
6      \\/     M anipulation  | For copyright notice see file Copyright
7 -------------------------------------------------------------------------------
8 License
9     This file is part of foam-extend.
11     foam-extend is free software: you can redistribute it and/or modify it
12     under the terms of the GNU General Public License as published by the
13     Free Software Foundation, either version 3 of the License, or (at your
14     option) any later version.
16     foam-extend is distributed in the hope that it will be useful, but
17     WITHOUT ANY WARRANTY; without even the implied warranty of
18     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19     General Public License for more details.
21     You should have received a copy of the GNU General Public License
22     along with foam-extend.  If not, see <http://www.gnu.org/licenses/>.
24 Class
25     Foam::profilingInfo
27 Description
28     Information needed for profiling
30 SourceFiles
31     profilingInfo.C
33 \*---------------------------------------------------------------------------*/
35 #ifndef profilingInfo_H
36 #define profilingInfo_H
38 #include "label.H"
39 #include "scalar.H"
41 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
43 namespace Foam
46 // Forward declaration of classes
48 // class Istream;
49 class Ostream;
50 class profilingStack;
51 class profilingPool;
52 class profilingInfo;
54 Ostream& operator<<(Ostream&, const profilingInfo&);
56 /*---------------------------------------------------------------------------*\
57                            Class profilingInfo Declaration
58 \*---------------------------------------------------------------------------*/
60 class profilingInfo
62     // Private data
64     // nr of times this was called
65     label calls_;
67     // total time spent
68     scalar totalTime_;
70     // time spent in children
71     scalar childTime_;
73     // unique id to identify it
74     label id_;
76     // pointer to the parent object (if there is any)
77     profilingInfo &parent_;
79     // what this does
80     string description_;
82     // is this currently on the stack?
83     bool onStack_;
85     // Private Member Functions
87     //- Disallow default bitwise copy construct
88     profilingInfo(const profilingInfo&);
90     //- Disallow default bitwise assignment
91     void operator=(const profilingInfo&);
93     // Static data members
95     //- Counter that is used to generate the ids
96     static label nextId_;
98     //- get a new ID and update the counter
99     static label getID();
101     //- raise the next possible ID (to avoid ID-clashes during reading)
102     void raiseID(label maxVal);
104 protected:
106     void addedToStack()
107         { onStack_=true; }
109     void removedFromStack()
110         { onStack_=false; }
112     //- Construct null - only the master-element
113     profilingInfo();
115     void writeWithOffset(Ostream &os,bool offset=false,scalar time=0,scalar childTime=0) const;
117 public:
119     // Constructors
121     //- Construct from components
122     profilingInfo(profilingInfo &parent,const string &descr);
124 //     //- Construct from Istream
125 //     profilingInfo(Istream&);
127     // Destructor
129     ~profilingInfo();
132     // Member Functions
134     // Access
136     label id() const
137         { return id_; }
139     label calls() const
140         { return calls_; }
142     scalar totalTime() const
143         { return totalTime_; }
145     scalar childTime() const
146         { return childTime_; }
148     bool onStack() const
149         { return onStack_; }
151     const string &description() const
152         { return description_; }
154     const profilingInfo &parent() const
155         { return parent_; }
157     //- Update it with a new timing information
158     void update(scalar elapsedTime);
160     friend class profilingStack;
161     friend class profilingPool;
163     // IOstream Operators
165     //        friend Istream& operator>>(Istream&, profilingInfo&);
166     friend Ostream& operator<<(Ostream&, const profilingInfo&);
170 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
172 } // End namespace Foam
174 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
176 #endif
178 // ************************************************************************* //