00001 //-------------------------------------------------------------------------- 00002 // File and Version Information: 00003 // $Id: TrkId.cxx,v 1.1.1.1 2005/04/21 06:01:42 zhangy Exp $ 00004 // 00005 // Description: 00006 // Implementation of TrkId class. Not a whole lot here. 00007 // 00008 // Environment: 00009 // Software developed for the BaBar Detector at the SLAC B-Factory. 00010 // 00011 // Authors: 00012 // 00013 // Copyright (C) 1996 The Board of Trustees of 00014 // The Leland Stanford Junior University. All Rights Reserved. 00015 //------------------------------------------------------------------------ 00016 //#include "BaBar/BaBar.hh" 00017 #include "TrkBase/TrkId.h" 00018 #include <assert.h> 00019 #include "TrkBase/TrkIdManager.h" 00020 #include <iostream> 00021 00022 // Ctors 00023 //------------------------------------------------------------------------ 00024 TrkId::TrkId(long myval, TrkIdManager* man) : _value(myval), _idman(man) { 00025 //------------------------------------------------------------------------ 00026 } 00027 00028 //------------------------------------------------------------------------ 00029 TrkId::TrkId(TrkIdManager* man) : _value(man->nextId()), _idman(man) { 00030 //------------------------------------------------------------------------ 00031 } 00032 00033 //------------------------------------------------------------------------ 00034 TrkId::~TrkId() { 00035 //------------------------------------------------------------------------ 00036 } 00037 00038 // Copy ctor 00039 //------------------------------------------------------------------------ 00040 TrkId::TrkId(const TrkId &rhs) { 00041 //------------------------------------------------------------------------ 00042 _idman = rhs.idManager(); 00043 _value = rhs._value; 00044 } 00045 00046 //------------------------------------------------------------------------ 00047 TrkId& 00048 TrkId::operator= (const TrkId& rhs) { 00049 //------------------------------------------------------------------------ 00050 _idman = rhs.idManager(); 00051 _value = rhs._value; 00052 return *this; 00053 } 00054 00055 //------------------------------------------------------------------------ 00056 bool 00057 TrkId::operator<(const TrkId& other) const { 00058 /* if (*idManager() == *(other.idManager()) && _value < other._value) { 00059 return true; 00060 } 00061 else { 00062 if (idManager() < other.idManager()) { 00063 return true; 00064 } 00065 else 00066 return false; 00067 }*/ 00068 std::cout << " TrkId::operator<(const TrkId& other) const needs to be checked " << std::endl; 00069 if(_value < other._value) return true; 00070 return false; 00071 } 00072 //------------------------------------------------------------------------ 00073 00074 00075 //------------------------------------------------------------------------ 00076 void 00077 TrkId::setNewValue(const TrkId& source) { 00078 //------------------------------------------------------------------------ 00079 _idman = source.idManager(); 00080 assert (_idman != 0); 00081 _value = idManager()->nextId(); 00082 } 00083 00084 //------------------------------------------------------------------------ 00085 TrkIdManager* 00086 TrkId::idManager() const { 00087 //------------------------------------------------------------------------ 00088 return _idman; 00089 } 00090 00091 //------------------------------------------------------------------------ 00092 void 00093 TrkId::setIdManager(TrkIdManager* idMan){ 00094 //------------------------------------------------------------------------ 00095 _idman = idMan; 00096 }