mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
ENH: Added copy/clone functionality tp DataEntry class
This commit is contained in:
@ -31,8 +31,10 @@ template<class Type>
|
||||
Foam::Constant<Type>::Constant(const word& entryName, Istream& is)
|
||||
:
|
||||
DataEntry<Type>(entryName),
|
||||
value_(is)
|
||||
{}
|
||||
value_(pTraits<Type>::zero)
|
||||
{
|
||||
is >> value_;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
@ -43,22 +45,6 @@ Foam::Constant<Type>::Constant(const Constant<Type>& cnst)
|
||||
{}
|
||||
|
||||
|
||||
template<>
|
||||
Foam::Constant<Foam::label>::Constant(const word& entryName, Istream& is)
|
||||
:
|
||||
DataEntry<label>(entryName),
|
||||
value_(readLabel(is))
|
||||
{}
|
||||
|
||||
|
||||
template<>
|
||||
Foam::Constant<Foam::scalar>::Constant(const word& entryName, Istream& is)
|
||||
:
|
||||
DataEntry<scalar>(entryName),
|
||||
value_(readScalar(is))
|
||||
{}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * Destructor * * * * * * * * * * * * * * * //
|
||||
|
||||
template<class Type>
|
||||
|
||||
@ -51,11 +51,7 @@ template<class Type>
|
||||
class Constant;
|
||||
|
||||
template<class Type>
|
||||
Ostream& operator<<
|
||||
(
|
||||
Ostream&,
|
||||
const Constant<Type>&
|
||||
);
|
||||
Ostream& operator<<(Ostream&, const Constant<Type>&);
|
||||
|
||||
/*---------------------------------------------------------------------------*\
|
||||
Class Constant Declaration
|
||||
@ -92,6 +88,12 @@ public:
|
||||
//- Copy constructor
|
||||
Constant(const Constant<Type>& cnst);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<DataEntry<Type> > clone() const
|
||||
{
|
||||
return tmp<DataEntry<Type> >(new Constant<Type>(*this));
|
||||
}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~Constant();
|
||||
@ -107,23 +109,12 @@ public:
|
||||
|
||||
|
||||
//- Ostream Operator
|
||||
friend Ostream& operator<< <Type>
|
||||
(
|
||||
Ostream&,
|
||||
const Constant<Type>&
|
||||
);
|
||||
friend Ostream& operator<< <Type>(Ostream&, const Constant<Type>&);
|
||||
};
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
template<>
|
||||
Constant<label>::Constant(const word& entryName, Istream& is);
|
||||
|
||||
template<>
|
||||
Constant<scalar>::Constant(const word& entryName, Istream& is);
|
||||
|
||||
|
||||
} // End namespace Foam
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
@ -30,6 +30,7 @@ License
|
||||
template<class Type>
|
||||
Foam::DataEntry<Type>::DataEntry(const word& entryName)
|
||||
:
|
||||
refCount(),
|
||||
name_(entryName)
|
||||
{}
|
||||
|
||||
@ -37,6 +38,7 @@ Foam::DataEntry<Type>::DataEntry(const word& entryName)
|
||||
template<class Type>
|
||||
Foam::DataEntry<Type>::DataEntry(const DataEntry<Type>& de)
|
||||
:
|
||||
refCount(),
|
||||
name_(de.name_)
|
||||
{}
|
||||
|
||||
@ -57,6 +59,31 @@ const Foam::word& Foam::DataEntry<Type>::name() const
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Type Foam::DataEntry<Type>::value(const scalar x) const
|
||||
{
|
||||
notImplemented("Type Foam::DataEntry<Type>::value(const scalar) const");
|
||||
|
||||
return pTraits<Type>::zero;
|
||||
}
|
||||
|
||||
|
||||
template<class Type>
|
||||
Type Foam::DataEntry<Type>::integrate(const scalar x1, const scalar x2) const
|
||||
{
|
||||
notImplemented
|
||||
(
|
||||
"Type Foam::DataEntry<Type>::integrate"
|
||||
"("
|
||||
"const scalar, "
|
||||
"const scalar"
|
||||
") const"
|
||||
);
|
||||
|
||||
return pTraits<Type>::zero;
|
||||
}
|
||||
|
||||
|
||||
// * * * * * * * * * * * * * * IOStream operators * * * * * * * * * * * * * //
|
||||
|
||||
#include "DataEntryIO.C"
|
||||
|
||||
@ -62,6 +62,8 @@ Ostream& operator<<
|
||||
|
||||
template<class Type>
|
||||
class DataEntry
|
||||
:
|
||||
public refCount
|
||||
{
|
||||
// Private Member Functions
|
||||
|
||||
@ -104,6 +106,12 @@ public:
|
||||
//- Copy constructor
|
||||
DataEntry(const DataEntry<Type>& de);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<DataEntry<Type> > clone() const
|
||||
{
|
||||
return tmp<DataEntry<Type> >(new DataEntry<Type>(*this));
|
||||
}
|
||||
|
||||
|
||||
//- Selector
|
||||
static autoPtr<DataEntry<Type> > New
|
||||
@ -128,10 +136,10 @@ public:
|
||||
// Evaluation
|
||||
|
||||
//- Return value as a function of (scalar) independent variable
|
||||
virtual Type value(const scalar x) const = 0;
|
||||
virtual Type value(const scalar x) const;
|
||||
|
||||
//- Integrate between two (scalar) values
|
||||
virtual Type integrate(const scalar x1, const scalar x2) const = 0;
|
||||
virtual Type integrate(const scalar x1, const scalar x2) const;
|
||||
|
||||
|
||||
//- Ostream Operator
|
||||
|
||||
@ -98,6 +98,12 @@ public:
|
||||
//- Copy constructor
|
||||
Table(const Table<Type>& tbl);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<DataEntry<Type> > clone() const
|
||||
{
|
||||
return tmp<DataEntry<Type> >(new Table<Type>(*this));
|
||||
}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~Table();
|
||||
|
||||
@ -91,12 +91,17 @@ public:
|
||||
|
||||
// Constructors
|
||||
|
||||
//- Construct from entry name and Istream
|
||||
polynomial(const word& entryName, Istream& is);
|
||||
|
||||
//- Copy constructor
|
||||
polynomial(const polynomial& poly);
|
||||
|
||||
//- Construct and return a clone
|
||||
virtual tmp<DataEntry<scalar> > clone() const
|
||||
{
|
||||
return tmp<DataEntry<scalar> >(new polynomial(*this));
|
||||
}
|
||||
|
||||
|
||||
//- Destructor
|
||||
virtual ~polynomial();
|
||||
@ -112,11 +117,7 @@ public:
|
||||
|
||||
|
||||
//- Ostream Operator
|
||||
friend Ostream& operator<<
|
||||
(
|
||||
Ostream&,
|
||||
const polynomial&
|
||||
);
|
||||
friend Ostream& operator<<(Ostream&, const polynomial&);
|
||||
};
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user