Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RooLinkedListElem.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitCore *
4 * File: $Id: RooLinkedListElem.h,v 1.11 2007/05/11 09:11:30 verkerke Exp $
5 * Authors: *
6 * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
7 * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
8 * *
9 * Copyright (c) 2000-2005, Regents of the University of California *
10 * and Stanford University. All rights reserved. *
11 * *
12 * Redistribution and use in source and binary forms, *
13 * with or without modification, are permitted according to the terms *
14 * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
15 *****************************************************************************/
16#ifndef ROO_LINKED_LIST_ELEM
17#define ROO_LINKED_LIST_ELEM
18
19#include "Rtypes.h"
20
21class TObject ;
23class TBuffer ;
24
25/// \cond ROOFIT_INTERNAL
26
27namespace RooLinkedListImplDetails {
28 class Chunk;
29 class Pool;
30}
31
32/// \endcond
33
35public:
36 // Initial element constructor
37 RooLinkedListElem() = default;
38
39 void init(TObject* arg, RooLinkedListElem* after=nullptr) {
40 _arg = arg ;
41 _refCount = 1 ;
42
43 if (after) {
44 _prev = after ;
45 _next = after->_next ;
46 after->_next = this ;
47 if (_next) {
48 _next->_prev = this ;
49 }
50 }
51 }
52
53 void release() {
54 if (_prev) _prev->_next = _next ;
55 if (_next) _next->_prev = _prev ;
56 _prev = nullptr ;
57 _next = nullptr ;
58 }
59
60 /// Constructor with payload.
62
64 // Constructor with payload and next chain element
65 _prev(after), _next(after->_next), _arg(arg), _refCount(1) {
66
67 // Insert self in link
68 after->_next = this ;
69 if (_next) _next->_prev = this ;
70 }
71
72 // Destructor
74 // Remove self from link
75 if (_prev) _prev->_next = _next ;
76 if (_next) _next->_prev = _prev ;
77 }
78
79 Int_t refCount() const { return _refCount ; }
80 Int_t incRefCount() { return ++_refCount ; }
81 Int_t decRefCount() { return --_refCount ; }
82
83protected:
84 friend class RooLinkedList ;
87 friend class RooLinkedListIterImpl ;
88 friend class RooFIterForLinkedList ;
89 RooLinkedListElem* _prev = nullptr; ///< Link to previous element in list
90 RooLinkedListElem* _next = nullptr; ///< Link to next element in list
91 TObject* _arg = nullptr; ///< Link to contents
92 Int_t _refCount = 0; ///<! Reference count
93
94protected:
95
96 // Forbidden
98
99 ClassDef(RooLinkedListElem,1) // Element of RooLinkedList container class
100} ;
101
102
103
104#endif
#define ClassDef(name, id)
Definition Rtypes.h:337
Implementation of the GenericRooFIter interface for the RooLinkedList.
Link element for the RooLinkedList class.
TObject * _arg
Link to contents.
RooLinkedListElem(TObject *arg)
Constructor with payload.
friend class RooLinkedListImplDetails::Pool
Int_t _refCount
! Reference count
RooLinkedListElem(TObject *arg, RooLinkedListElem *after)
RooLinkedListElem(const RooLinkedListElem &)
void init(TObject *arg, RooLinkedListElem *after=nullptr)
RooLinkedListElem()=default
RooLinkedListElem * _prev
Link to previous element in list.
RooLinkedListElem * _next
Link to next element in list.
friend class RooLinkedListImplDetails::Chunk
Int_t refCount() const
Implementation of the actual iterator on RooLinkedLists.
Collection class for internal use, storing a collection of RooAbsArg pointers in a doubly linked list...
Buffer base class used for serializing objects.
Definition TBuffer.h:43
Mother of all ROOT objects.
Definition TObject.h:41