The Gaudi Framework  master (37c0b60a)
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 
15 namespace Gaudi {
16  namespace TestSuite {
17  namespace TestObjectVersion {
18  // using ObjectType = DataObject;
20 
21  struct CreateObject : Gaudi::Functional::Producer<ObjectType()> {
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& )> {
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
Gaudi::TestSuite::TestObjectVersion::UseObject
Definition: TestObjectVersion.cpp:33
Gaudi::Functional::Consumer
details::Consumer< Signature, Traits_, details::isLegacy< Traits_ > > Consumer
Definition: Consumer.h:69
std::string
STL class.
TestSuite
#define TestSuite
Definition: MakeAndConsume.cpp:658
ISvcLocator
Definition: ISvcLocator.h:46
GaudiException
Definition: GaudiException.h:31
DataObject::setVersion
void setVersion(unsigned char vsn)
Set version number of this object representation.
Definition: DataObject.h:85
Gaudi::TestSuite::TestObjectVersion::CreateObject
Definition: TestObjectVersion.cpp:21
KeyedContainer.h
Gaudi::TestSuite::TestObjectVersion::CreateObject::CreateObject
CreateObject(const std::string &name, ISvcLocator *svcLoc)
Definition: TestObjectVersion.cpp:22
Gaudi::TestSuite::TestObjectVersion::UseObject::operator()
void operator()(const ObjectType &o) const override
Definition: TestObjectVersion.cpp:36
Consumer.h
Gaudi::Functional::Producer
details::Producer< Signature, Traits_, details::isLegacy< Traits_ > > Producer
Definition: Producer.h:37
Producer.h
KeyedContainer
template class KeyedContainer, KeyedContainer.h
Definition: KeyedContainer.h:74
Gaudi::Functional::details::Producer
Definition: Producer.h:22
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202
Gaudi
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition: __init__.py:1
ConditionsStallTest.name
name
Definition: ConditionsStallTest.py:77
DECLARE_COMPONENT
#define DECLARE_COMPONENT(type)
Definition: PluginServiceV1.h:46
DataObject::version
unsigned char version() const
Retrieve version number of this object representation.
Definition: DataObject.h:83
Gaudi::TestSuite::TestObjectVersion::CreateObject::operator()
ObjectType operator()() const override
Definition: TestObjectVersion.cpp:24
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:101
Gaudi::TestSuite::TestObjectVersion::UseObject::UseObject
UseObject(const std::string &name, ISvcLocator *svcLoc)
Definition: TestObjectVersion.cpp:34