nullObject.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) 2014-2022 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::NullObject
26 
27 Description
28  Singleton null-object class and instance
29 
30 SourceFiles
31  nullObjectI.H
32  nullObject.C
33 
34 \*---------------------------------------------------------------------------*/
35 
36 #ifndef nullObject_H
37 #define nullObject_H
38 
39 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
40 
41 namespace Foam
42 {
43 
44 /*---------------------------------------------------------------------------*\
45  Class nullObject Declaration
46 \*---------------------------------------------------------------------------*/
47 
48 class NullObject
49 {
50  //- Private constructor
51  NullObject()
52  {}
53 
54 public:
55 
56  //- The unique null object
57  static const NullObject nullObject;
58 
59  //- Disallow default bitwise copy construction
60  NullObject(const NullObject&) = delete;
61 
62  //- Disallow default bitwise assignment
63  void operator=(const NullObject&) = delete;
64 };
65 
66 
67 //- Pointer to the unique nullObject
68 extern const NullObject* nullObjectPtr;
69 
70 
71 //- Return const reference to the nullObject of type T
72 template<class T>
73 inline const T& NullObjectRef();
74 
75 //- Return const pointer to the nullObject of type T
76 template<class T>
77 inline const T* NullObjectConstPtr();
78 
79 //- Return pointer to the nullObject of type T
80 template<class T>
81 inline T* NullObjectPtr();
82 
83 //- Return reference to the nullObject of type T
84 template<class T>
85 inline T&& NullObjectMove();
86 
87 
88 //- Return true if t is a reference to the nullObject of type T
89 template<class T>
90 inline bool isNull(const T& t);
91 
92 //- Return true if t is not a reference to the nullObject of type T
93 template<class T>
94 inline bool notNull(const T& t);
95 
96 
97 //- Return true if t is a pointer to the nullObject of type T
98 template<class T>
99 inline bool isNull(const T* t);
100 
101 //- Return true if t is not a pointer to the nullObject of type T
102 template<class T>
103 inline bool notNull(const T* t);
104 
105 
106 //- Return true if t is a pointer to the nullObject of type T
107 template<class T>
108 inline bool isNull(T* t);
109 
110 //- Return true if t is not a pointer to the nullObject of type T
111 template<class T>
112 inline bool notNull(T* t);
113 
114 
115 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
116 
117 } // End namespace Foam
118 
119 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
120 
121 #include "nullObjectI.H"
122 
123 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
124 
125 #endif
126 
127 // ************************************************************************* //
Singleton null-object class and instance.
Definition: nullObject.H:48
void operator=(const NullObject &)=delete
Disallow default bitwise assignment.
static const NullObject nullObject
The unique null object.
Definition: nullObject.H:56
Namespace for OpenFOAM.
T && NullObjectMove()
Return reference to the nullObject of type T.
Definition: nullObjectI.H:33
const NullObject * nullObjectPtr
Pointer to the unique nullObject.
Definition: nullObject.C:31
bool notNull(const T &t)
Return true if t is not a reference to the nullObject of type T.
Definition: nullObjectI.H:58
T * NullObjectPtr()
Return pointer to the nullObject of type T.
Definition: nullObjectI.H:45
const T & NullObjectRef()
Return const reference to the nullObject of type T.
Definition: nullObjectI.H:27
const T * NullObjectConstPtr()
Return const pointer to the nullObject of type T.
Definition: nullObjectI.H:39
bool isNull(const T &t)
Return true if t is a reference to the nullObject of type T.
Definition: nullObjectI.H:52
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)