ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Database
AthenaPOOL
AthenaPoolCnvSvc
src
AthenaRootSerializeSvc.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
/* file contains the implementation for the AthenaRootSerializeSvc class.
6
* @author Peter van Gemmeren <gemmeren@anl.gov>
7
**/
8
9
#include "
AthenaRootSerializeSvc.h
"
10
#include "
DataModelRoot/RootType.h
"
11
12
#include "TBufferFile.h"
13
#include "TClass.h"
14
15
//___________________________________________________________________________
16
AthenaRootSerializeSvc::AthenaRootSerializeSvc
(
const
std::string& name,
17
ISvcLocator* pSvcLocator) : base_class(name, pSvcLocator) {
18
}
19
20
//___________________________________________________________________________
21
AthenaRootSerializeSvc::~AthenaRootSerializeSvc
() {
22
}
23
24
//___________________________________________________________________________
25
StatusCode
AthenaRootSerializeSvc::initialize
() {
26
ATH_MSG_INFO
(
"Initializing "
<< name());
27
28
// Load message handler dictionary to avoid crashes when reporting
29
// possible errors during event processing (ATR-25049)
30
TClass::GetClass(
"TMessageHandler"
);
31
32
return
(StatusCode::SUCCESS);
33
}
34
35
//___________________________________________________________________________
36
void
*
AthenaRootSerializeSvc::serialize
(
const
void
*
object
,
const
RootType
& cltype,
size_t
& nbytes)
const
{
37
TBufferFile writeBuffer(TBuffer::kWrite);
38
writeBuffer.WriteObjectAny(
object
, cltype);
39
void
* buffer = writeBuffer.Buffer();
40
nbytes = writeBuffer.Length();
41
writeBuffer.ResetBit(TBuffer::kIsOwner); writeBuffer.SetBuffer(
nullptr
);
42
return
(buffer);
43
}
44
45
//___________________________________________________________________________
46
void
*
AthenaRootSerializeSvc::deserialize
(
void
* buffer,
size_t
& nbytes,
const
RootType
& cltype)
const
{
47
void
* obj =
nullptr
;
48
if
(cltype.
IsFundamental
()) {
49
obj =
new
char
[nbytes];
50
std::memcpy(obj, buffer, nbytes);
51
}
else
if
(cltype.
Name
() ==
"Token"
) {
// Token is C string
52
obj =
new
char
[nbytes];
53
std::memcpy(obj, buffer, nbytes);
static_cast<
char
*
>
(obj)[nbytes - 1] = 0;
54
}
else
{
55
TBufferFile readBuffer(TBuffer::kRead, nbytes, buffer, kFALSE);
56
obj = readBuffer.ReadObjectAny(cltype);
57
nbytes = readBuffer.Length();
58
}
59
return
(obj);
60
}
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
AthenaRootSerializeSvc.h
This file contains the class definition for the AthenaRootSerializeSvc class.
RootType.h
RootType
TTypeAdapter RootType
Definition
RootType.h:211
AthenaRootSerializeSvc::initialize
virtual StatusCode initialize() override
Gaudi Service Interface method implementations:
Definition
AthenaRootSerializeSvc.cxx:25
AthenaRootSerializeSvc::deserialize
virtual void * deserialize(void *buffer, size_t &nbytes, const RootType &cltype) const override
Definition
AthenaRootSerializeSvc.cxx:46
AthenaRootSerializeSvc::serialize
virtual void * serialize(const void *object, const RootType &cltype, size_t &nbytes) const override
Definition
AthenaRootSerializeSvc.cxx:36
AthenaRootSerializeSvc::AthenaRootSerializeSvc
AthenaRootSerializeSvc(const std::string &name, ISvcLocator *pSvcLocator)
Standard Service Constructor.
Definition
AthenaRootSerializeSvc.cxx:16
AthenaRootSerializeSvc::~AthenaRootSerializeSvc
virtual ~AthenaRootSerializeSvc()
Destructor.
Definition
AthenaRootSerializeSvc.cxx:21
TScopeAdapter::IsFundamental
Bool_t IsFundamental() const
Definition
RootType.cxx:731
TScopeAdapter::Name
std::string Name(unsigned int mod=Reflex::SCOPED) const
Definition
RootType.cxx:612
Generated on
for ATLAS Offline Software by
1.17.0