regIOobjectI.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-2015 OpenFOAM Foundation
9  Copyright (C) 2018-2019 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 \*---------------------------------------------------------------------------*/
28 
29 // * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
30 
32 {
33  return ownedByRegistry_;
34 }
35 
36 
38 {
39  ownedByRegistry_ = true;
40 }
41 
42 
43 template<class Type>
44 inline Type& Foam::regIOobject::store(Type* p)
45 {
46  if (!p)
47  {
49  << "Object deallocated\n"
50  << abort(FatalError);
51  }
52 
53  p->regIOobject::ownedByRegistry_ = true;
54 
55  return *p;
56 }
57 
58 
59 template<class Type>
61 {
62  return store(aptr.ptr()); // release, pass management to regIOobject
63 }
64 
65 
66 template<class Type>
68 {
69  return store(aptr.ptr()); // release, pass management to regIOobject
70 }
71 
72 
73 inline void Foam::regIOobject::release(const bool unregister)
74 {
75  ownedByRegistry_ = false;
76  if (unregister)
77  {
78  registered_ = false;
79  }
80 }
81 
82 
84 {
85  return eventNo_;
86 }
87 
89 {
90  return eventNo_;
91 }
92 
93 
95 {
96  return watchIndices_;
97 }
98 
99 
101 {
102  return watchIndices_;
103 }
104 
105 
106 // ************************************************************************* //
p
volScalarField & p
Definition: createFieldRefs.H:8
Foam::regIOobject::release
void release(const bool unregister=false)
Release ownership of this object from its registry.
Definition: regIOobjectI.H:73
Foam::regIOobject::watchIndices
const labelList & watchIndices() const
Return file-monitoring handles.
Definition: regIOobjectI.H:94
Foam::regIOobject::eventNo
label eventNo() const
Event number at last update.
Definition: regIOobjectI.H:83
Foam::label
intWM_LABEL_SIZE_t label
A label is an int32_t or int64_t as specified by the pre-processor macro WM_LABEL_SIZE.
Definition: label.H:62
Foam::autoPtr::ptr
T * ptr() noexcept
Definition: autoPtrI.H:144
Foam::FatalError
error FatalError
Foam::regIOobject::ownedByRegistry
bool ownedByRegistry() const
Is this object owned by the registry?
Definition: regIOobjectI.H:31
Foam::abort
errorManip< error > abort(error &err)
Definition: errorManip.H:137
Foam::autoPtr
Pointer management similar to std::unique_ptr, with some additional methods and type checking.
Definition: HashPtrTable.H:53
Foam::regIOobject::store
void store()
Transfer ownership of this object to its registry.
Definition: regIOobjectI.H:37
FatalErrorInFunction
#define FatalErrorInFunction
Report an error message using Foam::FatalError.
Definition: error.H:355
Foam::List< label >