StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StSstPackageList.cc
1 //$Id: StSstPackageList.cc,v 1.1 2015/06/23 16:26:20 jeromel Exp $
2 //
3 //$Log: StSstPackageList.cc,v $
4 //Revision 1.1 2015/06/23 16:26:20 jeromel
5 //First version created from the SSD code and reshaped
6 //
7 //Revision 1.1 2015/04/19 17:30:32 bouchet
8 //initial commit ; SST codes
9 //
10 
11 //fork from the SSD code, move along - see history therein
12 
13 #include "StSstPackageList.hh"
14 
15 StSstPackageList::StSstPackageList()
16 {
17  mListLengthP = 0;
18  mFirstPackage = 0;
19  mLastPackage = 0;
20 }
21 
22 StSstPackageList::~StSstPackageList()
23 {
24  if (mListLengthP)
25  {
26  StSstPackage *ptr = mLastPackage;
27  StSstPackage *toDele;
28  while (mListLengthP)
29  {
30  toDele = ptr;
31  ptr = prev(ptr);
32  delete toDele;
33  mListLengthP--;
34  }
35  }
36 }
37 
38 StSstPackage* StSstPackageList::next(StSstPackage *ptr)
39 { return ptr->getNextPackage(); }
40 
41 StSstPackage* StSstPackageList::prev(StSstPackage *ptr)
42 { return ptr->getPrevPackage(); }
43 
44 StSstPackage* StSstPackageList::first()
45 { return mFirstPackage; }
46 
47 StSstPackage* StSstPackageList::last()
48 { return mLastPackage; }
49 
50 Int_t StSstPackageList::getSize()
51 { return mListLengthP; }
52 
53 
54 Int_t StSstPackageList::addNewPackage(StSstPackage *ptr)
55 {
56  if (!ptr) return 0;
57  if (mListLengthP == 0)
58  {
59  ptr->setPrevPackage(0);
60  ptr->setNextPackage(0);
61  mFirstPackage = ptr;
62  mLastPackage = ptr;
63  }
64  else
65  {
66  ptr->setPrevPackage(mLastPackage);
67  ptr->setNextPackage(0);
68  mLastPackage->setNextPackage(ptr);
69  mLastPackage = ptr;
70  }
71  mListLengthP++;
72  return 1;
73 }
74 
75 StSstPackageList::StSstPackageList(const StSstPackageList & originalPackageList)
76 {
77  mListLengthP = originalPackageList.mListLengthP;
78  mFirstPackage = originalPackageList.mFirstPackage;
79  mLastPackage = originalPackageList.mLastPackage;
80 }
81 
82 StSstPackageList& StSstPackageList::operator=(const StSstPackageList originalPackageList)
83 {
84  mListLengthP = originalPackageList.mListLengthP;
85  mFirstPackage = originalPackageList.mFirstPackage;
86  mLastPackage = originalPackageList.mLastPackage;
87 
88  return *this;
89 }