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-2019 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 reference to the nullObject of type T
72 template<class T>
73 inline const T& NullObjectRef();
74 
75 //- Return pointer to the nullObject of type T
76 template<class T>
77 inline const T* NullObjectPtr();
78 
79 //- Return reference to the nullObject of type T
80 template<class T>
81 inline T&& NullObjectMove();
82 
83 
84 //- Return true if t is a reference to the nullObject of type T
85 template<class T>
86 inline bool isNull(const T& t);
87 
88 //- Return true if t is not a reference to the nullObject of type T
89 template<class T>
90 inline bool notNull(const T& t);
91 
92 
93 //- Return true if t is a pointer to the nullObject of type T
94 template<class T>
95 inline bool isNull(const T* t);
96 
97 //- Return true if t is not a pointer to the nullObject of type T
98 template<class T>
99 inline bool notNull(const T* t);
100 
101 
102 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
103 
104 } // End namespace Foam
105 
106 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
107 
108 #include "nullObjectI.H"
109 
110 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
111 
112 #endif
113 
114 // ************************************************************************* //
T && NullObjectMove()
Return reference to the nullObject of type T.
Definition: nullObjectI.H:33
void operator=(const NullObject &)=delete
Disallow default bitwise assignment.
bool isNull(const T &t)
Return true if t is a reference to the nullObject of type T.
Definition: nullObjectI.H:46
const T * NullObjectPtr()
Return pointer to the nullObject of type T.
Definition: nullObjectI.H:39
static const NullObject nullObject
The unique null object.
Definition: nullObject.H:56
const NullObject * nullObjectPtr
Pointer to the unique nullObject.
Definition: nullObject.C:31
void T(FieldField< Field, Type > &f1, const FieldField< Field, Type > &f2)
bool notNull(const T &t)
Return true if t is not a reference to the nullObject of type T.
Definition: nullObjectI.H:52
Singleton null-object class and instance.
Definition: nullObject.H:47
const T & NullObjectRef()
Return reference to the nullObject of type T.
Definition: nullObjectI.H:27
Namespace for OpenFOAM.