VR-Forces Developer's Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
columnLogger.h
Go to the documentation of this file.
1 /*******************************************************************************
2 ** Copyright (c) 2015 MAK Technologies, Inc.
3 ** All rights reserved.
4 *******************************************************************************/
5 
8 
9 #pragma once
10 
11 #include <vrfutil/vrfutilDefines.h>
12 
14 #include <boost/noncopyable.hpp>
15 #include <boost/ptr_container/ptr_list.hpp>
16 
17 #include <tbb/spin_mutex.h>
18 #include <tbb/spin_rw_mutex.h>
19 
21 #include <iosfwd>
22 #include <list>
23 #include <map>
24 #include <sstream>
25 #include <string>
26 #include <vector>
27 
28 
29 class DT_DLL_vrfutil DtColumnLogger : boost::noncopyable
30 {
31 public:
32  explicit DtColumnLogger();
33 
34  ~DtColumnLogger();
35 
36  class DT_DLL_vrfutil Column : boost::noncopyable
37  {
38  public:
40  {
41  typedef std::list<Value> List;
42 
43  unsigned line;
44  double number;
45  unsigned calls;
46  unsigned precision;
47 
48  struct Parent
49  {
50  typedef std::vector<Parent> Sequence;
51 
52  const char* group;
53  double percent;
54 
55  explicit Parent(const char* g, double p)
56  : group(g), percent(p) { }
57  };
58 
60 
61  Value& setGroup(const char* n, double percent)
62  { parents.push_back(Parent(n,percent)); return *this; }
63  Value& addCalls(unsigned c) { calls += c; return *this; }
64  Value& setPrecision(unsigned p) { precision = p; return *this; }
65 
66  std::string str() const;
67 
68  explicit Value(double number, unsigned line);
69  };
70 
71  typedef boost::ptr_list<Column> Sequence;
72 
73  explicit Column(DtColumnLogger&, const std::string& label);
74  explicit Column(Column& parent, const std::string& label);
75 
76  Column& getColumn(const std::string& label, int index = -1);
77 
78  Value& addValue(double);
79 
80  template <typename T>
81  Value& addValue(T val)
82  {
83  return addValue(double(val)).setPrecision(3);
84  }
85 
87  void reset(bool resetWidth);
88 
89  int print(std::ostream* textstream, std::ostream* csvsteram, bool headers);
90 
92  unsigned width();
93  void updateWidth(unsigned, bool onlyIfGreater=true);
94 
95  Value::List& values() { return myValues; }
96  Sequence& subColumns() { return myColumns; }
97 
98  std::string label() const { return myLabel; }
99 
100  void markAsPrinted();
101  bool hasBeenPrinted();
102 
103  private:
104  typedef tbb::spin_rw_mutex Mutex;
105 
106  mutable Mutex myMutex;
108 
109  std::string myLabel;
111 
112  unsigned myMaxWidth;
113  bool myNewFlag;
114 
116  };
117 
118  Column& getColumn(const std::string& label, int index = -1)
119  {
120  return myRootColumn.getColumn(label, index);
121  }
122 
123  Column& getColumn(const char* label, int index = -1)
124  {
125  return getColumn(std::string(label), index);
126  }
127 
128  unsigned lineNumber() const;
129  void incrementLineNumber();
130 
132  void reset(bool resetWidth = false);
133 
135  void print();
136  void printText(const std::string&);
137 
138  void setOutput(const std::string& file);
139  void setTag(const std::string& tag);
140 
141 private:
142  void initFiles();
143 
144  unsigned myCurrentLine;
146 
148  std::string myTextOutputFile;
149  std::string myCSVOutputFile;
150  std::string myTag;
151 
152  std::ostream* myTextOutput;
153  std::ostream* myCSVOutput;
154 
155 };
const char * group
Definition: columnLogger.h:52
Column & getColumn(const std::string &label, int index=-1)
Definition: columnLogger.h:118
Parent::Sequence parents
Definition: columnLogger.h:59
Value::List & values()
Definition: columnLogger.h:95
Sequence myColumns
Definition: columnLogger.h:115
std::string myTextOutputFile
Definition: columnLogger.h:148
unsigned myCurrentLine
Definition: columnLogger.h:144
Column & getColumn(const char *label, int index=-1)
Definition: columnLogger.h:123
Definition: columnLogger.h:48
unsigned precision
Definition: columnLogger.h:46
Value & setPrecision(unsigned p)
Definition: columnLogger.h:64
unsigned myMaxWidth
Definition: columnLogger.h:112
Definition: columnLogger.h:36
unsigned myLinesSinceHeaderPrint
Definition: columnLogger.h:145
Sequence & subColumns()
Definition: columnLogger.h:96
tbb::spin_rw_mutex Mutex
Definition: columnLogger.h:104
void print(double **a, int r, int c, const char *str)
Definition: columnLogger.h:39
unsigned line
Definition: columnLogger.h:43
Column myRootColumn
Definition: columnLogger.h:147
IMGUI_API void Value(const char *prefix, bool b)
DtColumnLogger & myLogger
Definition: columnLogger.h:107
unsigned calls
Definition: columnLogger.h:45
double number
Definition: columnLogger.h:44
Column & getColumn(const std::string &label, int index=-1)
std::list< Value > List
Definition: columnLogger.h:41
std::vector< Parent > Sequence
Definition: columnLogger.h:50
bool myNewFlag
Definition: columnLogger.h:113
Value & setGroup(const char *n, double percent)
Definition: columnLogger.h:61
std::string myTag
Definition: columnLogger.h:150
boost::ptr_list< Column > Sequence
Definition: columnLogger.h:71
std::string myCSVOutputFile
Definition: columnLogger.h:149
Value & addValue(T val)
Definition: columnLogger.h:81
Third party includes.
Definition: columnLogger.h:29
Value::List myValues
Definition: columnLogger.h:110
#define DT_DLL_vrfutil
This file is used to determine how to build Disable inconsistent dll linkage warning Visual Studio 6...
Definition: vrfutilDefines.h:34
std::string label() const
Definition: columnLogger.h:98
std::ostream * myTextOutput
Definition: columnLogger.h:152
std::string myLabel
Definition: columnLogger.h:109
Value & addCalls(unsigned c)
Definition: columnLogger.h:63
std::ostream * myCSVOutput
Definition: columnLogger.h:153
double percent
Definition: columnLogger.h:53
Parent(const char *g, double p)
Definition: columnLogger.h:55
Mutex myMutex
Definition: columnLogger.h:106

Document ID: Generated on Thu Oct 23 22:29:17 EDT 2025 from SVN revision 280951
Copyright © 2005-2024 MAK Technologies. All Rights Reserved (www.mak.com)