Commit c8f3520f authored by Marco Clemencic's avatar Marco Clemencic
Browse files

Add test and fix of version propagation in KeyedContainer move (#27)

parent 8f22dbb5
#include <GaudiAlg/Consumer.h>
#include <GaudiAlg/Producer.h>
#include <GaudiKernel/KeyedContainer.h>
namespace Gaudi
{
namespace Examples
{
namespace TestObjectVersion
{
// using ObjectType = DataObject;
using ObjectType = KeyedContainer<KeyedObject<std::size_t>>;
struct CreateObject : Gaudi::Functional::Producer<ObjectType()> {
CreateObject( const std::string& name, ISvcLocator* svcLoc )
: Producer( name, svcLoc, KeyValue( "OutputLocation", "/Event/SomeData" ) )
{
}
ObjectType operator()() const override
{
ObjectType o;
o.setVersion( 42 );
info() << "Created object with version " << static_cast<int>( o.version() ) << endmsg;
return o;
}
};
DECLARE_COMPONENT( CreateObject )
struct UseObject : Gaudi::Functional::Consumer<void( const ObjectType& )> {
UseObject( const std::string& name, ISvcLocator* svcLoc )
: Consumer( name, svcLoc, KeyValue( "InputLocation", "/Event/SomeData" ) )
{
}
void operator()( const ObjectType& o ) const override
{
info() << "Retrieved object with version " << static_cast<int>( o.version() ) << endmsg;
if ( o.version() != 42 ) throw GaudiException( "Wrong object version", name(), StatusCode::FAILURE );
}
};
DECLARE_COMPONENT( UseObject )
}
}
}
from Gaudi.Configuration import ApplicationMgr
from Configurables import Gaudi__Examples__TestObjectVersion__CreateObject as CO
from Configurables import Gaudi__Examples__TestObjectVersion__UseObject as UO
ApplicationMgr(TopAlg=[CO(), UO()], EvtSel="NONE", EvtMax=1)
<?xml version="1.0" ?><!DOCTYPE extension PUBLIC '-//QM/2.3/Extension//EN' 'http://www.codesourcery.com/qm/dtds/2.3/-//qm/2.3/extension//en.dtd'>
<extension class="GaudiTest.GaudiExeTest" kind="test">
<argument name="program"><text>gaudirun.py</text></argument>
<argument name="args"><set><text>$GAUDIEXAMPLESROOT/tests/options/TestObjectVersion.py</text></set></argument>
<argument name="use_temp_dir"><enumeral>true</enumeral></argument>
</extension>
......@@ -189,7 +189,9 @@ public:
m_cont.setup( (void*)sptr, (void**)rptr );
}
KeyedContainer( KeyedContainer&& other )
: m_cont( std::move( other.m_cont ) ), m_sequential( std::move( other.m_sequential ) )
: ObjectContainerBase( std::move( other ) )
, m_cont( std::move( other.m_cont ) )
, m_sequential( std::move( other.m_sequential ) )
{
m_cont.setup( (void*)&m_sequential, (void**)&m_random );
std::for_each( begin(), end(), [this]( ContainedObject* obj ) { obj->setParent( this ); } );
......
Supports Markdown
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