Heavy ion Analysis Libriares
Loading...
Searching...
No Matches
Pointer.h
1/*
2 * VoidObject.h
3 *
4 * Created on: 10 cze 2024
5 * Author: daniel
6 */
7
8#ifndef HAL_FEATURES_IO_OBJECTVOID_H_
9#define HAL_FEATURES_IO_OBJECTVOID_H_
10
11#include "Object.h"
17namespace Hal {
18 template<class T>
19 class Pointer : public Object {
20 T* fPointer = {nullptr};
21 Bool_t fOwner = {kFALSE};
22
23 public:
24 Pointer() {};
25 Pointer(T* obj, Bool_t owner) : fPointer(obj), fOwner(owner) {}
26 T* GetPointer() const { return fPointer; }
27 virtual ~Pointer() {
28 if (fOwner && fPointer) delete fPointer;
29 }
30 ClassDef(Pointer, 0)
31 };
32
37 template<class T>
38 class DoublePointer : public Object {
39 T** fPointer = {nullptr};
40 Bool_t fOwner = {kFALSE};
41
42 public:
43 DoublePointer() {};
44 DoublePointer(T** obj, Bool_t owner) : fPointer(obj), fOwner(owner) {};
49 T* GetPointer() const { return *fPointer; }
54 T** GetDoublePointer() const { return fPointer; }
59 delete fPointer;
60 fPointer = nullptr;
61 }
62 virtual ~DoublePointer() {
63 if (fPointer && fOwner) {
64 delete *fPointer;
65 delete fPointer;
66 }
67 }
68 ClassDef(DoublePointer, 0)
69 };
70 typedef Pointer<TObject> ObjectPointer;
71 typedef DoublePointer<TObject> ObjectDoublePointer;
72} // namespace Hal
73
74#endif /* HAL_FEATURES_IO_OBJECTVOID_H_ */
T ** GetDoublePointer() const
Definition Pointer.h:54
T * GetPointer() const
Definition Pointer.h:49
void DeleteDoublePointer()
Definition Pointer.h:58