CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
Reader Class Reference

Public Member Functions

bool nextSample (VoidVec &vv)
 
 Reader (int fd)
 

Private Attributes

int fd_
 

Detailed Description

Definition at line 98 of file ProfParse.cc.

Constructor & Destructor Documentation

Reader::Reader ( int  fd)
inlineexplicit

Definition at line 101 of file ProfParse.cc.

101 :fd_(fd) { }
int fd_
Definition: ProfParse.cc:104

Member Function Documentation

bool Reader::nextSample ( VoidVec vv)

Definition at line 107 of file ProfParse.cc.

References dtNoiseDBValidation_cfg::cerr, fd_, pos, and SiPixelLorentzAngle_cfi::read.

Referenced by writeProfileData().

108 {
109  unsigned int cnt;
110  int sz = read(fd_,&cnt,sizeof(unsigned int));
111 
112  if(sz<0) {
113  perror("Reader::nextSample: read count");
114  std::cerr << "could not read next sample from profile data\n";
115  return false;
116  }
117  if(sz == 0) return false;
118  if((unsigned)sz<sizeof(unsigned int)) {
119  std::cerr << "Reader::nextSample: "
120  << "could not read the correct amount of profile data\n";
121  return false;
122  }
123  if(cnt > 1000) {
124  std::cerr << "Reader::nextSample: stack length is nonsense " << cnt << "\n";
125  return false;
126  }
127 
128  vv.resize(cnt);
129  void** pos = &vv[0];
130  int byte_cnt = cnt*sizeof(void*);
131 
132  while((sz = read(fd_,pos,byte_cnt)) < byte_cnt) {
133  if(sz < 0) {
134  perror("Reader::nextSample: read stack");
135  std::cerr << "could not read stack\n";
136  return false;
137  }
138  byte_cnt -= sz;
139  pos += sz;
140  }
141  return true;
142 }
int fd_
Definition: ProfParse.cc:104

Member Data Documentation

int Reader::fd_
private

Definition at line 104 of file ProfParse.cc.

Referenced by nextSample().