BRAT 2.4.5
Class index
Full class index
brahmlib
BRAHMS
ROOT page
////////////////////////////////////////////////////////////
//
// BrCreationID is a bookkeeping class that stores some  
// key information about the creation of a BrDataObject
//
////////////////////////////////////////////////////////////

//
// $Id: BrCreationID.cxx,v 1.1.1.1 2001/06/21 14:54:58 hagel Exp $
// $Author: hagel $
// $Date: 2001/06/21 14:54:58 $
//
#include "BrCreationID.h"
#include <iostream.h>
#ifndef WIN32
#include <sys/types.h>
#include <unistd.h>
#include <pwd.h>
#endif
#ifndef ROOT_TSystem
#include "TSystem.h"
#endif
#ifndef _BRDEBUG
#define _BRDEBUG
#endif 
#undef _BRDEBUG

//____________________________________________________________________
ClassImp(BrCreationID);

//____________________________________________________________________
 BrCreationID::BrCreationID()
{
// Default constructor. Does nothing.
// Don't use this constructor unless you have to and know
// what you are doing
// Use BrCreationID(TObject *Creator) instead.
#ifdef _BRDEBUG
  cout << "BrCreationID() : ctor " << endl;
#endif

  fUserID = 0; 
}

//____________________________________________________________________
 BrCreationID::BrCreationID(TObject *Creator)
{
  // Constructor. Fills the data members of the BrCreationID
  // based on the TObject pointer and some TSystem calls
#ifdef _BRDEBUG
  cout << "BrCreationID(Creator) : ctor " << endl;
#endif
  fUserID                = 0;
  
  if(!Creator)
    Error("BrCreationID", "No creator specified");
  else {
    TClass *cl = Creator->Class();
    fCreatorClassVersion = cl->GetClassVersion();
    fCreatorClassName    = cl->GetName();
#ifndef WIN32
    fUserID              = getuid();
#endif
    fHost                = gSystem->GetHostByName(gSystem->HostName()); 
    // sprintf(HostName,"%s",gSystem->HostName());
    // fHost = new TInetAddress(gSystem->GetHostByName(&HostName[0]));
  }
}

//____________________________________________________________________
 BrCreationID::~BrCreationID()
{
  // Destructor. Delete BrCreationID 
#ifdef _BRDEBUG
  cout << "BrCreationID : dtor " << endl;
#endif
}

//____________________________________________________________________
 void BrCreationID::Print(Option_t* option) const 
{
  // Print creator information. 
  cout << "Creator information: " << endl;

  // Print time of creation 
  cout << "  " << flush;
  fTime.Print(); 

  // Print creator class info 
  cout << "  Creator class " << fCreatorClassName.Data() 
       << " version " << fCreatorClassVersion << endl;

  // Print host name 
  cout << "  " << flush;
  fHost.Print();
  
  // Print user information (not that this depends on executing
  // host). 
  cout << "  User ID: " << fUserID << flush;
  if (fUserID > 0) {
#ifndef WIN32 
    TString
      localhost(gSystem->GetHostByName(gSystem->HostName()).GetName());  
    
    // Only try to get the user name if on the same machine as the one
    // that created this object. 
    if (!localhost.CompareTo(fHost.GetName())) {
      struct passwd* pw = getpwuid (fUserID);
      if (pw)
	cout << "  [" << pw->pw_name << ", " 
	     << pw->pw_gecos << "]" << endl;
      else
	cout << "  [Unknown - not in database]" << endl;
    }
#endif
  }
  else {
#ifndef WIN32 
    cout << "  [Unknown]" << endl;
#else 
    cout << "  [Unknown - Windoze system]" << endl;
#endif    
  }
}
  
//  $Log: BrCreationID.cxx,v $
//  Revision 1.1.1.1  2001/06/21 14:54:58  hagel
//  Initial revision of brat2
//
//  Revision 1.5  2001/06/01 15:46:37  cholm
//  Fixed creation id class to be more clean.  Now sets the user name
//  (if avaliable) has a Print method.
//  PRint method in BrDataObject.
//  Print method in BrDataTable
//  Print method in BrEvent
//  Print method in BrEventNode
//
//  Revision 1.4  1998/08/14 21:26:24  videbaek
//  Some cleanup mods
//
//  Revision 1.3  1998/04/06 21:11:50  videbaek
//  Clean up and additions for Win95
//
//  Revision 1.2  1998/03/09 20:53:48  videbaek
//  Ensure that pointers are non-NULL before deleting
//
//  Revision 1.1.1.1  1998/03/04 21:32:48  brahmlib
//  Brat base
//
//

This page automatically generated by script docBrat by Christian Holm

Copyright ; 2002 BRAHMS Collaboration <brahmlib@rcf.rhic.bnl.gov>
Last Update on by

Validate HTML
Validate CSS