unwatchedIOdictionary.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) 2015-2017 OpenFOAM Foundation
9  Copyright (C) 2021 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::unwatchedIOdictionary
29 
30 Description
31  unwatchedIOdictionary is like IOdictionary but stores
32  dependencies as files instead of fileMonitor watchIndices.
33  Used to read controlDict since there fileMonitor not yet setup.
34 
35 SourceFiles
36  unwatchedIOdictionary.C
37 
38 \*---------------------------------------------------------------------------*/
39 
40 #ifndef Foam_unwatchedIOdictionary_H
41 #define Foam_unwatchedIOdictionary_H
42 
43 #include "baseIOdictionary.H"
44 
45 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
46 
47 namespace Foam
48 {
49 
50 /*---------------------------------------------------------------------------*\
51  Class unwatchedIOdictionary Declaration
52 \*---------------------------------------------------------------------------*/
53 
55 :
56  public baseIOdictionary
57 {
58  // Private Data
59 
60  //- The files that would be watched
61  fileNameList files_;
62 
63 
64 public:
65 
66  // Constructors
67 
68  //- Construct given an IOobject
69  //- and optional fallback dictionary content
70  // A null dictionary pointer is treated like an empty dictionary.
71  explicit unwatchedIOdictionary
72  (
73  const IOobject& io,
74  const dictionary* fallback = nullptr
75  );
76 
77  //- Construct given an IOobject and fallback dictionary content
79  (
80  const IOobject& io,
81  const dictionary& dict
82  );
83 
84  //- Construct given an IOobject, wanted typeName
85  //- and optional fallback dictionary content
86  // A null dictionary pointer is treated like an empty dictionary.
88  (
89  const IOobject& io,
90  const word& wantedType,
91  const dictionary* fallback = nullptr
92  );
93 
94  //- Construct given an IOobject and Istream
96 
97 
98  //- Destructor
99  virtual ~unwatchedIOdictionary() = default;
100 
101 
102  // Member Functions
103 
104  //- Is object global
105  virtual bool global() const
106  {
107  return true;
108  }
109 
110  //- Return complete path + object name if the file exists
111  // either in the case/processor or case otherwise null
112  virtual fileName filePath() const
113  {
114  return globalFilePath(type());
115  }
117  //- Add file watch on object (READ_IF_MODIFIED)
118  virtual void addWatch();
119 
120  //- Add file watch for fileName on object if not yet watched.
121  // \return index of watch
122  virtual label addWatch(const fileName&);
123 
124  //- Return the files that would be watched
125  const fileNameList& files() const noexcept
126  {
127  return files_;
128  }
129 
130  //- Access to the files that would be watched
132  {
133  return files_;
134  }
135 };
136 
137 
138 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
139 
140 //- Global file type for unwatchedIOdictionary
141 template<>
142 struct is_globalIOobject<unwatchedIOdictionary> : std::true_type {};
143 
144 
145 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
147 } // End namespace Foam
148 
149 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
150 
151 #endif
152 
153 // ************************************************************************* //
dictionary dict
unwatchedIOdictionary is like IOdictionary but stores dependencies as files instead of fileMonitor wa...
A class for handling file names.
Definition: fileName.H:72
baseIOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO function...
fileName globalFilePath(const word &typeName, const bool search=true) const
Redirect to fileHandler filePath, searching up if in parallel.
Definition: IOobject.C:547
A list of keyword definitions, which are a keyword followed by a number of values (eg...
Definition: dictionary.H:129
An Istream is an abstract base class for all input systems (streams, files, token lists etc)...
Definition: Istream.H:57
virtual bool global() const
Is object global.
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: POSIX.C:799
A class for handling words, derived from Foam::string.
Definition: word.H:63
virtual void addWatch()
Add file watch on object (READ_IF_MODIFIED)
const fileNameList & files() const noexcept
Return the files that would be watched.
const direction noexcept
Definition: Scalar.H:258
virtual ~unwatchedIOdictionary()=default
Destructor.
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
virtual fileName filePath() const
Return complete path + object name if the file exists.
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:172
Namespace for OpenFOAM.
unwatchedIOdictionary(const IOobject &io, const dictionary *fallback=nullptr)
Construct given an IOobject and optional fallback dictionary content.