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
26 class Chunk;
27 class Pool;
28}
29
31public:
32 // Initial element ctor
34 _prev(nullptr), _next(nullptr), _arg(nullptr), _refCount(0) {
35 }
36
37 void init(TObject* arg, RooLinkedListElem* after=nullptr) {
38 _arg = arg ;
39 _refCount = 1 ;
40
41 if (after) {
42 _prev = after ;
43 _next = after->_next ;
44 after->_next = this ;
45 if (_next) {
46 _next->_prev = this ;
47 }
48 }
49 }
50
51 void release() {
52 if (_prev) _prev->_next = _next ;
53 if (_next) _next->_prev = _prev ;
54 _prev = nullptr ;
55 _next = nullptr ;
56 }
57
59 // Constructor with payload
60 _prev(nullptr), _next(nullptr), _arg(arg), _refCount(1) {
61 }
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 ; ///< Link to previous element in list
90 RooLinkedListElem* _next ; ///< Link to next element in list
91 TObject* _arg ; ///< Link to contents
92 Int_t _refCount ; ///<! 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.
RooLinkedListElem is an link element for the RooLinkedList class.
TObject * _arg
Link to contents.
RooLinkedListElem(TObject *arg)
Int_t _refCount
! Reference count
RooLinkedListElem(TObject *arg, RooLinkedListElem *after)
RooLinkedListElem(const RooLinkedListElem &)
void init(TObject *arg, RooLinkedListElem *after=nullptr)
RooLinkedListElem * _prev
Link to previous element in list.
RooLinkedListElem * _next
Link to next element in list.
Int_t refCount() const
a chunk of memory in a pool for quick allocation of RooLinkedListElems
Implementation of the actual iterator on RooLinkedLists.
RooLinkedList is an collection class for internal use, storing a collection of RooAbsArg pointers in ...
Buffer base class used for serializing objects.
Definition TBuffer.h:43
Mother of all ROOT objects.
Definition TObject.h:41