Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
TGSimpleTableInterface.cxx
Go to the documentation of this file.
1// Author: Roel Aaij 15/08/2007
2
3/*************************************************************************
4 * Copyright (C) 1995-2007, Rene Brun and Fons Rademakers. *
5 * All rights reserved. *
6 * *
7 * For the licensing terms see $ROOTSYS/LICENSE. *
8 * For the list of contributors see $ROOTSYS/README/CREDITS. *
9 *************************************************************************/
10
12#include "TGResourcePool.h"
13#include "TError.h"
14
16
17//////////////////////////////////////////////////////////////////////////
18// //
19// TGSimpleTableInterface //
20// //
21// TGSimpleTableInterface is a very simple implementation of a //
22// TVirtualTableInterface. This interface provides a TGTable with data //
23// from a two dimensional array of doubles in memory. It is mostly //
24// meant as an example implementation for a TVirtualTableInterface. //
25// //
26//////////////////////////////////////////////////////////////////////////
27
28////////////////////////////////////////////////////////////////////////////////
29/// TGSimpleTableInterfac constructor.
30
32 UInt_t nrows, UInt_t ncolumns)
33 : TVirtualTableInterface(), fData(data), fNRows(nrows), fNColumns(ncolumns)
34{
35}
36
37////////////////////////////////////////////////////////////////////////////////
38/// TGSimpleTableInterface destructor.
39
41{
42}
43
44////////////////////////////////////////////////////////////////////////////////
45/// Return the value of the double in row,column of the data.
46
48{
49 if ((row > fNRows) || (column > fNColumns)) {
50 Error("TGSimpleTableInterface","Non existing value requested.");
51 return 0;
52 }
53 if (fData == nullptr) {
54 Error("TGSimpleTableInterface","Non existing table data.");
55 return 0;
56 }
57 return fData[row][column];
58}
59
60////////////////////////////////////////////////////////////////////////////////
61/// Return the value of the double in row,column of the data as a string.
62
64{
65 // FIXME use template string for string format instead of hardcoded format
66
67 fBuffer.Form("%5.2f", GetValue(row, column));
68 return fBuffer.Data();
69}
70
71////////////////////////////////////////////////////////////////////////////////
72/// Return a name for the header at row.
73
75{
76 fBuffer.Form("DRow %d", row);
77 return fBuffer.Data();
78}
79
80////////////////////////////////////////////////////////////////////////////////
81/// Return a name for the header at column.
82
84{
85 fBuffer.Form("DCol %d", column);
86 return fBuffer.Data();
87}
double Double_t
Definition RtypesCore.h:59
#define ClassImp(name)
Definition Rtypes.h:364
void Error(const char *location, const char *msgfmt,...)
Use this function in case an error occurred.
Definition TError.cxx:187
const char * GetValueAsString(UInt_t row, UInt_t column) override
Return the value of the double in row,column of the data as a string.
virtual ~TGSimpleTableInterface()
TGSimpleTableInterface destructor.
TGSimpleTableInterface(Double_t **data, UInt_t nrows=2, UInt_t ncolumns=2)
TGSimpleTableInterfac constructor.
Double_t GetValue(UInt_t row, UInt_t column) override
Return the value of the double in row,column of the data.
const char * GetRowHeader(UInt_t row) override
Return a name for the header at row.
const char * GetColumnHeader(UInt_t column) override
Return a name for the header at column.
const char * Data() const
Definition TString.h:369
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition TString.cxx:2309