CMS 3D CMS Logo

Public Member Functions | Private Attributes

Reader Class Reference

List of all members.

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) [inline, explicit]

Definition at line 101 of file ProfParse.cc.

:fd_(fd) { }

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().

{
  unsigned int cnt;
  int sz = read(fd_,&cnt,sizeof(unsigned int));

  if(sz<0) {
      perror("Reader::nextSample: read count");
      std::cerr << "could not read next sample from profile data\n";
      return false;
  }
  if(sz == 0) return false;
  if((unsigned)sz<sizeof(unsigned int)) {
      std::cerr << "Reader::nextSample: "
           << "could not read the correct amount of profile data\n";
      return false;
  }
  if(cnt > 1000) {
      std::cerr << "Reader::nextSample: stack length is nonsense " << cnt << "\n";
      return false;
  }
  
  vv.resize(cnt);
  void** pos = &vv[0];
  int byte_cnt = cnt*sizeof(void*);

  while((sz = read(fd_,pos,byte_cnt)) < byte_cnt) {
      if(sz < 0) {
          perror("Reader::nextSample: read stack");
          std::cerr << "could not read stack\n";
          return false;
      }
      byte_cnt -= sz;
      pos += sz;
  }
  return true;
}

Member Data Documentation

int Reader::fd_ [private]

Definition at line 104 of file ProfParse.cc.

Referenced by nextSample().