mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
STYLE: reduce some file clutter for zero/one/nullObject
- more consistent location for oneField, oneFieldField inline definitions - eliminate nullObjectI.H for more transparency
This commit is contained in:
committed by
Andrew Heather
parent
ba8f237b21
commit
bd9992d0d5
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd |
|
||||
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
@ -47,26 +47,27 @@ namespace Foam
|
||||
{
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class oneField Declaration
|
||||
Class oneFieldField Declaration
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
class oneFieldField
|
||||
:
|
||||
public one
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
oneFieldField()
|
||||
{}
|
||||
oneFieldField() = default;
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
inline oneField operator[](const label) const;
|
||||
inline oneField operator[](const label) const
|
||||
{
|
||||
return oneField();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -74,10 +75,6 @@ public:
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "oneFieldFieldI.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
@ -1,38 +1 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd |
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
| Copyright (C) 2011 OpenFOAM Foundation
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "oneFieldField.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::oneField Foam::oneFieldField::operator[](const label) const
|
||||
{
|
||||
return oneField();
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
#warning File removed - left for old dependency check only
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd |
|
||||
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
@ -54,7 +54,6 @@ class oneField
|
||||
:
|
||||
public one
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
// Public typedefs
|
||||
@ -65,23 +64,23 @@ public:
|
||||
// Constructors
|
||||
|
||||
//- Construct null
|
||||
oneField()
|
||||
{}
|
||||
oneField() = default;
|
||||
|
||||
|
||||
// Member Operators
|
||||
|
||||
inline one operator[](const label) const;
|
||||
inline one operator[](const label) const
|
||||
{
|
||||
return one();
|
||||
}
|
||||
|
||||
inline oneField field() const;
|
||||
inline oneField field() const
|
||||
{
|
||||
return oneField();
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
inline const oneField& operator*(const oneField&, const oneField&);
|
||||
|
||||
inline const oneField& operator/(const oneField&, const oneField&);
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd |
|
||||
\\ / A nd | Copyright (C) 2019 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
@ -25,40 +25,25 @@ License
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "oneField.H"
|
||||
// * * * * * * * * * * * * * * * Global Functions * * * * * * * * * * * * * //
|
||||
|
||||
namespace Foam
|
||||
{
|
||||
|
||||
inline const oneField& operator*(const oneField& of, const oneField&)
|
||||
{
|
||||
return of;
|
||||
}
|
||||
|
||||
|
||||
inline const oneField& operator/(const oneField& of, const oneField&)
|
||||
{
|
||||
return of;
|
||||
}
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
inline Foam::one Foam::oneField::operator[](const label) const
|
||||
{
|
||||
return one();
|
||||
}
|
||||
|
||||
|
||||
inline Foam::oneField Foam::oneField::field() const
|
||||
{
|
||||
return oneField();
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::oneField& Foam::operator*
|
||||
(
|
||||
const oneField& of,
|
||||
const oneField&
|
||||
)
|
||||
{
|
||||
return of;
|
||||
}
|
||||
|
||||
|
||||
inline const Foam::oneField& Foam::operator/
|
||||
(
|
||||
const oneField& of,
|
||||
const oneField&
|
||||
)
|
||||
{
|
||||
return of;
|
||||
}
|
||||
} // End namespace Foam
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -31,11 +31,9 @@ Description
|
||||
|
||||
Its contents occupy enough space to also be reinterpreted
|
||||
as another class with a null pointer or zero long for its first
|
||||
member. There is an additional zero second parameter for safe
|
||||
casting to List etc.
|
||||
member, with additional zero parameters for safe casting to List etc.
|
||||
|
||||
SourceFiles
|
||||
nullObjectI.H
|
||||
nullObject.C
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
@ -137,50 +135,74 @@ public:
|
||||
};
|
||||
|
||||
|
||||
// IOstream Operators
|
||||
|
||||
//- Read from Istream consumes no content.
|
||||
inline Istream& operator>>(Istream& is, NullObject&)
|
||||
{
|
||||
return is;
|
||||
}
|
||||
|
||||
//- Write to Ostream emits no content.
|
||||
inline Ostream& operator<<(Ostream& os, const NullObject&)
|
||||
{
|
||||
return os;
|
||||
}
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// Globals
|
||||
|
||||
//- Pointer to the unique nullObject
|
||||
extern const NullObject* nullObjectPtr;
|
||||
|
||||
|
||||
//- Reference to the nullObject of type T
|
||||
// IOstream Operators
|
||||
|
||||
//- Read from Istream consumes no content.
|
||||
inline Istream& operator>>(Istream& is, NullObject&) noexcept
|
||||
{
|
||||
return is;
|
||||
}
|
||||
|
||||
//- Write to Ostream emits no content.
|
||||
inline Ostream& operator<<(Ostream& os, const NullObject&) noexcept
|
||||
{
|
||||
return os;
|
||||
}
|
||||
|
||||
|
||||
// Global Functions
|
||||
|
||||
//- Pointer (of type T) to the nullObject
|
||||
template<class T>
|
||||
inline const T& NullObjectRef();
|
||||
inline const T* NullObjectPtr()
|
||||
{
|
||||
return reinterpret_cast<const T*>(nullObjectPtr);
|
||||
}
|
||||
|
||||
//- Pointer to the nullObject of type T
|
||||
//- Reference (of type T) to the nullObject
|
||||
template<class T>
|
||||
inline const T* NullObjectPtr();
|
||||
inline const T& NullObjectRef()
|
||||
{
|
||||
return *reinterpret_cast<const T*>(nullObjectPtr);
|
||||
}
|
||||
|
||||
|
||||
//- True if t is a reference to the nullObject of type T
|
||||
//- True if ptr is a pointer (of type T) to the nullObject
|
||||
template<class T>
|
||||
inline bool isNull(const T& t);
|
||||
inline bool isNull(const T* ptr)
|
||||
{
|
||||
return ptr == NullObjectPtr<T>();
|
||||
}
|
||||
|
||||
//- True if t is not a reference to the nullObject of type T
|
||||
//- True if obj is a reference (of type T) to the nullObject
|
||||
template<class T>
|
||||
inline bool notNull(const T& t);
|
||||
inline bool isNull(const T& obj)
|
||||
{
|
||||
return &obj == NullObjectPtr<T>();
|
||||
}
|
||||
|
||||
|
||||
//- True if t is a pointer to the nullObject of type T
|
||||
//- True if ptr is not a pointer (of type T) to the nullObject
|
||||
template<class T>
|
||||
inline bool isNull(const T* t);
|
||||
inline bool notNull(const T* ptr)
|
||||
{
|
||||
return ptr != NullObjectPtr<T>();
|
||||
}
|
||||
|
||||
//- True if t is not a pointer to the nullObject of type T
|
||||
//- True if obj is not a reference (of type T) to the nullObject
|
||||
template<class T>
|
||||
inline bool notNull(const T* t);
|
||||
inline bool notNull(const T& obj)
|
||||
{
|
||||
return &obj != NullObjectPtr<T>();
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
@ -189,10 +211,6 @@ inline bool notNull(const T* t);
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#include "nullObjectI.H"
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
#endif
|
||||
|
||||
// ************************************************************************* //
|
||||
|
||||
@ -1,67 +1 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd |
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
| Copyright (C) 2014-2016 OpenFOAM Foundation
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
template<class T>
|
||||
inline const T& Foam::NullObjectRef()
|
||||
{
|
||||
return *reinterpret_cast<const T*>(nullObjectPtr);
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline const T* Foam::NullObjectPtr()
|
||||
{
|
||||
return reinterpret_cast<const T*>(nullObjectPtr);
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::isNull(const T& t)
|
||||
{
|
||||
return &t == NullObjectPtr<T>();
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::notNull(const T& t)
|
||||
{
|
||||
return &t != NullObjectPtr<T>();
|
||||
}
|
||||
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::isNull(const T* t)
|
||||
{
|
||||
return t == NullObjectPtr<T>();
|
||||
}
|
||||
|
||||
template<class T>
|
||||
inline bool Foam::notNull(const T* t)
|
||||
{
|
||||
return t != NullObjectPtr<T>();
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
#warning File removed - left for old dependency check only
|
||||
|
||||
@ -28,11 +28,14 @@ Class
|
||||
|
||||
Description
|
||||
A class representing the concept of 1 (one), which can be used to avoid
|
||||
manipulating objects that are known to be 'one' at compile-time.
|
||||
manipulating objects that are known to be \em one at compile-time.
|
||||
|
||||
SourceFiles
|
||||
oneI.H
|
||||
|
||||
SeeAlso
|
||||
Foam::zero
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef one_H
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2017-2018 OpenCFD Ltd.
|
||||
\\ / A nd | Copyright (C) 2017-2019 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
| Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
@ -28,12 +28,15 @@ Class
|
||||
|
||||
Description
|
||||
A class representing the concept of 0 (zero), which can be used to avoid
|
||||
manipulating objects that are known to be 'zero' at compile-time.
|
||||
manipulating objects that are known to be \em zero at compile-time.
|
||||
|
||||
SourceFiles
|
||||
zero.C
|
||||
zeroI.H
|
||||
|
||||
SeeAlso
|
||||
Foam::one
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef zero_H
|
||||
@ -121,7 +124,7 @@ public:
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
// Global zero
|
||||
//- Global zero
|
||||
static constexpr const zero Zero;
|
||||
|
||||
// IOstream Operators
|
||||
|
||||
Reference in New Issue
Block a user