#include <quick_log.hxx>

Public Member Functions

 ~QuickLog ()
 

Static Public Member Functions

static const String GetName ()
 eg https://cs.chromium.org/chromium/src/gpu/config/software_rendering_list_json.cc More...
 
static bool WriteInfo (Writer &writer)
 
static bool WriteDoc (Writer &writer)
 
static bool WriteSrc (Writer &writer)
 
static OstreamBuild (Ostream &os, Options opts, const IT &begin, const IT &end, const int offset=0)
 
static WriterBuild (Writer &writer, Options opts, const IT &begin, const IT &end, const int offset=0)
 

Private Member Functions

 QuickLog (Ostream &os)
 
QuickLog operator= (QuickLog &)
 
bool Write (Options opts, const IT &begin, const IT &end, const int offset)
 

Static Private Member Functions

static bool Write (Writer &writer, Options opts, const IT &begin, const IT &end, const int offset)
 
static bool WriteParameters (Writer &writer, Options opts, const IT &begin, const IT &end, const int offset)
 
static bool WriteComputation (Writer &writer, const IT &begin, const IT &end, const int offset)
 

Private Attributes

std::unique_ptr< Streamstream
 
std::unique_ptr< Writerwriter
 

Detailed Description

template<typename IT, typename Compare = std::less_equal<typename std::iterator_traits<IT>::value_type>>
class SHA_Logger::QuickLog< IT, Compare >

Definition at line 39 of file quick_log.hxx.

Constructor & Destructor Documentation

template<typename IT , typename Compare = std::less_equal<typename std::iterator_traits<IT>::value_type>>
SHA_Logger::QuickLog< IT, Compare >::~QuickLog ( )
inline

Definition at line 58 of file quick_log.hxx.

58 { assert(this->writer->IsComplete()); }
std::unique_ptr< Writer > writer
Definition: quick_log.hxx:168
template<typename IT , typename Compare = std::less_equal<typename std::iterator_traits<IT>::value_type>>
SHA_Logger::QuickLog< IT, Compare >::QuickLog ( Ostream os)
inlineprivate

Definition at line 85 of file quick_log.hxx.

85  : stream(std::unique_ptr<Stream>(new Stream(os))),
86  writer(std::unique_ptr<Writer>(new Writer(*this->stream))) {}
std::unique_ptr< Writer > writer
Definition: quick_log.hxx:168
rapidjson::OStreamWrapper Stream
Definition: typedef.hxx:32
std::unique_ptr< Stream > stream
Definition: quick_log.hxx:167
rapidjson::PrettyWriter< Stream > Writer
Definition: typedef.hxx:33

Member Function Documentation

template<typename IT , typename Compare = std::less_equal<typename std::iterator_traits<IT>::value_type>>
static Ostream& SHA_Logger::QuickLog< IT, Compare >::Build ( Ostream os,
Options  opts,
const IT &  begin,
const IT &  end,
const int  offset = 0 
)
inlinestatic

Instantiate a new json writer using the stream passed as argument, run and write algorithm computation information.

Returns
stream reference filled up with QuickLog object information, error object information in case of failure.

Definition at line 65 of file quick_log.hxx.

66  {
67  std::unique_ptr<QuickLog> builder = std::unique_ptr<QuickLog>(new QuickLog(os));
68  builder->Write(opts, begin, end, offset);
69 
70  return os;
71  }
QuickLog(Ostream &os)
Definition: quick_log.hxx:85
template<typename IT , typename Compare = std::less_equal<typename std::iterator_traits<IT>::value_type>>
static Writer& SHA_Logger::QuickLog< IT, Compare >::Build ( Writer writer,
Options  opts,
const IT &  begin,
const IT &  end,
const int  offset = 0 
)
inlinestatic

Use json writer passed as parameter to write iterator information.

Returns
stream reference filled up with QuickLog object information, error information in case of failure.

Definition at line 77 of file quick_log.hxx.

