Logo ROOT  
Reference Guide
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
11#include "TClass.h"
12#include "Riostream.h"
13#include "TSystem.h"
14#include "TEnv.h"
16#include "TGResourcePool.h"
17#include "TError.h"
18
20
21//////////////////////////////////////////////////////////////////////////
22// //
23// TGSimpleTableInterface //
24// //
25// TGSimpleTableInterface is a very simple implementation of a //
26// TVirtualTableInterface. This interface provides a TGTable with data //
27// from a two dimensional array of doubles in memory. It is mostly //
28// meant as an example implementation for a TVirtualTableInterface. //
29// //
30//////////////////////////////////////////////////////////////////////////
31
32////////////////////////////////////////////////////////////////////////////////
33/// TGSimpleTableInterfac constructor.
34
36 UInt_t nrows, UInt_t ncolumns)
37 : TVirtualTableInterface(), fData(data), fNRows(nrows), fNColumns(ncolumns)
38{
39}
40
41////////////////////////////////////////////////////////////////////////////////
42/// TGSimpleTableInterface destructor.
43
45{
46}
47
48////////////////////////////////////////////////////////////////////////////////
49/// Return the value of the double in row,column of the data.
50
52{
53 if ((row > fNRows) || (column > fNColumns)) {
54 Error("TGSimpleTableInterface","Non existing value requested.");
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:57
#define ClassImp(name)
Definition: Rtypes.h:361
void Error(const char *location, const char *msgfmt,...)
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:364
void Form(const char *fmt,...)
Formats a string using a printf style format descriptor.
Definition: TString.cxx:2289