Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
ValueChecking.h
Go to the documentation of this file.
1/*
2 * ValueChecking.h
3 *
4 * Created on: 03.08.2020
5 * Author: shageboeck
6 */
7
8#ifndef ROOFIT_ROOFITCORE_INC_VALUECHECKING_H_
9#define ROOFIT_ROOFITCORE_INC_VALUECHECKING_H_
10
11#include <TSystem.h>
12
13#include <exception>
14#include <vector>
15#include <string>
16#include <sstream>
17
18class CachingError : public std::exception {
19 public:
20 CachingError(const std::string& newMessage)
21 {
22 _messages.push_back(newMessage);
23 }
24
25 CachingError(CachingError&& previous, const std::string& newMessage) :
26 _messages{std::move(previous._messages)}
27 {
28 _messages.push_back(newMessage);
29 }
30
31 const char* what() const noexcept override {
32 std::stringstream out;
33 out << "**Computation/caching error** in\n";
34
35 std::string indent;
36 for (auto it = _messages.rbegin(); it != _messages.rend(); ++it) {
37 std::string message = *it;
38 auto pos = message.find('\n', 0);
39 while (pos != std::string::npos) {
40 message.insert(pos+1, indent);
41 pos = (message.find('\n', pos+1));
42 }
43
44 out << indent << message << "\n";
45 indent += " ";
46 }
47
48 out << std::endl;
49
50 std::string* ret = new std::string(out.str()); //Make it survive this method
51
52 return ret->c_str();
53 }
54
55
56 private:
57 std::vector<std::string> _messages;
58};
59
60
62 public:
63 template <class T,
64 typename std::enable_if<std::is_base_of<RooAbsArg, T>::value>::type* = nullptr >
65 FormatPdfTree& operator<<(const T& arg) {
66 _stream << arg.ClassName() << "::" << arg.GetName() << " " << &arg << " ";
67 arg.printArgs(_stream);
68 return *this;
69 }
70
71 template <class T,
72 typename std::enable_if< ! std::is_base_of<RooAbsArg, T>::value>::type* = nullptr >
73 FormatPdfTree& operator<<(const T& arg) {
74 _stream << arg;
75 return *this;
76 }
77
78 operator std::string() const {
79 return _stream.str();
80 }
81
82 std::ostream& stream() {
83 return _stream;
84 }
85
86 private:
87 std::ostringstream _stream;
88};
89
90
91
92#endif /* ROOFIT_ROOFITCORE_INC_VALUECHECKING_H_ */
static void indent(ostringstream &buf, int indent_level)
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
const char * what() const noexcept override
CachingError(CachingError &&previous, const std::string &newMessage)
CachingError(const std::string &newMessage)
std::vector< std::string > _messages
std::ostringstream _stream
std::ostream & stream()
FormatPdfTree & operator<<(const T &arg)