ROOT logo
/*****************************************************************************
 * Project: RooFit                                                           *
 * Package: RooFitCore                                                       *
 * @(#)root/roofitcore:$Id: RooList.cxx 24278 2008-06-15 15:21:16Z wouter $
 * 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)             *
 *****************************************************************************/

//////////////////////////////////////////////////////////////////////////////
//
// BEGIN_HTML
// A RooList is a TList with extra support for working with options
// that are associated with each node. This is a utility class for RooPlot
// END_HTML
//

#include "RooFit.h"

#include "RooList.h"
#include "RooList.h"
#include "RooMsgService.h"

#include "Riostream.h"

ClassImp(RooList)



//_____________________________________________________________________________
TObjOptLink *RooList::findLink(const char *name, const char *caller) const 
{
  // Find the link corresponding to the named object in this list.
  // Return 0 if the object is not found or does not have an Option_t
  // string associated with its link. Also print a warning message
  // if caller is non-zero.

  if(0 == strlen(name)) return 0;
  TObjLink *link = FirstLink();
  while (link) {
    TObject *obj= link->GetObject();
    if (obj->GetName() && !strcmp(name, obj->GetName())) break;
    link = link->Next();
  }
  if(0 == link) {
    if(strlen(caller)) {
      coutE(InputArguments) << caller << ": cannot find object named \"" << name << "\"" << endl;
    }
    return 0;
  }
  return dynamic_cast<TObjOptLink*>(link);
}


//_____________________________________________________________________________
Bool_t RooList::moveBefore(const char *before, const char *target, const char *caller) 
{
  // Move the target object immediately before the specified object,
  // preserving any Option_t associated with the target link.

  // Find the target object's link
  TObjOptLink *targetLink= findLink(target,caller);
  if(0 == targetLink) return kFALSE;

  // Find the insert-before object's link
  TObjOptLink *beforeLink= findLink(before,caller);
  if(0 == beforeLink) return kFALSE;

  // Remember the target link's object and options
  TObject *obj= targetLink->GetObject();
  TString opt= targetLink->GetOption();

  // Remove the target object in its present position
  Remove(targetLink);

  // Add it back in its new position
  if(beforeLink == fFirst) {
    RooList::AddFirst(obj, opt.Data());
  }
  else {
    NewOptLink(obj, opt.Data(), beforeLink->Prev());
    fSize++;
    Changed();
  }
  return kTRUE;
}


//_____________________________________________________________________________
Bool_t RooList::moveAfter(const char *after, const char *target, const char *caller) 
{
  // Move the target object immediately after the specified object,
  // preserving any Option_t associated with the target link.

  // Find the target object's link
  TObjOptLink *targetLink= findLink(target,caller);
  if(0 == targetLink) return kFALSE;

  // Find the insert-after object's link
  TObjOptLink *afterLink= findLink(after,caller);
  if(0 == afterLink) return kFALSE;

  // Remember the target link's object and options
  TObject *obj= targetLink->GetObject();
  TString opt= targetLink->GetOption();

  // Remove the target object in its present position
  Remove(targetLink);

  // Add it back in its new position
  if(afterLink == fLast) {
    RooList::AddLast(obj, opt.Data());
  }
  else {
    NewOptLink(obj, opt.Data(), afterLink);
    fSize++;
    Changed();
  }
  return kTRUE;
}
 RooList.cxx:1
 RooList.cxx:2
 RooList.cxx:3
 RooList.cxx:4
 RooList.cxx:5
 RooList.cxx:6
 RooList.cxx:7
 RooList.cxx:8
 RooList.cxx:9
 RooList.cxx:10
 RooList.cxx:11
 RooList.cxx:12
 RooList.cxx:13
 RooList.cxx:14
 RooList.cxx:15
 RooList.cxx:16
 RooList.cxx:17
 RooList.cxx:18
 RooList.cxx:19
 RooList.cxx:20
 RooList.cxx:21
 RooList.cxx:22
 RooList.cxx:23
 RooList.cxx:24
 RooList.cxx:25
 RooList.cxx:26
 RooList.cxx:27
 RooList.cxx:28
 RooList.cxx:29
 RooList.cxx:30
 RooList.cxx:31
 RooList.cxx:32
 RooList.cxx:33
 RooList.cxx:34
 RooList.cxx:35
 RooList.cxx:36
 RooList.cxx:37
 RooList.cxx:38
 RooList.cxx:39
 RooList.cxx:40
 RooList.cxx:41
 RooList.cxx:42
 RooList.cxx:43
 RooList.cxx:44
 RooList.cxx:45
 RooList.cxx:46
 RooList.cxx:47
 RooList.cxx:48
 RooList.cxx:49
 RooList.cxx:50
 RooList.cxx:51
 RooList.cxx:52
 RooList.cxx:53
 RooList.cxx:54
 RooList.cxx:55
 RooList.cxx:56
 RooList.cxx:57
 RooList.cxx:58
 RooList.cxx:59
 RooList.cxx:60
 RooList.cxx:61
 RooList.cxx:62
 RooList.cxx:63
 RooList.cxx:64
 RooList.cxx:65
 RooList.cxx:66
 RooList.cxx:67
 RooList.cxx:68
 RooList.cxx:69
 RooList.cxx:70
 RooList.cxx:71
 RooList.cxx:72
 RooList.cxx:73
 RooList.cxx:74
 RooList.cxx:75
 RooList.cxx:76
 RooList.cxx:77
 RooList.cxx:78
 RooList.cxx:79
 RooList.cxx:80
 RooList.cxx:81
 RooList.cxx:82
 RooList.cxx:83
 RooList.cxx:84
 RooList.cxx:85
 RooList.cxx:86
 RooList.cxx:87
 RooList.cxx:88
 RooList.cxx:89
 RooList.cxx:90
 RooList.cxx:91
 RooList.cxx:92
 RooList.cxx:93
 RooList.cxx:94
 RooList.cxx:95
 RooList.cxx:96
 RooList.cxx:97
 RooList.cxx:98
 RooList.cxx:99
 RooList.cxx:100
 RooList.cxx:101
 RooList.cxx:102
 RooList.cxx:103
 RooList.cxx:104
 RooList.cxx:105
 RooList.cxx:106
 RooList.cxx:107
 RooList.cxx:108
 RooList.cxx:109
 RooList.cxx:110
 RooList.cxx:111
 RooList.cxx:112
 RooList.cxx:113
 RooList.cxx:114
 RooList.cxx:115
 RooList.cxx:116
 RooList.cxx:117
 RooList.cxx:118
 RooList.cxx:119
 RooList.cxx:120
 RooList.cxx:121
 RooList.cxx:122
 RooList.cxx:123
 RooList.cxx:124
 RooList.cxx:125
 RooList.cxx:126
 RooList.cxx:127