Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
ValueChecking.h
Go to the documentation of this file.
1/// \cond ROOFIT_INTERNAL
2
3/*
4 * ValueChecking.h
5 *
6 * Created on: 03.08.2020
7 * Author: shageboeck
8 */
9
10#ifndef ROOFIT_ROOFITCORE_INC_VALUECHECKING_H_
11#define ROOFIT_ROOFITCORE_INC_VALUECHECKING_H_
12
13#include <TSystem.h>
14
15#include <exception>
16#include <vector>
17#include <string>
18#include <sstream>
19
20class CachingError : public std::exception {
21 public:
22 CachingError(const std::string& newMessage)
23 {
24 _messages.push_back(newMessage);
25 }
26
27 CachingError(CachingError&& previous, const std::string& newMessage) :
29 {
30 _messages.push_back(newMessage);
31 }
32
33 const char* what() const noexcept override {
34 std::stringstream out;
35 out << "**Computation/caching error** in\n";
36
37 std::string indent;
38 for (auto it = _messages.rbegin(); it != _messages.rend(); ++it) {
39 std::string message = *it;
40 auto pos = message.find('\n', 0);
41 while (pos != std::string::npos) {
42 message.insert(pos+1, indent);
43 pos = (message.find('\n', pos+1));
44 }
45
46 out << indent << message << "\n";
47 indent += " ";
48 }
49
50 out << std::endl;
51
52 std::string* ret = new std::string(out.str()); //Make it survive this method
53
54 return ret->c_str();
55 }
56
57
58 private:
59 std::vector<std::string> _messages;
60};
61
62
63class FormatPdfTree {
64 public:
65 template <class T,
66 typename std::enable_if<std::is_base_of<RooAbsArg, T>::value>::type* = nullptr >
67 FormatPdfTree& operator<<(const T& arg) {
68 _stream << arg.ClassName() << "::" << arg.GetName() << " " << &arg << " ";
69 arg.printArgs(_stream);
70 return *this;
71 }
72
73 template <class T,
74 typename std::enable_if< ! std::is_base_of<RooAbsArg, T>::value>::type* = nullptr >
75 FormatPdfTree& operator<<(const T& arg) {
76 _stream << arg;
77 return *this;
78 }
79
80 operator std::string() const {
81 return _stream.str();
82 }
83
84 std::ostream& stream() {
85 return _stream;
86 }
87
88 private:
89 std::ostringstream _stream;
90};
91
92
93
94#endif /* ROOFIT_ROOFITCORE_INC_VALUECHECKING_H_ */
95
96/// \endcond
TBuffer & operator<<(TBuffer &buf, const Tmpl *obj)
Definition TBuffer.h:397
static void indent(ostringstream &buf, int indent_level)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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
static const char * what
Definition stlLoader.cc:5