00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00012 #include <iostream>
00013 using namespace std;
00014
00015 #include <TUnixSystem.h>
00016
00017 #include "Dispatcher/DDSClientId.h"
00018 #include "MessageService/MsgService.h"
00019
00020 ClassImp(DDSClientId)
00021
00022 CVSID("$Id: DDSClientId.cxx,v 1.4 2007/08/24 05:23:48 schubert Exp $");
00023
00024 ostream& operator << (ostream& os, const DDSClientId& cid) {
00025 return cid.Print(os); }
00026
00027
00028 DDSClientId::DDSClientId(DDS::EClientType clienttype, string clientname) :
00029 fClientType(clienttype), fClientName(clientname),
00030 fUserName(""), fRealName(""), fHostName(""),fStartTime(0),
00031 fChildPid(0) {
00032
00033
00034 if ( fClientName.size() > 30 ) {
00035 fClientName.resize(30);
00036 MSG("DDS",Msg::kWarning) << "Client name exceeds 30 character limit."
00037 << "\nTruncated to "
00038 << fClientName.c_str() << endl;
00039 }
00040
00041
00042 UserGroup_t* usergrp = gSystem->GetUserInfo(gSystem->GetUid());
00043 if ( usergrp ) {
00044 fUserName = usergrp -> fUser;
00045 fRealName = usergrp -> fRealName;
00046 }
00047 else {
00048 MSG("DDS",Msg::kWarning)
00049 << "Failed to identify user info for client w/uid "
00050 << gSystem->GetUid() << "." << endl;
00051 }
00052 if ( usergrp ) delete usergrp; usergrp = 0;
00053
00054
00055 fHostName = gSystem->HostName();
00056
00057 }
00058
00059
00060 DDSClientId::~DDSClientId() {
00061
00062
00063 }
00064
00065
00066 void DDSClientId::Connected(int childpid) {
00067
00068
00069
00070
00071
00072 fChildPid = childpid;
00073 fStartTime = VldTimeStamp();
00074
00075 }
00076
00077
00078 std::ostream& DDSClientId::Print(std::ostream& os) const {
00079
00080
00081 VldTimeStamp currentTime;
00082 if ( fStartTime.GetSec() == 0 ) currentTime = VldTimeStamp(0);
00083
00084 os << fUserName.c_str()
00085 << " \"" << fRealName.c_str() << "\" "
00086 << fHostName.c_str() << " Type: "
00087 << DDS::AsString(fClientType);
00088
00089 if ( !fClientName.empty() ) os << "/" << fClientName.c_str();
00090
00091 if ( fChildPid ) {
00092 os << "\n CS pid " << fChildPid << " Start: "
00093 << fStartTime.AsString("s") << " UpTime(sec): "
00094 << (currentTime-fStartTime).GetSec() << "." << endl;
00095 }
00096 else
00097 os << endl;
00098
00099
00100 return os;
00101
00102 }
00103
00104
00105 void DDSClientId::Print(Option_t* ) const {
00106
00107
00108 Print(std::cout);
00109
00110 }
00111
00112
00113
00114
00115
00116
00117