Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/RooLinkedListElem.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*****************************************************************************
0002  * Project: RooFit                                                           *
0003  * Package: RooFitCore                                                       *
0004  *    File: $Id: RooLinkedListElem.h,v 1.11 2007/05/11 09:11:30 verkerke Exp $
0005  * Authors:                                                                  *
0006  *   WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu       *
0007  *   DK, David Kirkby,    UC Irvine,         dkirkby@uci.edu                 *
0008  *                                                                           *
0009  * Copyright (c) 2000-2005, Regents of the University of California          *
0010  *                          and Stanford University. All rights reserved.    *
0011  *                                                                           *
0012  * Redistribution and use in source and binary forms,                        *
0013  * with or without modification, are permitted according to the terms        *
0014  * listed in LICENSE (http://roofit.sourceforge.net/license.txt)             *
0015  *****************************************************************************/
0016 #ifndef ROO_LINKED_LIST_ELEM
0017 #define ROO_LINKED_LIST_ELEM
0018 
0019 #include "Rtypes.h"
0020 
0021 class TObject ;
0022 class RooLinkedListElem ;
0023 class TBuffer ;
0024 
0025 /// \cond ROOFIT_INTERNAL
0026 
0027 namespace RooLinkedListImplDetails {
0028     class Chunk;
0029     class Pool;
0030 }
0031 
0032 /// \endcond
0033 
0034 class RooLinkedListElem {
0035 public:
0036   // Initial element constructor
0037   RooLinkedListElem() = default;
0038 
0039   void init(TObject* arg, RooLinkedListElem* after=nullptr) {
0040    _arg = arg ;
0041    _refCount = 1 ;
0042 
0043    if (after) {
0044      _prev = after ;
0045      _next = after->_next ;
0046      after->_next = this ;
0047      if (_next) {
0048        _next->_prev = this ;
0049      }
0050    }
0051  }
0052 
0053  void release() {
0054    if (_prev) _prev->_next = _next ;
0055    if (_next) _next->_prev = _prev ;
0056    _prev = nullptr ;
0057    _next = nullptr ;
0058  }
0059 
0060   /// Constructor with payload.
0061   RooLinkedListElem(TObject *arg) : _arg(arg), _refCount(1) {}
0062 
0063   RooLinkedListElem(TObject* arg, RooLinkedListElem* after) :
0064     // Constructor with payload and next chain element
0065     _prev(after), _next(after->_next), _arg(arg), _refCount(1) {
0066 
0067     // Insert self in link
0068     after->_next = this ;
0069     if (_next) _next->_prev = this ;
0070   }
0071 
0072   // Destructor
0073   virtual ~RooLinkedListElem() {
0074     // Remove self from link
0075     if (_prev) _prev->_next = _next ;
0076     if (_next) _next->_prev = _prev ;
0077   }
0078 
0079   Int_t refCount() const { return _refCount ; }
0080   Int_t incRefCount() { return ++_refCount ; }
0081   Int_t decRefCount() { return --_refCount ; }
0082 
0083 protected:
0084   friend class RooLinkedList ;
0085   friend class RooLinkedListImplDetails::Pool;
0086   friend class RooLinkedListImplDetails::Chunk;
0087   friend class RooLinkedListIterImpl ;
0088   friend class RooFIterForLinkedList ;
0089   RooLinkedListElem* _prev = nullptr; ///< Link to previous element in list
0090   RooLinkedListElem* _next = nullptr; ///< Link to next element in list
0091   TObject*   _arg = nullptr;          ///< Link to contents
0092   Int_t      _refCount = 0;           ///<! Reference count
0093 
0094 protected:
0095 
0096   // Forbidden
0097   RooLinkedListElem(const RooLinkedListElem&) ;
0098 
0099   ClassDef(RooLinkedListElem,1) // Element of RooLinkedList container class
0100 } ;
0101 
0102 
0103 
0104 #endif