text.cc (8296:be7f03723412) | text.cc (8514:57c96df312a1) |
---|---|
1/* 2 * Copyright (c) 2004-2005 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 567 unchanged lines hidden (view full) --- 576} 577 578void 579Text::visit(const FormulaInfo &info) 580{ 581 visit((const VectorInfo &)info); 582} 583 | 1/* 2 * Copyright (c) 2004-2005 The Regents of The University of Michigan 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions are 7 * met: redistributions of source code must retain the above copyright 8 * notice, this list of conditions and the following disclaimer; --- 567 unchanged lines hidden (view full) --- 576} 577 578void 579Text::visit(const FormulaInfo &info) 580{ 581 visit((const VectorInfo &)info); 582} 583 |
584/* 585 This struct implements the output methods for the sparse 586 histogram stat 587*/ 588struct SparseHistPrint 589{ 590 string name; 591 string separatorString; 592 string desc; 593 Flags flags; 594 bool descriptions; 595 int precision; 596 597 const SparseHistData &data; 598 599 SparseHistPrint(const Text *text, const SparseHistInfo &info); 600 void init(const Text *text, const Info &info); 601 void operator()(ostream &stream) const; 602}; 603 604/* Call initialization function */ 605SparseHistPrint::SparseHistPrint(const Text *text, const SparseHistInfo &info) 606 : data(info.data) 607{ 608 init(text, info); 609} 610 611/* Initialization function */ 612void 613SparseHistPrint::init(const Text *text, const Info &info) 614{ 615 name = info.name; 616 separatorString = info.separatorString; 617 desc = info.desc; 618 flags = info.flags; 619 precision = info.precision; 620 descriptions = text->descriptions; 621} 622 623/* Grab data from map and write to output stream */ 624void 625SparseHistPrint::operator()(ostream &stream) const 626{ 627 string base = name + separatorString; 628 629 ScalarPrint print; 630 print.precision = precision; 631 print.flags = flags; 632 print.descriptions = descriptions; 633 print.desc = desc; 634 print.pdf = NAN; 635 print.cdf = NAN; 636 637 print.name = base + "samples"; 638 print.value = data.samples; 639 print(stream); 640 641 MCounter::const_iterator it; 642 for (it = data.cmap.begin(); it != data.cmap.end(); it++) { 643 stringstream namestr; 644 namestr << base; 645 646 namestr <<(*it).first; 647 print.name = namestr.str(); 648 print.value = (*it).second; 649 print(stream); 650 } 651 652 print.pdf = NAN; 653 print.cdf = NAN; 654 655 print.name = base + "total"; 656 print.value = total; 657 print(stream); 658} 659 660void 661Text::visit(const SparseHistInfo &info) 662{ 663 if (noOutput(info)) 664 return; 665 666 SparseHistPrint print(this, info); 667 print(*stream); 668} 669 |
|
584Output * 585initText(const string &filename, bool desc) 586{ 587 static Text text; 588 static bool connected = false; 589 590 if (!connected) { 591 text.open(*simout.find(filename)); 592 text.descriptions = desc; 593 connected = true; 594 } 595 596 return &text; 597} 598 599} // namespace Stats | 670Output * 671initText(const string &filename, bool desc) 672{ 673 static Text text; 674 static bool connected = false; 675 676 if (!connected) { 677 text.open(*simout.find(filename)); 678 text.descriptions = desc; 679 connected = true; 680 } 681 682 return &text; 683} 684 685} // namespace Stats |