1 //===-- Results.h -----------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef __PerfTestDriver_Results_h__
11 #define __PerfTestDriver_Results_h__
13 #include "lldb/lldb-forward.h"
42 Result (Type type, const char *name, const char *description) :
49 if (description && description[0])
50 m_description = description;
59 Write (Results &results) = 0;
64 if (m_type == Type::Array)
71 if (m_type == Type::Dictionary)
72 return (Dictionary *)this;
78 if (m_type == Type::Double)
79 return (Double *)this;
86 if (m_type == Type::String)
87 return (String *)this;
93 if (m_type == Type::Unsigned)
94 return (Unsigned *)this;
103 return m_name.c_str();
107 GetDescription() const
109 if (m_description.empty())
111 return m_description.c_str();
122 std::string m_description;
126 typedef std::shared_ptr<Result> ResultSP;
128 class Array : public Result
131 Array (const char *name, const char *description) :
132 Result (Type::Array, name, description)
142 Append (const ResultSP &result_sp);
145 ForEach (const std::function <bool (const ResultSP &)> &callback);
148 Write (Results &results)
152 typedef std::vector<ResultSP> collection;
156 class Dictionary : public Result
160 Result (Type::Dictionary, NULL, NULL)
164 Dictionary (const char *name, const char *description) :
165 Result (Type::Dictionary, name, description)
175 Write (Results &results)
180 ForEach (const std::function <bool (const std::string &, const ResultSP &)> &callback);
183 Add (const char *name, const char *description, const ResultSP &result_sp);
186 AddDouble (const char *name, const char *descriptiorn, double value);
189 AddUnsigned (const char *name, const char *description, uint64_t value);
192 AddString (const char *name, const char *description, const char *value);
196 typedef std::map<std::string, ResultSP> collection;
197 collection m_dictionary;
200 class String : public Result
203 String (const char *name, const char *description, const char *value) :
204 Result (Type::String, name, description),
207 if (value && value[0])
217 Write (Results &results)
224 return m_string.empty() ? NULL : m_string.c_str();
228 std::string m_string;
231 class Double : public Result
234 Double (const char *name, const char *description, double value) :
235 Result (Type::Double, name, description),
246 Write (Results &results)
260 class Unsigned : public Result
263 Unsigned (const char *name, const char *description, uint64_t value) :
264 Result (Type::Unsigned, name, description),
275 Write (Results &results)
305 Write (const char *path);
308 Dictionary m_results;
311 } // namespace lldb_perf
312 #endif // #ifndef __PerfTestDriver_Results_h__