nullObject.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 | Copyright (C) 2014 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  //- Prevent copy-construction
55  NullObject(const NullObject&);
56 
57  //- Prevent assignment
58  NullObject& operator=(const NullObject&);
59 
60 public:
61 
62  //- The unique null object
63  static const NullObject nullObject;
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 
80 //- Return true if t is a reference to the nullObject of type T
81 template <class T>
82 inline bool isNull(const T& t);
83 
84 //- Return true if t is not a reference to the nullObject of type T
85 template <class T>
86 inline bool notNull(const T& t);
87 
88 
89 //- Return true if t is a pointer to the nullObject of type T
90 template <class T>
91 inline bool isNull(const T* t);
92 
93 //- Return true if t is not a pointer to the nullObject of type T
94 template <class T>
95 inline bool notNull(const T* t);
96 
97 
98 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
99 
100 } // End namespace Foam
101 
102 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
103 
104 #include "nullObjectI.H"
105 
106 // * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
107 
108 #endif
109 
110 // ************************************************************************* //
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:46
Namespace for OpenFOAM.
const T & NullObjectRef()
Return reference to the nullObject of type T.
Definition: nullObjectI.H:27
static const NullObject nullObject
The unique null object.
Definition: nullObject.H:62
const T * NullObjectPtr()
Return pointer to the nullObject of type T.
Definition: nullObjectI.H:33
const NullObject * nullObjectPtr
Pointer to the unique nullObject.
Definition: nullObject.C:31
bool isNull(const T &t)
Return true if t is a reference to the nullObject of type T.
Definition: nullObjectI.H:40