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 99 of file ProfParse.cc.

Constructor & Destructor Documentation

Reader::Reader ( int  fd)
inlineexplicit

Definition at line 102 of file ProfParse.cc.

102 :fd_(fd) { }
int fd_
Definition: ProfParse.cc:105
tuple fd
Definition: ztee.py:136

Member Function Documentation

bool Reader::nextSample ( VoidVec vv)

Definition at line 108 of file ProfParse.cc.

References ecal_dqm_sourceclient-live_cfg::cerr, fd_, and SiPixelLorentzAngle_cfi::read.

Referenced by writeProfileData().

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

Member Data Documentation

int Reader::fd_
private

Definition at line 105 of file ProfParse.cc.

Referenced by nextSample().