Forward compatibility: flex
[foam-extend-3.2.git] / src / foam / global / profiling / profilingPool.H
blob36a27745da23ed2fc4b980b21b83201a06084490
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::profilingPool
27 Description
28     Collects all the data for profiling
30 SourceFiles
31     profilingPool.C
33 \*---------------------------------------------------------------------------*/
35 #ifndef profilingPool_H
36 #define profilingPool_H
38 #include "regIOobject.H"
39 #include "clockTime.H"
41 #include <map>
43 #include "profilingInfo.H"
44 #include "profilingStack.H"
46 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
48 namespace Foam
51 // Forward declaration of classes
52 // class Istream;
53 class Ostream;
55 // // Forward declaration of friend functions and operators
56 // Istream& operator>>(Istream&, profilingPool&);
57 // Ostream& operator<<(Ostream&, const profilingPool&);
60 /*---------------------------------------------------------------------------*\
61                            Class profilingPool Declaration
62 \*---------------------------------------------------------------------------*/
64 class profilingPool
66     public regIOobject
68     // Private typedefs
70         typedef std::multimap<Foam::string,Foam::profilingInfo*> mapType;
71         typedef std::pair<Foam::string,Foam::profilingInfo*> mapValues;
72         typedef mapType::iterator mapIterator;
73         typedef mapType::const_iterator mapConstIterator;
76     // Private data
78         mapType allInfo_;
80         profilingStack theStack_;
82         clockTime globalTime_;
84         const Time &owner_;
86     // Private Member Functions
88         //- Disallow default bitwise copy construct
89         profilingPool(const profilingPool&);
91         //- Disallow default bitwise assignment
92         void operator=(const profilingPool&);
95     // Static data members
97         //- The only possible Pool-Object
98         static profilingPool *thePool_;
101     // Constructors
103         //- Construct null
104         profilingPool
105         (
106             const IOobject&,
107             const Time&
108         );
111     //- Destructor
112     ~profilingPool();
115     // Member functions
117         mapType& map()
118         {
119             return allInfo_;
120         }
122         const mapType& map() const
123         {
124             return allInfo_;
125         }
127         profilingStack& stack()
128         {
129             return theStack_;
130         }
132         const profilingStack& stack() const
133         {
134             return theStack_;
135         }
137         const Time& owner() const
138         {
139             return owner_;
140         }
142 protected:
144     static void initProfiling
145     (
146         const IOobject&,
147         const Time&
148     );
150     static void stopProfiling(const Time&);
152 public:
154     static profilingInfo& getInfo(const string& name);
156     static void remove(const profilingInfo& info);
158     static void rememberTimer(const profilingInfo& info, clockTime& timer);
160     virtual bool writeData(Ostream&) const;
162     friend class Time;
166 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
168 } // End namespace Foam
170 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
172 #endif
174 // ************************************************************************* //