Commit ab11a330 authored by Mark Olesen's avatar Mark Olesen
Browse files

ENH: accept movable autoPtr for storage in regIOobject

parent 6d906e52
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2017 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -176,12 +176,17 @@ public:
//- Transfer ownership of the given object pointer to its registry
// and return reference to object.
template<class Type>
inline static Type& store(Type*);
inline static Type& store(Type* p);
//- Transfer ownership of the given object pointer to its registry
// and return reference to object.
//- and return reference to object.
template<class Type>
inline static Type& store(autoPtr<Type>& aptr);
//- Transfer ownership of the given object pointer to its registry
//- and return reference to object.
template<class Type>
inline static Type& store(autoPtr<Type>&);
inline static Type& store(autoPtr<Type>&& aptr);
//- Release ownership of this object from its registry
inline void release();
......
......@@ -3,7 +3,7 @@
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
\\ / O peration |
\\ / A nd | Copyright (C) 2011-2015 OpenFOAM Foundation
\\/ M anipulation |
\\/ M anipulation | Copyright (C) 2018 OpenCFD Ltd.
-------------------------------------------------------------------------------
License
This file is part of OpenFOAM.
......@@ -38,36 +38,32 @@ inline void Foam::regIOobject::store()
template<class Type>
inline Type& Foam::regIOobject::store(Type* tPtr)
inline Type& Foam::regIOobject::store(Type* p)
{
if (!tPtr)
if (!p)
{
FatalErrorInFunction
<< "object deallocated"
<< abort(FatalError);
}
tPtr->regIOobject::ownedByRegistry_ = true;
p->regIOobject::ownedByRegistry_ = true;
return *tPtr;
return *p;
}
template<class Type>
inline Type& Foam::regIOobject::store(autoPtr<Type>& atPtr)
inline Type& Foam::regIOobject::store(autoPtr<Type>& aptr)
{
Type* tPtr = atPtr.ptr();
if (!tPtr)
{
FatalErrorInFunction
<< "object deallocated"
<< abort(FatalError);
}
return store(aptr.ptr()); // release, pass management to regIOobject
}
tPtr->regIOobject::ownedByRegistry_ = true;
return *tPtr;
template<class Type>
inline Type& Foam::regIOobject::store(autoPtr<Type>&& aptr)
{
return store(aptr.ptr()); // release, pass management to regIOobject
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment