// $Id: BrEventNode.cxx,v 1.9 1998/08/20 14:28:18 hagel Exp $
// $Log: BrEventNode.cxx,v $
// Revision 1.9 1998/08/20 14:28:18 hagel
// Add Copy method + cleanup
//
// Revision 1.8 1998/08/14 21:26:25 videbaek
// Some cleanup mods
//
// Revision 1.7 1998/08/05 15:40:29 hagel
// Add Clear to BrEventNode
//
// Revision 1.6 1998/07/03 16:01:53 hagel
// Clean up g++ warnings
//
// Revision 1.5 1998/04/30 17:12:18 videbaek
// Added functionality to BrIOModule
//
// Revision 1.3 1998/03/09 20:53:50 videbaek
// Ensure that pointers are non-NULL before deleting
//
// Revision 1.2 1998/03/06 22:09:59 videbaek
// Working update
//
// Revision 1.1.1.1 1998/03/04 21:32:48 brahmlib
// Brat base
//
//
// Author: F.Videbaek
//
#include "BrEventNode.h"
#include "BrDataTable.h"
//
// Root classes
//
#include "TBuffer.h"
#include <iostream.h>
////////////////////////////////////////////////////////////
//
// BrEventNode is a BRAHMS data class providing storage and
// access function for event data information. The data
// is stored in BrDataObject objects that are kept inside
// a THashList (or TObjArray).
// This allows modification of the BrEvent content by the
// user, with the BrDataObject providing a standard interface
// for information retrieval, bookkeeping and I/O selection.
//
////////////////////////////////////////////////////////////
//
//
// Note the use of HashTables. This will be most efficient to access data by name
// This should be chekced out carefully, and performence measured.
//
ClassImp(BrEventNode)
BrEventNode::BrEventNode()
{
// Constructor. Set counter and list data members to zero.
// Don't use this constructor unless you have to and know
// what you are doing
// Use BrEventNode(Char_t Name) instead
fObjectList = NULL;
fVerbose = 0;
}
BrEventNode::BrEventNode(Char_t* Name) : BrDataObject(Name)
{
// Constructor. Create the hash table
// for storing the data objects for this event. Set the
// eventnode name
// fObjectList = new THashTable();
fObjectList = new TObjArray();
fVerbose = 0;
}
BrEventNode::~BrEventNode()
{
// Destructor. Delete BrEventNode and all the data objects
// currently owned by BrEventNode.
// It is assumed but not checked that all member in the lower nodes are also deleted.
//
#ifdef _BRDEBUG
cout << "BrEventNode: dtor" << endl;
#endif
if(fObjectList){
fObjectList->Delete();
#ifdef _BRDEBUG
cout << " delete fObjectList " << endl;
#endif
delete fObjectList;
}
}
Int_t BrEventNode::AddObject(BrDataObject *Object)
{
// Add a BrDataObejct to the EventNode. The object can be simple,
// or an EventNode..
//
fObjectList->Add(Object);
if(fVerbose)
{
printf("Add data Object %s, total # of Objects %dn",
Object->GetName(),
fObjectList->GetSize());
}
return fObjectList->GetSize();
}
BrDataTable* BrEventNode::GetDataTable(Char_t *Name)
{
// Get a pointer to a BrDataObject with the given Name in the node or lower in the tree.
// Only the first occurence of an object with a specified name is returned
// Recursive calls are made if EventNodes are part of the list.
//
TIter next(fObjectList);
BrDataObject *object;
while ((object = (BrDataObject*)next())){
if (!strcmp(Name, object->GetName())) return (BrDataTable* ) object;
if(object->IsNode()){
object = ((BrEventNode*) object)->GetObject(Name);
if(object != NULL) return (BrDataTable*) object;
}
}
return 0;
}
BrDataObject *BrEventNode::GetObject(Char_t *Name)
{
// Get a pointer to a BrDataObject with the given Name in the node or lower in the tree.
// Only the first occurence of an object with a specified name is returned
// Recursive calls are made if EventNodes are part of the list.
//
TIter next(fObjectList);
BrDataObject *object;
while ((object = (BrDataObject*)next())){
if (!strcmp(Name, object->GetName())) return (BrDataObject* ) object;
if(object->IsNode()){
object = ((BrEventNode*) object)->GetObject(Name);
if(object != NULL) return object;
}
}
return 0;
}
void BrEventNode::Clear()
{
if(fObjectList) fObjectList->Clear();
}
void BrEventNode::ListObjects()
{
// List on standard out a summary of BrDataObjects in the EventNode.
// The listing is recursive. All levels are scanned.
//
BrDataObject *object;
Int_t num = 0;
TIter NextObject(fObjectList);
while((object = (BrDataObject*)NextObject()))
{
IndentLevel();
cout << num << " - " << object << " - " << object->GetName() << " - " << object->GetTitle() << endl;
if(object->IsNode()){
IncreaseDirLevel();
((BrEventNode*) object)->ListObjects();
DecreaseDirLevel();
}
num++;
}
}
void BrEventNode::Copy(BrEventNode &eventnode) {
BrDataObject::Copy(eventnode);
eventnode.fVerbose = fVerbose;
if(fObjectList) {
TObjArray *objlist = eventnode.GetObjectList();
if(objlist) {
for(Int_t i=0;i<fObjectList->GetEntries();i++) {
objlist->Add(fObjectList->At(i));
}
}
}
/*
fVerbose = eventnode.fVerbose;
TObjArray *objlist = eventnode.GetObjectList();
if(objlist) {
if(!fObjectList) fObjectList = new TObjArray();
for(Int_t i=0;i<objlist->GetEntries();i++) {
fObjectList->Add(objlist->At(i));
}
}
*/
}
/*
//______________________________________________________________________________
void BrEventNode::Streamer(TBuffer &R__b)
{
// Stream an object of class BrEvent.
if (R__b.IsReading()) {
Version_t R__v = R__b.ReadVersion();
BrDataObject::Streamer(R__b);
R__b >> fVerbose;
R__b >> fObjectList;
} else {
R__b.WriteVersion(BrEventNode::IsA());
BrDataObject::Streamer(R__b);
R__b << fVerbose;
// make a temporary hashtable for the objects marked
// as persistent and store only those in the output
// buffer. Since this is a node iterative calls should probably be
// implemented. What has to be done for BrEvent that is a derived
// Class ?
//
THashTable *temp = new THashTable();
TIter NextObject(fObjectList);
TObject *obj;
while(obj = NextObject())
{
temp->Add(obj);
}
R__b << temp;
temp->Clear();
delete temp;
}
}
*/
ROOT page - Class index - 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.