PODIO
v00-16-03
An Event-Data-Model Toolkit for High Energy Physics Experiments
Loading...
Searching...
No Matches
ObjBase.h
Go to the documentation of this file.
1
#ifndef PODIO_OBJBASE_H
2
#define PODIO_OBJBASE_H
3
4
#include "
podio/ObjectID.h
"
5
#include <atomic>
6
#include <iostream>
7
8
namespace
podio
{
9
10
class
ObjBase
{
11
public
:
12
/// Constructor from ObjectID and initial object-count
13
ObjBase
(
ObjectID
id_,
unsigned
i) :
id
(id_), ref_counter(i) {
14
}
15
16
/// checks whether object is "untracked" by a collection
17
/// if yes, increases reference count
18
void
acquire
() {
19
if
(
id
.index ==
podio::ObjectID::untracked
) {
20
++ref_counter;
21
}
22
};
23
24
/// checks whether object is "untracked" by a collection
25
/// if yes, decrease reference count and delete itself if count===0
26
int
release
() {
27
if
(
id
.index !=
podio::ObjectID::untracked
) {
28
return
1;
29
};
30
if
(--ref_counter == 0) {
31
delete
this
;
32
}
33
return
0;
34
};
35
36
/// destructor
37
virtual
~ObjBase
() =
default
;
38
39
public
:
40
/// ID of the object
41
podio::ObjectID
id
;
42
43
private
:
44
/// reference counter
45
std::atomic<unsigned> ref_counter;
46
};
47
48
}
// namespace podio
49
50
#endif
ObjectID.h
podio::ObjBase
Definition:
ObjBase.h:10
podio::ObjBase::~ObjBase
virtual ~ObjBase()=default
destructor
podio::ObjBase::acquire
void acquire()
Definition:
ObjBase.h:18
podio::ObjBase::release
int release()
Definition:
ObjBase.h:26
podio::ObjBase::ObjBase
ObjBase(ObjectID id_, unsigned i)
Constructor from ObjectID and initial object-count.
Definition:
ObjBase.h:13
podio::ObjBase::id
podio::ObjectID id
ID of the object.
Definition:
ObjBase.h:41
podio::ObjectID
Definition:
ObjectID.h:6
podio::ObjectID::untracked
static const int untracked
not part of a collection
Definition:
ObjectID.h:15
podio
Definition:
ASCIIWriter.h:14
podio-00-16-03
include
podio
ObjBase.h
Generated by
1.9.6