IOobjectListI.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) 2022-2023 OpenCFD Ltd.
9 -------------------------------------------------------------------------------
10 License
11  This file is part of OpenFOAM.
12 
13  OpenFOAM is free software: you can redistribute it and/or modify it
14  under the terms of the GNU General Public License as published by
15  the Free Software Foundation, either version 3 of the License, or
16  (at your option) any later version.
17 
18  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
19  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21  for more details.
22 
23  You should have received a copy of the GNU General Public License
24  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
25 
26 \*---------------------------------------------------------------------------*/
27 
28 // * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
29 
31 :
33 {}
34 
35 
36 inline Foam::IOobjectList::IOobjectList(const label initialCapacity)
37 :
38  HashPtrTable<IOobject>(initialCapacity)
39 {}
40 
41 
43 :
44  HashPtrTable<IOobject>(list)
45 {}
46 
47 
49 :
50  HashPtrTable<IOobject>(std::move(list))
51 {}
52 
53 
55 (
56  const objectRegistry& db,
57  const fileName& instance,
58  IOobjectOption ioOpt
59 )
60 :
61  IOobjectList(db, instance, fileName::null, ioOpt)
62 {}
63 
64 
66 (
67  const objectRegistry& db,
68  const fileName& instance,
69  IOobjectOption::registerOption registerObject
70 )
71 :
73  (
74  db,
75  instance,
76  fileName::null,
78  (
79  IOobjectOption::MUST_READ,
80  IOobjectOption::NO_WRITE,
81  registerObject
82  )
83  )
84 {}
85 
86 
88 (
89  const objectRegistry& db,
90  const fileName& instance,
91  const fileName& local,
92  IOobjectOption::registerOption registerObject
93 )
94 :
96  (
97  db,
98  instance,
99  local,
101  (
102  IOobjectOption::MUST_READ,
103  IOobjectOption::NO_WRITE,
104  registerObject
105  )
106  )
107 {}
108 
109 
110 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
111 
112 inline bool Foam::IOobjectList::add(autoPtr<IOobject>& objectPtr)
113 {
114  if (objectPtr)
115  {
116  return insert(objectPtr->name(), std::move(objectPtr));
117  }
118 
119  return false;
120 }
121 
122 
123 inline bool Foam::IOobjectList::add(autoPtr<IOobject>&& objectPtr)
124 {
125  if (objectPtr)
126  {
127  return insert(objectPtr->name(), std::move(objectPtr));
128  }
130  return false;
131 }
132 
133 
134 // * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
135 
137 {
138  transfer(list);
139 }
140 
141 
142 // ************************************************************************* //
A class for handling file names.
Definition: fileName.H:72
List of IOobjects with searching and retrieving facilities. Implemented as a HashTable, so the various sorted methods should be used if traversing in parallel.
Definition: IOobjectList.H:55
const word & name() const noexcept
Return the object name.
Definition: IOobjectI.H:195
srcOptions insert("case", fileName(rootDirSource/caseDirSource))
bool add(autoPtr< IOobject > &objectPtr)
Move insert IOobject into the list.
bool local
Definition: EEqn.H:20
const direction noexcept
Definition: Scalar.H:258
registerOption
Enumeration for use with registerObject(). Values map to bool (false/true)
A simple container of IOobject preferences. Can also be used for general handling of read/no-read/rea...
void operator=(const IOobjectList &)=delete
No copy assignment.
A class representing the concept of 0 (zero) that can be used to avoid manipulating objects known to ...
Definition: zero.H:57
Pointer management similar to std::unique_ptr, with some additional methods and type checking...
Definition: HashPtrTable.H:48
IOobjectList() noexcept=default
Default construct: empty without allocation (capacity=0).
Registry of regIOobjects.
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:172