// Author: Thomas Hadig (Group EB SLAC Stanford CA USA)
// Last update: $Date: 2003/08/22 19:15:06 $
// Copyright: Thomas Hadig, hadig@slac.stanford.edu
#ifndef __CRTCRATE_CXX
#define __CRTCRATE_CXX
////////////////////////////////////////////////////////////////////////////////
//
// Cosmic Ray Telescope Data Aquisition Software
//
// abstract class for a controler/crate.
//
////////////////////////////////////////////////////////////////////////////////
#include <gendriver/crate.hh>
namespace CRT
{
//{{{}}}
//{{{ constructor
CrtCrate::CrtCrate()
{
// default constructor
fNumberBoards=0;
fBoards=(const CrtBoard **)0;
}
//}}}
//{{{ constructor CrtCrate(const Char_t *inName)
CrtCrate::CrtCrate(const Char_t *inName) : TNamed(inName, inName)
{
// default constructor
fNumberBoards=0;
fBoards=(const CrtBoard **)0;
}
//}}}
//{{{ destructor
CrtCrate::~CrtCrate()
{
// destructor
if (fBoards!=(const CrtBoard **)0)
{
delete [] fBoards;
fBoards = (const CrtBoard **)0;
}
}
//}}}
//{{{ AddBoard
void CrtCrate::AddBoard(const CrtBoard *inBoard)
{
// adds a board to the crate
// inBoard: pointer to the board object
if (inBoard==(const CrtBoard *)0) return;
if (fBoards!=(const CrtBoard **)0)
//{{{ increase baord array size
{
fNumberBoards++;
const CrtBoard **newPointer = new (const CrtBoard *)[fNumberBoards];
Int_t i=0;
while (i<fNumberBoards-1)
{
newPointer[i] = fBoards[i];
i++;
}
delete [] fBoards;
fBoards = newPointer;
}
//}}}
else
//{{{ create board array
{
fNumberBoards=1;
fBoards = new (const CrtBoard *)[1];
}
//}}}
fBoards[fNumberBoards-1]=inBoard;
}
//}}}
//{{{ RemoveBoard
void CrtCrate::RemoveBoard(const CrtBoard *inBoard)
{
// removes a board to the crate
// inBoard: pointer to the board object
if (inBoard==(const CrtBoard *)0) return;
if (fBoards==(const CrtBoard **)0) return;
Int_t i=0;
while (i<fNumberBoards)
{
if (fBoards[i]==inBoard)
//{{{ remove this baord
{
if (fNumberBoards<=1)
{
delete [] fBoards;
fBoards = (const CrtBoard **)0;
fNumberBoards = 0;
return;
}
const CrtBoard **newPointer = new (const CrtBoard *)[fNumberBoards-1];
Int_t j=0;
while (j<i)
{
newPointer[j] = fBoards[j];
j++;
}
i++;
while (i<fNumberBoards)
{
newPointer[i-1] = fBoards[i];
i++;
}
delete [] fBoards;
fBoards=newPointer;
fNumberBoards--;
return;
}
//}}}
i++;
}
return;
}
//}}}
//{{{ GetBoard
const CrtBoard *CrtCrate::GetBoard(Int_t inNumber) const
{
// returns pointer to the board with the identifier inNumber
// numbers are consequtive and might change after a call to
// RemoveBoard. Please note: this is NOT the board ID/crate slot
if ((inNumber<0)||(inNumber>=fNumberBoards)) return (const CrtBoard *)0;
return fBoards[inNumber];
}
//}}}
}
ClassImp(CRT::CrtCrate) //generic description of a controler/crate
#endif
ROOT page - Class index - Class Hierarchy - Top of the page
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.