writeDictionary.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) 2013-2016 OpenFOAM Foundation
9  Copyright (C) 2016-2019 OpenCFD Ltd.
10 -------------------------------------------------------------------------------
11 License
12  This file is part of OpenFOAM.
13 
14  OpenFOAM is free software: you can redistribute it and/or modify it
15  under the terms of the GNU General Public License as published by
16  the Free Software Foundation, either version 3 of the License, or
17  (at your option) any later version.
18 
19  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
21  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
22  for more details.
23 
24  You should have received a copy of the GNU General Public License
25  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
26 
27 Class
28  Foam::functionObjects::writeDictionary
29 
30 Group
31  grpUtilitiesFunctionObjects
32 
33 Description
34  Writes dictionaries on start-up and on change.
35 
36 SourceFiles
37  writeDictionary.C
38 
39 \*---------------------------------------------------------------------------*/
40 
41 #ifndef functionObjects_writeDictionary_H
42 #define functionObjects_writeDictionary_H
43 
44 #include "regionFunctionObject.H"
45 #include "wordList.H"
46 #include "SHA1Digest.H"
47 
48 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
49 
50 namespace Foam
51 {
52 namespace functionObjects
53 {
54 
55 /*---------------------------------------------------------------------------*\
56  Class writeDictionary Declaration
57 \*---------------------------------------------------------------------------*/
58 
59 class writeDictionary
60 :
62 {
63  // Private data
64 
65  //- Names of dictionaries to monitor
66  wordList dictNames_;
67 
68  //- List of changed dictionaries (only those registered to database)
69  List<SHA1Digest> digests_;
70 
71  //- Flag to indicate the first time that a dictionary is been changed
72  //- (per call to execute)
73  bool firstChange_;
74 
75 
76  // Private Member Functions
77 
78  //- Write the output header
79  void writeHeader();
80 
81  //- Helper to check and write the dictionary if its sha1 has changed
82  void checkDictionary(const dictionary& dict, const label dicti);
83 
84  //- Helper to write the dictionary if found at location
85  bool tryDirectory(const word& location, const label dicti);
86 
87  //- No copy construct
88  writeDictionary(const writeDictionary&) = delete;
89 
90  //- No copy assignment
91  void operator=(const writeDictionary&) = delete;
92 
93 
94 public:
95 
96  //- Runtime type information
97  TypeName("writeDictionary");
98 
99 
100  // Constructors
101 
102  //- Construct from Time and dictionary
104  (
105  const word& name,
106  const Time& runTime,
107  const dictionary& dict
108  );
109 
110 
111  //- Destructor
112  virtual ~writeDictionary() = default;
113 
114 
115  // Member Functions
116 
117  //- Read the writeDictionary data
118  virtual bool read(const dictionary&);
119 
120  //- Execute, currently does nothing
121  virtual bool execute();
122 
123  //- Write the selected dictionaries
124  virtual bool write();
125 };
126 
127 
128 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
129 
130 } // End namespace functionObjects
131 } // End namespace Foam
132 
133 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
134 
135 #endif
136 
137 // ************************************************************************* //
runTime
engineTime & runTime
Definition: createEngineTime.H:13
Foam::Time
Class to control time during OpenFOAM simulations that is also the top-level objectRegistry.
Definition: Time.H:73
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::functionObjects::writeDictionary
Writes dictionaries on start-up and on change.
Definition: writeDictionary.H:58
Foam::functionObjects::writeDictionary::execute
virtual bool execute()
Execute, currently does nothing.
Definition: writeDictionary.C:164
Foam::functionObjects::writeDictionary::write
virtual bool write()
Write the selected dictionaries.
Definition: writeDictionary.C:170
Foam::functionObjects::writeDictionary::read
virtual bool read(const dictionary &)
Read the writeDictionary data.
Definition: writeDictionary.C:136
wordList.H
SHA1Digest.H
regionFunctionObject.H
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::dictionary
A list of keyword definitions, which are a keyword followed by a number of values (eg,...
Definition: dictionary.H:123
Foam
Namespace for OpenFOAM.
Definition: atmBoundaryLayer.C:33
Foam::functionObjects::writeDictionary::~writeDictionary
virtual ~writeDictionary()=default
Destructor.
Foam::functionObject::name
const word & name() const noexcept
Return the name of this functionObject.
Definition: functionObject.C:143
Foam::List< word >
Foam::functionObjects::regionFunctionObject
Specialization of Foam::functionObject for a region and providing a reference to the region Foam::obj...
Definition: regionFunctionObject.H:90
Foam::functionObjects::writeDictionary::TypeName
TypeName("writeDictionary")
Runtime type information.