Skip to content
Snippets Groups Projects
Commit 31c6b667 authored by Vakhtang Tsulaia's avatar Vakhtang Tsulaia
Browse files

Merge branch 'TP.CreateTransient' into 'master'

Add helper class CreateTransient to TPConverterBase

See merge request !2807
parents 3811649c 0b511c7d
No related branches found
No related tags found
No related merge requests found
......@@ -470,6 +470,25 @@ protected:
// --------------------------------------------------------------
namespace TPCnv {
/** @class TPCnv::CreateTransient
Helper class to make specializing the creation of transient objects
in the TPConverterBase::createTransient() easier.
Provide specialization before definition of your T/P converter for transient typeTRANS
The final T/P converter can still overwrite its whole createTransient() method
*/
template<class TRANS>
class CreateTransient {
public:
static std::unique_ptr<TRANS> create() { return std::make_unique<TRANS>(); }
};
} // namespace TPCnv
// Base converter template for polymorphic types
// Converters for objects in the same inheritance tree must share the same
......
......@@ -62,10 +62,13 @@ toPersistent_impl( const TRANS *trans, MsgStream &log )
template< class TRANS_BASE, class TRANS, class PERS >
TRANS* TPPolyCnvBase<TRANS_BASE, TRANS, PERS>::
createTransient(const PERS* persObj, MsgStream &log) {
std::unique_ptr<TRANS> trans(new TRANS());
createTransient(const PERS* persObj, MsgStream &log)
{
// this is by default equivalent to 'new TRANS()'
std::unique_ptr<TRANS> trans = TPCnv::CreateTransient<TRANS>::create();
this->persToTrans(persObj, trans.get(), log);
return(trans.release());
return( trans.release() );
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment