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 unwatchedIOdictionary_H
41 #define 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
95  unwatchedIOdictionary(const IOobject& io, Istream& is);
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  }
116 
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
131  fileNameList& files() noexcept
132  {
133  return files_;
134  }
135 };
136 
137 
138 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
139 
140 //- Template function for obtaining global status
141 template<>
143 {
144  return true;
145 }
146 
147 
148 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
149 
150 } // End namespace Foam
151 
152 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
153 
154 #endif
155 
156 // ************************************************************************* //
Foam::typeGlobal< unwatchedIOdictionary >
bool typeGlobal< unwatchedIOdictionary >()
Template function for obtaining global status.
Definition: unwatchedIOdictionary.H:141
Foam::IOobject
Defines the attributes of an object for which implicit objectRegistry management is supported,...
Definition: IOobject.H:169
Foam::word
A class for handling words, derived from Foam::string.
Definition: word.H:65
Foam::fileName
A class for handling file names.
Definition: fileName.H:73
Foam::unwatchedIOdictionary::filePath
virtual fileName filePath() const
Return complete path + object name if the file exists.
Definition: unwatchedIOdictionary.H:111
Foam::unwatchedIOdictionary::addWatch
virtual void addWatch()
Add file watch on object (READ_IF_MODIFIED)
Definition: unwatchedIOdictionary.C:114
Foam::unwatchedIOdictionary::files
fileNameList & files() noexcept
Access to the files that would be watched.
Definition: unwatchedIOdictionary.H:130
Foam::unwatchedIOdictionary::unwatchedIOdictionary
unwatchedIOdictionary(const IOobject &io, const dictionary *fallback=nullptr)
Definition: unwatchedIOdictionary.C:37
baseIOdictionary.H
Foam::unwatchedIOdictionary
unwatchedIOdictionary is like IOdictionary but stores dependencies as files instead of fileMonitor wa...
Definition: unwatchedIOdictionary.H:53
Foam::Istream
An Istream is an abstract base class for all input systems (streams, files, token lists etc)....
Definition: Istream.H:61
Foam::baseIOdictionary
baseIOdictionary is derived from dictionary and IOobject to give the dictionary automatic IO function...
Definition: baseIOdictionary.H:56
Foam::unwatchedIOdictionary::~unwatchedIOdictionary
virtual ~unwatchedIOdictionary()=default
Destructor.
Foam::unwatchedIOdictionary::global
virtual bool global() const
Is object global.
Definition: unwatchedIOdictionary.H:104
dict
dictionary dict
Definition: searchingEngine.H:14
Foam::IOobject::globalFilePath
fileName globalFilePath(const word &typeName, const bool search=true) const
Helper for filePath that searches up if in parallel.
Definition: IOobject.C:580
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::List< fileName >
Foam::type
fileName::Type type(const fileName &name, const bool followLink=true)
Return the file type: DIRECTORY or FILE, normally following symbolic links.
Definition: MSwindows.C:590
Foam::unwatchedIOdictionary::files
const fileNameList & files() const noexcept
Return the files that would be watched.
Definition: unwatchedIOdictionary.H:124