The Gaudi Framework  master (181af51f)
Loading...
Searching...
No Matches
TestObjectVersion.cpp
Go to the documentation of this file.
1/***********************************************************************************\
2* (c) Copyright 1998-2023 CERN for the benefit of the LHCb and ATLAS collaborations *
3* *
4* This software is distributed under the terms of the Apache version 2 licence, *
5* copied verbatim in the file "LICENSE". *
6* *
7* In applying this licence, CERN does not waive the privileges and immunities *
8* granted to it by virtue of its status as an Intergovernmental Organization *
9* or submit itself to any jurisdiction. *
10\***********************************************************************************/
14
15namespace Gaudi {
16 namespace TestSuite {
18 // using ObjectType = DataObject;
20
22 CreateObject( const std::string& name, ISvcLocator* svcLoc )
23 : Producer( name, svcLoc, KeyValue( "OutputLocation", "/Event/SomeData" ) ) {}
24 ObjectType operator()() const override {
25 ObjectType o;
26 o.setVersion( 42 );
27 info() << "Created object with version " << static_cast<int>( o.version() ) << endmsg;
28 return o;
29 }
30 };
31 DECLARE_COMPONENT( CreateObject )
32
33 struct UseObject : Gaudi::Functional::Consumer<void( const ObjectType& )> {
34 UseObject( const std::string& name, ISvcLocator* svcLoc )
35 : Consumer( name, svcLoc, KeyValue( "InputLocation", "/Event/SomeData" ) ) {}
36 void operator()( const ObjectType& o ) const override {
37 info() << "Retrieved object with version " << static_cast<int>( o.version() ) << endmsg;
38 if ( o.version() != 42 ) throw GaudiException( "Wrong object version", name(), StatusCode::FAILURE );
39 }
40 };
41 DECLARE_COMPONENT( UseObject )
42 } // namespace TestObjectVersion
43 } // namespace TestSuite
44} // namespace Gaudi
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition MsgStream.h:198
#define DECLARE_COMPONENT(type)
unsigned char version() const
Retrieve version number of this object representation.
Definition DataObject.h:84
void setVersion(unsigned char vsn)
Set version number of this object representation.
Definition DataObject.h:86
Define general base for Gaudi exception.
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition ISvcLocator.h:42
template class KeyedContainer, KeyedContainer.h
constexpr static const auto FAILURE
Definition StatusCode.h:100
details::Producer< Signature, Traits_, details::isLegacy< Traits_ > > Producer
Definition Producer.h:37
KeyedContainer< KeyedObject< std::size_t > > ObjectType
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition __init__.py:1
CreateObject(const std::string &name, ISvcLocator *svcLoc)
void operator()(const ObjectType &o) const override
UseObject(const std::string &name, ISvcLocator *svcLoc)