sharedRegIOobject.H
Go to the documentation of this file.
1 /*---------------------------------------------------------------------------*\
2  ========= |
3  \\ / F ield | OpenFOAM: The Open Source CFD Toolbox
4  \\ / O peration | Website: https://openfoam.org
5  \\ / A nd | Copyright (C) 2025 OpenFOAM Foundation
6  \\/ M anipulation |
7 -------------------------------------------------------------------------------
8 License
9  This file is part of OpenFOAM.
10 
11  OpenFOAM is free software: you can redistribute it and/or modify it
12  under the terms of the GNU General Public License as published by
13  the Free Software Foundation, either version 3 of the License, or
14  (at your option) any later version.
15 
16  OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
17  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18  FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
19  for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
23 
24 Class
25  Foam::sharedRegIOobject
26 
27 Description
28  Container for a pointer to a shared object, who's memory is managed by an
29  object registry. Object lifetime is managed by reference counting, which
30  limits the object types to those that inherit a reference count.
31 
32 SourceFiles
33  sharedRegIOobjectI.H
34 
35 \*---------------------------------------------------------------------------*/
36 
37 #ifndef sharedRegIOobject_H
38 #define sharedRegIOobject_H
39 
40 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
41 
42 namespace Foam
43 {
44 
45 class IOobject;
46 
47 /*---------------------------------------------------------------------------*\
48  Class sharedRegIOobject Declaration
49 \*---------------------------------------------------------------------------*/
50 
51 template<class Type>
53 {
54  // Private Data
55 
56  //- Pointer to the registered object
57  Type* ptr_;
58 
59 
60 public:
61 
62  // Constructors
63 
64  //- Default construct
65  inline sharedRegIOobject();
66 
67  //- Construct from an IO object and additional arguments
68  template<class ... Args>
69  inline sharedRegIOobject(const IOobject& io, const Args& ... args);
70 
71  //- Disallow default bitwise copy construction
73 
74 
75  //- Destructor
77 
78 
79  // Member Functions
80 
81  //- Is this object set?
82  inline bool valid() const;
83 
84  //- Set the object
85  template<class ... Args>
86  inline void set(const IOobject& io, const Args& ... args);
87 
88  //- Return a reference to the object
89  inline Type& ref() const;
90 
91  //- Clear the object
92  inline void clear();
93 
94 
95  // Member Operators
96 
97  //- Return a reference to the object
98  inline const Type& operator()() const;
99 
100  //- Disallow default bitwise assignment
101  void operator=(const sharedRegIOobject<Type>&) = delete;
102 };
103 
104 
105 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
106 
107 } // End namespace Foam
108 
109 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
110 
111 #include "sharedRegIOobjectI.H"
112 
113 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
114 
115 #endif
116 
117 // ************************************************************************* //
IOobject defines the attributes of an object for which implicit objectRegistry management is supporte...
Definition: IOobject.H:99
Container for a pointer to a shared object, who's memory is managed by an object registry....
void set(const IOobject &io, const Args &... args)
Set the object.
sharedRegIOobject()
Default construct.
void operator=(const sharedRegIOobject< Type > &)=delete
Disallow default bitwise assignment.
bool valid() const
Is this object set?
const Type & operator()() const
Return a reference to the object.
void clear()
Clear the object.
Type & ref() const
Return a reference to the object.
Namespace for OpenFOAM.
Foam::argList args(argc, argv)