ROOT logo
/*****************************************************************************
 * Project: RooFit                                                           *
 * Package: RooFitCore                                                       *
 *    File: $Id: RooLinkedListElem.h,v 1.11 2007/05/11 09:11:30 verkerke Exp $
 * Authors:                                                                  *
 *   WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu       *
 *   DK, David Kirkby,    UC Irvine,         dkirkby@uci.edu                 *
 *                                                                           *
 * Copyright (c) 2000-2005, Regents of the University of California          *
 *                          and Stanford University. All rights reserved.    *
 *                                                                           *
 * Redistribution and use in source and binary forms,                        *
 * with or without modification, are permitted according to the terms        *
 * listed in LICENSE (http://roofit.sourceforge.net/license.txt)             *
 *****************************************************************************/
#ifndef ROO_LINKED_LIST_ELEM
#define ROO_LINKED_LIST_ELEM

#include "Rtypes.h"

class TObject ;
class RooLinkedListElem ;
class TBuffer ;

namespace RooLinkedListImplDetails {
    class Chunk;
    class Pool;
}

class RooLinkedListElem {
public:
  // Initial element ctor
  RooLinkedListElem() :
    _prev(0), _next(0), _arg(0), _refCount(0) {
  }
   
  void init(TObject* arg, RooLinkedListElem* after=0) {
   _arg = arg ;
   _refCount = 1 ;

   if (after) {
     _prev = after ;
     _next = after->_next ;
     after->_next = this ;
     if (_next) {
       _next->_prev = this ;
     }     
   }
 }
 
 void release() {
   if (_prev) _prev->_next = _next ;
   if (_next) _next->_prev = _prev ;   
   _prev = 0 ;
   _next = 0 ;
 }

  RooLinkedListElem(TObject* arg) : 
    // Constructor with payload
    _prev(0), _next(0), _arg(arg), _refCount(1) {
  }

  RooLinkedListElem(TObject* arg, RooLinkedListElem* after) : 
    // Constructor with payload and next chain element
    _prev(after), _next(after->_next), _arg(arg), _refCount(1) {

    // Insert self in link
    after->_next = this ;
    if (_next) _next->_prev = this ;
  }

  // Destructor
  virtual ~RooLinkedListElem() {    
    // Remove self from link
    if (_prev) _prev->_next = _next ;
    if (_next) _next->_prev = _prev ;
  }

  Int_t refCount() const { return _refCount ; }
  Int_t incRefCount() { return ++_refCount ; }
  Int_t decRefCount() { return --_refCount ; }

protected:
  friend class RooHashTable ;
  friend class RooLinkedList ;
  friend class RooLinkedListImplDetails::Pool;
  friend class RooLinkedListImplDetails::Chunk;
  friend class RooLinkedListIter ;
  friend class RooFIter ;
  RooLinkedListElem* _prev ; // Link to previous element in list
  RooLinkedListElem* _next ; // Link to next element in list
  TObject*   _arg ;          // Link to contents
  Int_t      _refCount ;     //! Reference count

protected:

  // Forbidden
  RooLinkedListElem(const RooLinkedListElem&) ;

  ClassDef(RooLinkedListElem,1) // Element of RooLinkedList container class
} ;



#endif
 RooLinkedListElem.h:1
 RooLinkedListElem.h:2
 RooLinkedListElem.h:3
 RooLinkedListElem.h:4
 RooLinkedListElem.h:5
 RooLinkedListElem.h:6
 RooLinkedListElem.h:7
 RooLinkedListElem.h:8
 RooLinkedListElem.h:9
 RooLinkedListElem.h:10
 RooLinkedListElem.h:11
 RooLinkedListElem.h:12
 RooLinkedListElem.h:13
 RooLinkedListElem.h:14
 RooLinkedListElem.h:15
 RooLinkedListElem.h:16
 RooLinkedListElem.h:17
 RooLinkedListElem.h:18
 RooLinkedListElem.h:19
 RooLinkedListElem.h:20
 RooLinkedListElem.h:21
 RooLinkedListElem.h:22
 RooLinkedListElem.h:23
 RooLinkedListElem.h:24
 RooLinkedListElem.h:25
 RooLinkedListElem.h:26
 RooLinkedListElem.h:27
 RooLinkedListElem.h:28
 RooLinkedListElem.h:29
 RooLinkedListElem.h:30
 RooLinkedListElem.h:31
 RooLinkedListElem.h:32
 RooLinkedListElem.h:33
 RooLinkedListElem.h:34
 RooLinkedListElem.h:35
 RooLinkedListElem.h:36
 RooLinkedListElem.h:37
 RooLinkedListElem.h:38
 RooLinkedListElem.h:39
 RooLinkedListElem.h:40
 RooLinkedListElem.h:41
 RooLinkedListElem.h:42
 RooLinkedListElem.h:43
 RooLinkedListElem.h:44
 RooLinkedListElem.h:45
 RooLinkedListElem.h:46
 RooLinkedListElem.h:47
 RooLinkedListElem.h:48
 RooLinkedListElem.h:49
 RooLinkedListElem.h:50
 RooLinkedListElem.h:51
 RooLinkedListElem.h:52
 RooLinkedListElem.h:53
 RooLinkedListElem.h:54
 RooLinkedListElem.h:55
 RooLinkedListElem.h:56
 RooLinkedListElem.h:57
 RooLinkedListElem.h:58
 RooLinkedListElem.h:59
 RooLinkedListElem.h:60
 RooLinkedListElem.h:61
 RooLinkedListElem.h:62
 RooLinkedListElem.h:63
 RooLinkedListElem.h:64
 RooLinkedListElem.h:65
 RooLinkedListElem.h:66
 RooLinkedListElem.h:67
 RooLinkedListElem.h:68
 RooLinkedListElem.h:69
 RooLinkedListElem.h:70
 RooLinkedListElem.h:71
 RooLinkedListElem.h:72
 RooLinkedListElem.h:73
 RooLinkedListElem.h:74
 RooLinkedListElem.h:75
 RooLinkedListElem.h:76
 RooLinkedListElem.h:77
 RooLinkedListElem.h:78
 RooLinkedListElem.h:79
 RooLinkedListElem.h:80
 RooLinkedListElem.h:81
 RooLinkedListElem.h:82
 RooLinkedListElem.h:83
 RooLinkedListElem.h:84
 RooLinkedListElem.h:85
 RooLinkedListElem.h:86
 RooLinkedListElem.h:87
 RooLinkedListElem.h:88
 RooLinkedListElem.h:89
 RooLinkedListElem.h:90
 RooLinkedListElem.h:91
 RooLinkedListElem.h:92
 RooLinkedListElem.h:93
 RooLinkedListElem.h:94
 RooLinkedListElem.h:95
 RooLinkedListElem.h:96
 RooLinkedListElem.h:97
 RooLinkedListElem.h:98
 RooLinkedListElem.h:99
 RooLinkedListElem.h:100
 RooLinkedListElem.h:101
 RooLinkedListElem.h:102
 RooLinkedListElem.h:103
 RooLinkedListElem.h:104
 RooLinkedListElem.h:105