78  {
79  Write(writer, opts, begin, end, offset);
80 
81  return writer;
82  }
std::unique_ptr< Writer > writer
Definition: quick_log.hxx:168
bool Write(Options opts, const IT &begin, const IT &end, const int offset)
Definition: quick_log.hxx:89
template<typename IT , typename Compare = std::less_equal<typename std::iterator_traits<IT>::value_type>>
static const String SHA_Logger::QuickLog< IT, Compare >::GetName ( )
inlinestatic

eg https://cs.chromium.org/chromium/src/gpu/config/software_rendering_list_json.cc

Definition at line 43 of file quick_log.hxx.

43 { return "Quick_Sort"; }
template<typename IT , typename Compare = std::less_equal<typename std::iterator_traits<IT>::value_type>>
QuickLog SHA_Logger::QuickLog< IT, Compare >::operator= ( QuickLog< IT, Compare > &  )
inlineprivate

Definition at line 87 of file quick_log.hxx.

87 {} // Not Implemented
template<typename IT , typename Compare = std::less_equal<typename std::iterator_traits<IT>::value_type>>
bool SHA_Logger::QuickLog< IT, Compare >::Write ( Options  opts,
const IT &  begin,
const IT &  end,
const int  offset 
)
inlineprivate

Definition at line 89 of file quick_log.hxx.

90  { return Write(*this->writer, opts, begin, end, offset); }
std::unique_ptr< Writer > writer
Definition: quick_log.hxx:168
bool Write(Options opts, const IT &begin, const IT &end, const int offset)
Definition: quick_log.hxx:89
template<typename IT , typename Compare = std::less_equal<typename std::iterator_traits<IT>::value_type>>
static bool SHA_Logger::QuickLog< IT, Compare >::Write ( Writer writer,
Options  opts,
const IT &  begin,
const IT &  end,
const int  offset 
)
inlinestaticprivate

Definition at line 92 of file quick_log.hxx.

93  {
94  // Do not write sequence if no data to be processed
95  const int _seqSize = static_cast<int>(std::distance(begin, end));
96  if (_seqSize < 2)
97  {
98  Comment::Build(writer, "Sequence size too small to be processed.", 0);
99  Operation::Return<bool>(writer, true);
100  return true;
101  }
102 
103  writer.StartObject();
104 
105  // Write description
107 
108  // Write parameters
109  WriteParameters(writer, opts, begin, end, offset);
110 
111  // Write computation
112  WriteComputation(writer, begin, end, offset);
113 
114  writer.EndObject();
115 
116  return true;
117  }
static Ostream & Build(Ostream &os, const String &message, int level=0, const String extent="normal")
Definition: comment.hxx:43
static bool WriteComputation(Writer &writer, const IT &begin, const IT &end, const int offset)
Definition: quick_log.hxx:141
static Ostream & Build(Ostream &os, Options opts)
Definition: algorithm.hxx:39
std::unique_ptr< Writer > writer
Definition: quick_log.hxx:168
static bool WriteParameters(Writer &writer, Options opts, const IT &begin, const IT &end, const int offset)
Definition: quick_log.hxx:120
template<typename IT , typename Compare = std::less_equal<typename std::iterator_traits<IT>::value_type>>
static bool SHA_Logger::QuickLog< IT, Compare >::WriteComputation ( Writer writer,
const IT &  begin,
const IT &  end,
const int  offset 
)
inlinestaticprivate

Definition at line 141 of file quick_log.hxx.

