IOPtrList.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) 2011-2016 OpenFOAM Foundation
9  Copyright (C) 2018-2023 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::IOPtrList
29 
30 Description
31  A PtrList of objects of type <T> with automated input and output.
32 
33 SourceFiles
34  IOPtrList.C
35 
36 \*---------------------------------------------------------------------------*/
37 
38 #ifndef Foam_IOPtrList_H
39 #define Foam_IOPtrList_H
40 
41 #include "PtrList.H"
42 #include "regIOobject.H"
43 
44 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
45 
46 namespace Foam
47 {
48 
49 /*---------------------------------------------------------------------------*\
50  Class IOPtrList Declaration
51 \*---------------------------------------------------------------------------*/
52 
53 template<class T>
54 class IOPtrList
55 :
56  public regIOobject,
57  public PtrList<T>
58 {
59 public:
60 
61  //- Runtime type information
62  TypeName("PtrList");
63 
64 
65  // Constructors
66 
67  //- Default copy construct
68  IOPtrList(const IOPtrList&) = default;
69 
70  //- Construct from IOobject
71  explicit IOPtrList(const IOobject& io);
72 
73  //- Construct from IOobject using given Istream constructor class
74  template<class INew>
75  IOPtrList(const IOobject& io, const INew& inewt);
76 
77  //- Construct from IOobject with given size
78  IOPtrList(const IOobject& io, const label len);
79 
80  //- Construct from IOobject and a copy of PtrList content
81  IOPtrList(const IOobject& io, const PtrList<T>& content);
82 
83  //- Construct by transferring the PtrList content
84  IOPtrList(const IOobject& io, PtrList<T>&& content);
85 
86 
87  // Factory Methods
88 
89  //- Read and return contents. The IOobject will not be registered
90  static PtrList<T> readContents(const IOobject& io);
91 
92 
93  //- Destructor
94  virtual ~IOPtrList() = default;
95 
96 
97  // Member Functions
98 
99  bool writeData(Ostream& os) const;
100 
101 
102  // Member Operators
103 
104  //- Copy assignment of entries
105  void operator=(const IOPtrList<T>& rhs);
106 
107  //- Copy or move assignment of entries
108  using PtrList<T>::operator=;
109 };
110 
111 
112 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
113 
114 } // End namespace Foam
115 
116 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
117 
118 #ifdef NoRepository
119  #include "IOPtrList.C"
120 #endif
121 
122 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
123 
124 #endif
125 
126 // ************************************************************************* //
virtual ~IOPtrList()=default
Destructor.
void operator=(const IOPtrList< T > &rhs)
Copy assignment of entries.
Definition: IOPtrList.C:141
TypeName("PtrList")
Runtime type information.
An Ostream is an abstract base class for all output systems (streams, files, token lists...
Definition: Ostream.H:56
OBJstream os(runTime.globalPath()/outputName)
bool writeData(Ostream &os) const
Pure virtual writeData function.
Definition: IOPtrList.C:132
static PtrList< T > readContents(const IOobject &io)
Read and return contents. The IOobject will not be registered.
Definition: IOPtrList.C:115
A PtrList of objects of type <T> with automated input and output.
Definition: IOPtrList.H:49
A list of pointers to objects of type <T>, with allocation/deallocation management of the pointers...
Definition: List.H:55
A helper class when constructing from an Istream or dictionary.
Definition: INew.H:46
IOPtrList(const IOPtrList &)=default
Default copy construct.
regIOobject is an abstract class derived from IOobject to handle automatic object registration with t...
Definition: regIOobject.H:66
IOobject io("surfaceFilmProperties", mesh.time().constant(), mesh, IOobject::READ_IF_PRESENT, IOobject::NO_WRITE, IOobject::NO_REGISTER)
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:172
Namespace for OpenFOAM.