BmnRoot
Loading...
Searching...
No Matches
BmnDigi.cxx
Go to the documentation of this file.
1
7#include "BmnDigi.h"
8
9#include <sstream>
10#include "BmnMatch.h"
11
12#include "FairMultiLinkedData.h"
13
14#include <memory>
15#include <utility> // std::forward
16
17
18using std::string;
19using std::stringstream;
20
21
22
23// ----- Default constructor -------------------------------------------
25 : TObject(),
26 fMatch(NULL)
27{
28}
29// -------------------------------------------------------------------------
30
31
32
33// ----- Copy constructor (deep copy) ----------------------------------
35 : TObject(rhs),
36 fMatch(NULL)
37{
38 if ( rhs.fMatch ) {
39 fMatch = new BmnMatch();
40 fMatch->AddLinks( *(rhs.fMatch) );
41 }
42}
43// -------------------------------------------------------------------------
44
45
46
47// ----- Move constructor -----------------------------------------------
49 : TObject(std::forward<BmnDigi>(other)), // should be std::forward
50 fMatch(nullptr)
51{
52 fMatch = other.fMatch;
53 other.fMatch = nullptr;
54}
55// -------------------------------------------------------------------------
56
57
58
59// ----- Assignment operator (deep copy) --------------------------------
61{
62 if (this != &rhs) {
63 TObject::operator=(rhs);
64 if ( rhs.fMatch ) {
65 fMatch = new BmnMatch();
66 fMatch->AddLinks( *(rhs.fMatch) );
67 }
68 else fMatch = NULL;
69 }
70 return *this;
71}
72// -------------------------------------------------------------------------
73
74
75
76// ----- Assignment operator (deep copy) --------------------------------
78{
79 if (this != &other) {
80 TObject::operator=(std::forward<BmnDigi>(other));
81 // Free the existing resource
82 delete fMatch;
83 fMatch = other.fMatch;
84 other.fMatch = nullptr;
85 }
86 return *this;
87}
88// -------------------------------------------------------------------------
89
90
91
92// ----- Destructor ----------------------------------------------------
94 if ( fMatch) delete fMatch;
95}
96// -------------------------------------------------------------------------
97
98
99
100// ----- Info to string ------------------------------------------------
101string BmnDigi::ToString() const {
102 stringstream ss;
103 ss << "Digi: address " << GetAddress() << " | time " << GetTime();
104 return ss.str();
105}
106// -------------------------------------------------------------------------
107
108
109// The following functions are only implemented for the unit tests.
110// They can only be called from a derived class via BmnDigi::GetAddress()
112{
113 return -111;
114}
115
117{
118 return -111;
119}
120
121Double_t BmnDigi::GetTime() const
122{
123 return -111.;
124}
Base class for persistent representation of digital information.
Definition BmnDigi.h:44
virtual std::string ToString() const
Definition BmnDigi.cxx:101
BmnDigi()
Definition BmnDigi.cxx:24
virtual Int_t GetSystemId() const =0
Definition BmnDigi.cxx:116
BmnDigi & operator=(const BmnDigi &)
Definition BmnDigi.cxx:60
BmnMatch * fMatch
Monte-Carlo match information.
Definition BmnDigi.h:97
virtual Double_t GetTime() const =0
Definition BmnDigi.cxx:121
virtual Int_t GetAddress() const =0
Definition BmnDigi.cxx:111
virtual ~BmnDigi()
Definition BmnDigi.cxx:93
void AddLinks(const BmnMatch &match)
Definition BmnMatch.h:46
STL namespace.