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 or move assignment of entries
105  using PtrList<T>::operator=;
106 
107  //- Copy assignment of entries
108  void operator=(const IOPtrList<T>& rhs)
109  {
111  }
112 
113  //- Move assignment of entries
114  void operator=(IOPtrList<T>&& rhs)
115  {
116  PtrList<T>::operator=(std::move(static_cast<PtrList<T>&>(rhs)));
117  }
118 };
119 
120 
121 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
122 
123 } // End namespace Foam
124 
125 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
126 
127 #ifdef NoRepository
128  #include "IOPtrList.C"
129 #endif
130 
131 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
132 
133 #endif
134 
135 // ************************************************************************* //
virtual ~IOPtrList()=default
Destructor.
void operator=(const IOPtrList< T > &rhs)
Copy assignment of entries.
Definition: IOPtrList.H:125
void rhs(fvMatrix< typename Expr::value_type > &m, const Expr &expression)
void operator=(const UPtrList< T > &list)
Copy assignment.
Definition: PtrListI.H:304
const auto & io
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:133
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: PtrList.H:56
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:68
Defines the attributes of an object for which implicit objectRegistry management is supported...
Definition: IOobject.H:188
Namespace for OpenFOAM.