142  {
143  const auto _pivotIdx = rand() % static_cast<const int>(std::distance(begin, end));
144 
145  // Local logged variables
146  writer.Key("locals");
147  writer.StartArray();
148  auto pivot = Iterator::BuildIt<IT>(writer, kSeqName, "pivot", offset + _pivotIdx, begin + _pivotIdx,
149  "Pick Random Pivot within [begin, end]");
150  writer.EndArray();
151 
152  writer.Key("logs");
153  writer.StartArray();
154  // Proceed partition
155  auto newPivot = PartitionLog<IT, Compare>::Build(writer, OpIsSub, begin, pivot, end, offset);
156  auto newOffset = offset + std::distance(begin, newPivot);
157 
158  // Recurse on first partition
159  QuickLog<IT, Compare>::Build(writer, OpIsSub, begin, newPivot, offset);
160  // Recurse on second partition
161  QuickLog<IT, Compare>::Build(writer, OpIsSub, newPivot + 1, end, newOffset + 1);
162  writer.EndArray();
163 
164  return true;
165  }
static Ostream & Build(Ostream &os, Options opts, const IT &begin, const IT &end, const int offset=0)
Definition: quick_log.hxx:65
std::unique_ptr< Writer > writer
Definition: quick_log.hxx:168
static const std::string kSeqName
Definition: typedef.hxx:41
static IT Build(Ostream &os, Options opts, const IT &begin, const IT &pivot, const IT &end, const int offSet=0)
template<typename IT , typename Compare = std::less_equal<typename std::iterator_traits<IT>::value_type>>
static bool SHA_Logger::QuickLog< IT, Compare >::WriteDoc ( Writer writer)
inlinestatic

Write algorithm decription

Todo:
Use string litteral for JSON description within c++ code

Definition at line 51 of file quick_log.hxx.

51 { return true; }
template<typename IT , typename Compare = std::less_equal<typename std::iterator_traits<IT>::value_type>>
static bool SHA_Logger::QuickLog< IT, Compare >::WriteInfo ( Writer writer)
inlinestatic

Write algorithm information

Todo:
Use string litteral for JSON description within c++ code

Definition at line 47 of file quick_log.hxx.

47 { return true; }
template<typename IT , typename Compare = std::less_equal<typename std::iterator_traits<IT>::value_type>>
static bool SHA_Logger::QuickLog< IT, Compare >::WriteParameters ( Writer writer,
Options  opts,
const IT &  begin,
const IT &  end,
const int  offset 
)
inlinestaticprivate

Definition at line 120 of file quick_log.hxx.

122  {
123  writer.Key("parameters");
124  writer.StartArray();
125  if (opts & OpIsSub)
126  {
127  const int _seqSize = static_cast<int>(std::distance(begin, end));
128  Iterator::Build(writer, kSeqName, "begin", offset);
129  Iterator::Build(writer, kSeqName, "end", offset + _seqSize);
130  }
131  else
132  {
133  Array<IT>::Build(writer, kSeqName, "begin", begin, "end", end);
134  }
135  writer.EndArray();
136 
137  return true;
138  }
std::unique_ptr< Writer > writer
Definition: quick_log.hxx:168
static Ostream & Build(Ostream &os, const String &name, const String &beginName, const IT &begin, const String &endName, const IT &end)
Definition: array.hxx:42
static Ostream & Build(Ostream &os, const String &parentId, const String &name, int index, const String &comment="")
Definition: iterator.hxx:43
static const std::string kSeqName
Definition: typedef.hxx:41
template<typename IT , typename Compare = std::less_equal<typename std::iterator_traits<IT>::value_type>>
static bool SHA_Logger::QuickLog< IT, Compare >::WriteSrc ( Writer writer)
inlinestatic

Write algorithm sources

Todo:
Use string litteral for JSON description within c++ code

Definition at line 55 of file quick_log.hxx.

55 { return true; }

Member Data Documentation

template<typename IT , typename Compare = std::less_equal<typename std::iterator_traits<IT>::value_type>>
std::unique_ptr<Stream> SHA_Logger::QuickLog< IT, Compare >::stream
private

Definition at line 167 of file quick_log.hxx.

template<typename IT , typename Compare = std::less_equal<typename std::iterator_traits<IT>::value_type>>
std::unique_ptr<Writer> SHA_Logger::QuickLog< IT, Compare >::writer
private

Definition at line 168 of file quick_log.hxx.


The documentation for this class was generated from the following file: