tmp: encapsulate refCount to enable the option for tmp to use a specific version

This commit is contained in:
Henry Weller
2016-02-28 22:50:24 +00:00
parent eb1498f4c7
commit dac76d680c
27 changed files with 104 additions and 122 deletions

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -29,12 +29,12 @@ License
namespace Foam
{
const char* const token::typeName = "token";
token token::undefinedToken;
const char* const token::typeName = "token";
token token::undefinedToken;
typedef token::compound tokenCompound;
defineTypeNameAndDebug(tokenCompound, 0);
defineRunTimeSelectionTable(tokenCompound, Istream);
typedef token::compound tokenCompound;
defineTypeNameAndDebug(tokenCompound, 0);
defineRunTimeSelectionTable(tokenCompound, Istream);
}

View File

@ -25,15 +25,9 @@ License
#include <iostream>
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
namespace Foam
{
// * * * * * * * * * * * * * Private Member Functions * * * * * * * * * * * //
// Clear any allocated storage (word or string)
inline void token::clear()
inline void Foam::token::clear()
{
if (type_ == WORD)
{
@ -61,15 +55,14 @@ inline void token::clear()
// * * * * * * * * * * * * * * * * Constructors * * * * * * * * * * * * * * //
// Construct null
inline token::token()
inline Foam::token::token()
:
type_(UNDEFINED),
lineNumber_(0)
{}
// Construct as copy
inline token::token(const token& t)
inline Foam::token::token(const token& t)
:
type_(t.type_),
lineNumber_(t.lineNumber_)
@ -115,48 +108,48 @@ inline token::token(const token& t)
}
}
// Construct punctuation character token
inline token::token(punctuationToken p, label lineNumber)
inline Foam::token::token(punctuationToken p, label lineNumber)
:
type_(PUNCTUATION),
punctuationToken_(p),
lineNumber_(lineNumber)
{}
// Construct word token
inline token::token(const word& w, label lineNumber)
inline Foam::token::token(const word& w, label lineNumber)
:
type_(WORD),
wordTokenPtr_(new word(w)),
lineNumber_(lineNumber)
{}
// Construct string token
inline token::token(const string& s, label lineNumber)
inline Foam::token::token(const string& s, label lineNumber)
:
type_(STRING),
stringTokenPtr_(new string(s)),
lineNumber_(lineNumber)
{}
// Construct label token
inline token::token(const label l, label lineNumber)
inline Foam::token::token(const label l, label lineNumber)
:
type_(LABEL),
labelToken_(l),
lineNumber_(lineNumber)
{}
// Construct floatScalar token
inline token::token(const floatScalar s, label lineNumber)
inline Foam::token::token(const floatScalar s, label lineNumber)
:
type_(FLOAT_SCALAR),
floatScalarToken_(s),
lineNumber_(lineNumber)
{}
// Construct doubleScalar token
inline token::token(const doubleScalar s, label lineNumber)
inline Foam::token::token(const doubleScalar s, label lineNumber)
:
type_(DOUBLE_SCALAR),
doubleScalarToken_(s),
@ -166,8 +159,7 @@ inline token::token(const doubleScalar s, label lineNumber)
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
// Delete token clearing the storage used by word or string
inline token::~token()
inline Foam::token::~token()
{
clear();
}
@ -175,37 +167,37 @@ inline token::~token()
// * * * * * * * * * * * * * * * Member Functions * * * * * * * * * * * * * //
inline token::tokenType token::type() const
inline Foam::token::tokenType Foam::token::type() const
{
return type_;
}
inline token::tokenType& token::type()
inline Foam::token::tokenType& Foam::token::type()
{
return type_;
}
inline bool token::good() const
inline bool Foam::token::good() const
{
return (type_ != ERROR && type_ != UNDEFINED);
}
inline bool token::undefined() const
inline bool Foam::token::undefined() const
{
return (type_ == UNDEFINED);
}
inline bool token::error() const
inline bool Foam::token::error() const
{
return (type_ == ERROR);
}
inline bool token::isPunctuation() const
inline bool Foam::token::isPunctuation() const
{
return (type_ == PUNCTUATION);
}
inline token::punctuationToken token::pToken() const
inline Foam::token::punctuationToken Foam::token::pToken() const
{
if (type_ == PUNCTUATION)
{
@ -218,12 +210,12 @@ inline token::punctuationToken token::pToken() const
}
}
inline bool token::isWord() const
inline bool Foam::token::isWord() const
{
return (type_ == WORD);
}
inline const word& token::wordToken() const
inline const Foam::word& Foam::token::wordToken() const
{
if (type_ == WORD)
{
@ -236,17 +228,17 @@ inline const word& token::wordToken() const
}
}
inline bool token::isVariable() const
inline bool Foam::token::isVariable() const
{
return (type_ == VARIABLE);
}
inline bool token::isString() const
inline bool Foam::token::isString() const
{
return (type_ == STRING || type_ == VARIABLE || type_ == VERBATIMSTRING);
}
inline const string& token::stringToken() const
inline const Foam::string& Foam::token::stringToken() const
{
if (type_ == STRING || type_ == VARIABLE || type_ == VERBATIMSTRING)
{
@ -259,12 +251,12 @@ inline const string& token::stringToken() const
}
}
inline bool token::isLabel() const
inline bool Foam::token::isLabel() const
{
return (type_ == LABEL);
}
inline label token::labelToken() const
inline Foam::label Foam::token::labelToken() const
{
if (type_ == LABEL)
{
@ -277,12 +269,12 @@ inline label token::labelToken() const
}
}
inline bool token::isFloatScalar() const
inline bool Foam::token::isFloatScalar() const
{
return (type_ == FLOAT_SCALAR);
}
inline floatScalar token::floatScalarToken() const
inline Foam::floatScalar Foam::token::floatScalarToken() const
{
if (type_ == FLOAT_SCALAR)
{
@ -296,12 +288,12 @@ inline floatScalar token::floatScalarToken() const
}
inline bool token::isDoubleScalar() const
inline bool Foam::token::isDoubleScalar() const
{
return (type_ == DOUBLE_SCALAR);
}
inline doubleScalar token::doubleScalarToken() const
inline Foam::doubleScalar Foam::token::doubleScalarToken() const
{
if (type_ == DOUBLE_SCALAR)
{
@ -315,12 +307,12 @@ inline doubleScalar token::doubleScalarToken() const
}
inline bool token::isScalar() const
inline bool Foam::token::isScalar() const
{
return (type_ == FLOAT_SCALAR || type_ == DOUBLE_SCALAR);
}
inline scalar token::scalarToken() const
inline Foam::scalar Foam::token::scalarToken() const
{
if (type_ == FLOAT_SCALAR)
{
@ -337,12 +329,12 @@ inline scalar token::scalarToken() const
}
}
inline bool token::isNumber() const
inline bool Foam::token::isNumber() const
{
return (type_ == LABEL || isScalar());
}
inline scalar token::number() const
inline Foam::scalar Foam::token::number() const
{
if (type_ == LABEL)
{
@ -359,12 +351,12 @@ inline scalar token::number() const
}
}
inline bool token::isCompound() const
inline bool Foam::token::isCompound() const
{
return (type_ == COMPOUND);
}
inline const token::compound& token::compoundToken() const
inline const Foam::token::compound& Foam::token::compoundToken() const
{
if (type_ == COMPOUND)
{
@ -378,18 +370,18 @@ inline const token::compound& token::compoundToken() const
}
inline label token::lineNumber() const
inline Foam::label Foam::token::lineNumber() const
{
return lineNumber_;
}
inline label& token::lineNumber()
inline Foam::label& Foam::token::lineNumber()
{
return lineNumber_;
}
inline void token::setBad()
inline void Foam::token::setBad()
{
clear();
type_ = ERROR;
@ -398,7 +390,7 @@ inline void token::setBad()
// * * * * * * * * * * * * * * * Member Operators * * * * * * * * * * * * * //
inline void token::operator=(const token& t)
inline void Foam::token::operator=(const token& t)
{
clear();
type_ = t.type_;
@ -446,59 +438,59 @@ inline void token::operator=(const token& t)
lineNumber_ = t.lineNumber_;
}
inline void token::operator=(const punctuationToken p)
inline void Foam::token::operator=(const punctuationToken p)
{
clear();
type_ = PUNCTUATION;
punctuationToken_ = p;
}
inline void token::operator=(word* wPtr)
inline void Foam::token::operator=(word* wPtr)
{
clear();
type_ = WORD;
wordTokenPtr_ = wPtr;
}
inline void token::operator=(const word& w)
inline void Foam::token::operator=(const word& w)
{
operator=(new word(w));
}
inline void token::operator=(string* sPtr)
inline void Foam::token::operator=(string* sPtr)
{
clear();
type_ = STRING;
stringTokenPtr_ = sPtr;
}
inline void token::operator=(const string& s)
inline void Foam::token::operator=(const string& s)
{
operator=(new string(s));
}
inline void token::operator=(const label l)
inline void Foam::token::operator=(const label l)
{
clear();
type_ = LABEL;
labelToken_ = l;
}
inline void token::operator=(const floatScalar s)
inline void Foam::token::operator=(const floatScalar s)
{
clear();
type_ = FLOAT_SCALAR;
floatScalarToken_ = s;
}
inline void token::operator=(const doubleScalar s)
inline void Foam::token::operator=(const doubleScalar s)
{
clear();
type_ = DOUBLE_SCALAR;
doubleScalarToken_ = s;
}
inline void token::operator=(token::compound* cPtr)
inline void Foam::token::operator=(Foam::token::compound* cPtr)
{
clear();
type_ = COMPOUND;
@ -506,7 +498,7 @@ inline void token::operator=(token::compound* cPtr)
}
inline bool token::operator==(const token& t) const
inline bool Foam::token::operator==(const token& t) const
{
if (type_ != t.type_)
{
@ -548,17 +540,17 @@ inline bool token::operator==(const token& t) const
return false;
}
inline bool token::operator==(const punctuationToken p) const
inline bool Foam::token::operator==(const punctuationToken p) const
{
return (type_ == PUNCTUATION && punctuationToken_ == p);
}
inline bool token::operator==(const word& w) const
inline bool Foam::token::operator==(const word& w) const
{
return (type_ == WORD && wordToken() == w);
}
inline bool token::operator==(const string& s) const
inline bool Foam::token::operator==(const string& s) const
{
return
(
@ -567,59 +559,55 @@ inline bool token::operator==(const string& s) const
);
}
inline bool token::operator==(const label l) const
inline bool Foam::token::operator==(const label l) const
{
return (type_ == LABEL && labelToken_ == l);
}
inline bool token::operator==(const floatScalar s) const
inline bool Foam::token::operator==(const floatScalar s) const
{
return (type_ == FLOAT_SCALAR && equal(floatScalarToken_, s));
}
inline bool token::operator==(const doubleScalar s) const
inline bool Foam::token::operator==(const doubleScalar s) const
{
return (type_ == DOUBLE_SCALAR && equal(doubleScalarToken_, s));
}
inline bool token::operator!=(const token& t) const
inline bool Foam::token::operator!=(const token& t) const
{
return !operator==(t);
}
inline bool token::operator!=(const punctuationToken p) const
inline bool Foam::token::operator!=(const punctuationToken p) const
{
return !operator==(p);
}
inline bool token::operator!=(const word& w) const
inline bool Foam::token::operator!=(const word& w) const
{
return !operator==(w);
}
inline bool token::operator!=(const string& s) const
inline bool Foam::token::operator!=(const string& s) const
{
return !operator==(s);
}
inline bool token::operator!=(const floatScalar s) const
inline bool Foam::token::operator!=(const floatScalar s) const
{
return !operator==(s);
}
inline bool token::operator!=(const doubleScalar s) const
inline bool Foam::token::operator!=(const doubleScalar s) const
{
return !operator==(s);
}
inline bool token::operator!=(const label l) const
inline bool Foam::token::operator!=(const label l) const
{
return !operator==(l);
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
} // End namespace Foam
// ************************************************************************* //

View File

@ -2,7 +2,7 @@
========= |
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011 OpenFOAM Foundation
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
\\/ M anipulation |
-------------------------------------------------------------------------------
License
@ -39,11 +39,9 @@ Description
namespace Foam
{
typedef List<token> tokenList;
typedef List<token::tokenType> tokenTypeList;
} // End namespace Foam
}
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //

View File

@ -63,7 +63,7 @@ inline Foam::SubDimensionedField<Type, GeoMesh>::SubDimensionedField
const SubDimensionedField<Type, GeoMesh>& sfield
)
:
refCount(),
tmp<SubDimensionedField<Type, GeoMesh>>::refCount(),
SubField<Type>(sfield)
{}

View File

@ -137,7 +137,7 @@ FieldField<Field, Type>::FieldField
template<template<class> class Field, class Type>
FieldField<Field, Type>::FieldField(const FieldField<Field, Type>& f)
:
refCount(),
tmp<FieldField<Field, Type>>::refCount(),
PtrList<Field<Type>>(f)
{}
@ -145,7 +145,6 @@ FieldField<Field, Type>::FieldField(const FieldField<Field, Type>& f)
template<template<class> class Field, class Type>
FieldField<Field, Type>::FieldField(FieldField<Field, Type>& f, bool reuse)
:
refCount(),
PtrList<Field<Type>>(f, reuse)
{}

View File

@ -73,7 +73,7 @@ Ostream& operator<<
template<template<class> class Field, class Type>
class FieldField
:
public refCount,
public tmp<FieldField<Field, Type>>::refCount,
public PtrList<Field<Type>>
{

View File

@ -196,7 +196,7 @@ Foam::Field<Type>::Field
template<class Type>
Foam::Field<Type>::Field(const Field<Type>& f)
:
refCount(),
tmp<Field<Type>>::refCount(),
List<Type>(f)
{}

View File

@ -77,7 +77,7 @@ class dictionary;
template<class Type>
class Field
:
public refCount,
public tmp<Field<Type>>::refCount,
public List<Type>
{

View File

@ -58,7 +58,7 @@ template<class Type> class SubField;
template<class Type>
class SubField
:
public refCount,
public tmp<SubField<Type>>::refCount,
public SubList<Type>
{

View File

@ -74,7 +74,7 @@ inline Foam::SubField<Type>::SubField
const SubField<Type>& sfield
)
:
refCount(),
tmp<SubField<Type>>::refCount(),
SubList<Type>(sfield)
{}

View File

@ -77,6 +77,9 @@ class tmp
public:
typedef Foam::refCount refCount;
// Constructors
//- Store object pointer

View File

@ -157,8 +157,6 @@ class polyMesh;
\*---------------------------------------------------------------------------*/
class mapPolyMesh
:
public refCount
{
// Private data

View File

@ -34,7 +34,6 @@ SourceFiles
#ifndef mapSubsetMesh_H
#define mapSubsetMesh_H
#include "refCount.H"
#include "labelList.H"
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
@ -47,8 +46,6 @@ namespace Foam
\*---------------------------------------------------------------------------*/
class mapSubsetMesh
:
public refCount
{
// Private data

View File

@ -31,7 +31,6 @@ License
template<class Type>
Foam::Function1<Type>::Function1(const word& entryName)
:
refCount(),
name_(entryName)
{}
@ -39,7 +38,7 @@ Foam::Function1<Type>::Function1(const word& entryName)
template<class Type>
Foam::Function1<Type>::Function1(const Function1<Type>& de)
:
refCount(),
tmp<Function1<Type>>::refCount(),
name_(de.name_)
{}
@ -62,9 +61,7 @@ const Foam::word& Foam::Function1<Type>::name() const
template<class Type>
void Foam::Function1<Type>::convertTimeBase(const Time&)
{
// do nothing
}
{}
template<class Type>

View File

@ -61,7 +61,7 @@ template<class Type> Ostream& operator<<(Ostream&, const Function1<Type>&);
template<class Type>
class Function1
:
public refCount
public tmp<Function1<Type>>::refCount
{
// Private Member Functions

View File

@ -46,7 +46,7 @@ namespace fv
template<class Type>
convectionScheme<Type>::convectionScheme(const convectionScheme& cs)
:
refCount(),
tmp<convectionScheme<Type>>::refCount(),
mesh_(cs.mesh_)
{}

View File

@ -64,7 +64,7 @@ namespace fv
template<class Type>
class convectionScheme
:
public refCount
public tmp<convectionScheme<Type>>::refCount
{
// Private data

View File

@ -64,7 +64,7 @@ namespace fv
template<class Type>
class d2dt2Scheme
:
public refCount
public tmp<d2dt2Scheme<Type>>::refCount
{
protected:

View File

@ -64,7 +64,7 @@ namespace fv
template<class Type>
class ddtScheme
:
public refCount
public tmp<ddtScheme<Type>>::refCount
{
protected:

View File

@ -64,7 +64,7 @@ namespace fv
template<class Type>
class divScheme
:
public refCount
public tmp<divScheme<Type>>::refCount
{
protected:

View File

@ -60,7 +60,7 @@ namespace fv
template<class Type>
class gradScheme
:
public refCount
public tmp<gradScheme<Type>>::refCount
{
// Private data

View File

@ -65,7 +65,7 @@ namespace fv
template<class Type, class GType>
class laplacianScheme
:
public refCount
public tmp<laplacianScheme<Type, GType>>::refCount
{
protected:

View File

@ -60,7 +60,7 @@ namespace fv
template<class Type>
class snGradScheme
:
public refCount
public tmp<snGradScheme<Type>>::refCount
{
// Private data
@ -70,6 +70,9 @@ class snGradScheme
// Private Member Functions
//- Disallow copy construct
snGradScheme(const snGradScheme&);
//- Disallow default bitwise assignment
void operator=(const snGradScheme&);

View File

@ -321,7 +321,7 @@ Foam::fvMatrix<Type>::fvMatrix
template<class Type>
Foam::fvMatrix<Type>::fvMatrix(const fvMatrix<Type>& fvm)
:
refCount(),
tmp<fvMatrix<Type>>::refCount(),
lduMatrix(fvm),
psi_(fvm.psi_),
dimensions_(fvm.dimensions_),
@ -351,7 +351,6 @@ Foam::fvMatrix<Type>::fvMatrix(const fvMatrix<Type>& fvm)
template<class Type>
Foam::fvMatrix<Type>::fvMatrix(const tmp<fvMatrix<Type>>& tfvm)
:
refCount(),
lduMatrix
(
const_cast<fvMatrix<Type>&>(tfvm()),

View File

@ -114,7 +114,7 @@ template<class T> class UIndirectList;
template<class Type>
class fvMatrix
:
public refCount,
public tmp<fvMatrix<Type>>::refCount,
public lduMatrix
{
// Private data

View File

@ -50,7 +50,7 @@ namespace Foam
template<class Type>
class multivariateSurfaceInterpolationScheme
:
public refCount
public tmp<multivariateSurfaceInterpolationScheme<Type>>::refCount
{
public:

View File

@ -55,7 +55,7 @@ class fvMesh;
template<class Type>
class surfaceInterpolationScheme
:
public refCount
public tmp<surfaceInterpolationScheme<Type>>::refCount
{
// Private data