27 #include <boost/lexical_cast.hpp>
57 unsigned long cminflt;
59 unsigned long cmajflt;
72 unsigned long startcode;
73 unsigned long endcode;
74 unsigned long startstack;
75 unsigned long kstkesp;
76 unsigned long kstkeip;
79 unsigned long sigignore;
88 friend Fetcher&
operator>>(Fetcher&,
unsigned int&);
89 friend Fetcher&
operator>>(Fetcher&,
unsigned long&);
90 friend Fetcher&
operator>>(Fetcher&,
unsigned long long&);
92 friend Fetcher&
operator>>(Fetcher&, std::string&);
94 explicit Fetcher(
char* buffer) :
97 delims_(
" \t\n\f\v\r") {
101 const char*
t = getItem();
103 return boost::lexical_cast<
int>(
t);
106 const char*
t = getItem();
108 return boost::lexical_cast<
long>(
t);
110 unsigned int getUInt() {
111 const char*
t = getItem();
113 return boost::lexical_cast<
unsigned int>(
t);
115 unsigned long getULong() {
116 const char*
t = getItem();
118 return boost::lexical_cast<
unsigned long>(
t);
120 unsigned long long getULongLong() {
121 const char*
t = getItem();
123 return boost::lexical_cast<
unsigned long long>(
t);
128 std::string getString() {
129 return std::string(getItem());
132 char* item = strtok_r(buffer_, delims_, &save_);
139 char const*
const delims_;
142 Fetcher&
operator>>(Fetcher& iFetch,
int& oValue) {
143 oValue = iFetch.getInt();
146 Fetcher&
operator>>(Fetcher& iFetch,
long& oValue) {
147 oValue = iFetch.getLong();
150 Fetcher&
operator>>(Fetcher& iFetch,
unsigned int& oValue) {
151 oValue = iFetch.getUInt();
154 Fetcher&
operator>>(Fetcher& iFetch,
unsigned long& oValue) {
155 oValue = iFetch.getULong();
158 Fetcher&
operator>>(Fetcher& iFetch,
unsigned long long& oValue) {
159 oValue = iFetch.getULongLong();
162 Fetcher&
operator>>(Fetcher& iFetch,
char& oValue) {
163 oValue = iFetch.getChar();
166 Fetcher&
operator>>(Fetcher& iFetch, std::string& oValue) {
167 oValue = iFetch.getString();
176 pg_size_(sysconf(_SC_PAGESIZE)) {
178 std::ostringstream ost;
179 ost <<
"/proc/" << getpid() <<
"/stat";
181 if((
fd_ = open(ost.str().c_str(), O_RDONLY)) < 0) {
183 <<
"Failed to open " << ost.str() << std::endl;
196 double pr_size = 0.0, pr_rssize = 0.0;
201 lseek(
fd_, 0, SEEK_SET);
204 perror(
"Read of Proc file failed:");
213 Fetcher fetcher(
buf_);
249 }
catch (boost::bad_lexical_cast& iE) {
250 LogWarning(
"ProcInfoFetcher")<<
"Parsing of Prof file failed:"<<iE.what()<<std::endl;
255 pr_size = (double)pinfo.vsize;
256 pr_rssize = (
double)pinfo.rss;
258 ret.
vsize = pr_size / (1024.0*1024.0);
259 ret.
rss = (pr_rssize *
pg_size_) / (1024.0*1024.0);
std::vector< Variable::Flags > flags
int getInt(ResultSet *rset, int ipar)
std::istream & operator>>(std::istream &input, CLHEP::HepGenMatrix &matrix)