GSI Object Oriented Online Offline (Go4)  GO4-6.3.0
TGo4ExampleController.cxx
Go to the documentation of this file.
1 // $Id$
2 //-----------------------------------------------------------------------
3 // The GSI Online Offline Object Oriented (Go4) Project
4 // Experiment Data Processing at EE department, GSI
5 //-----------------------------------------------------------------------
6 // Copyright (C) 2000- GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
7 // Planckstr. 1, 64291 Darmstadt, Germany
8 // Contact: http://go4.gsi.de
9 //-----------------------------------------------------------------------
10 // This software can be used under the license agreements as stated
11 // in Go4License.txt file which is part of the distribution.
12 //-----------------------------------------------------------------------
13 
14 #include "TGo4ExampleController.h"
15 
16 #include <iostream>
17 #include "TCanvas.h"
18 
19 #include "TGo4Log.h"
20 #include "TGo4Status.h"
21 
22 #include "TGo4ComAction1.h"
23 
25 {
26  GO4TRACE((15,"TGo4ExampleController::TGo4ExampleController() constructor",__LINE__, __FILE__));
27  fxCanvas = new TCanvas("Example Display","Go4 controller canvas",3);
28 }
29 
31 {
32  GO4TRACE((15,"TGo4ExampleController::~TGo4ExampleController() destructor",__LINE__, __FILE__));
33  delete fxPreviousData;
34  delete fxCanvas;
35 }
36 
38 {
39  GO4TRACE((12,"TGo4ExampleController::DisplayData(TNamed*)",__LINE__, __FILE__));
40  if (data) {
41  delete fxPreviousData;
42  fxPreviousData = data;
43  std::cout << "ExampleController received data object:" << std::endl;
44  std::cout << "Classname:" << data->ClassName() << ", Name:"
45  << data->GetName() << std::endl;
46  fxCanvas->cd();
47  fxPreviousData->Draw();
48  fxCanvas->Modified();
49  fxCanvas->Update();
50  } else {
51  std::cout << "ExampleController has NULL data object" << std::endl;
52  }
53 }
54 
56 {
57  GO4TRACE((12,"TGo4ExampleController::DisplayLog(TGo4Status *)",__LINE__, __FILE__));
58  if (status) {
59  std::cout << "ExampleController received status object:" << std::endl;
60  if (status->InheritsFrom("TGo4ExampleClientStatus")) {
61  status->Print(); // display client status object
62  } else {
63  std::cout << status->GetName() << std::endl; // status message
64  }
65  delete status; // avoid memory leak
66  } else {
67  std::cout << "ExampleController has NULL status object" << std::endl;
68  }
69 }
70 
72 {
73  GO4TRACE((12,"TGo4ExampleController::GetCommand()",__LINE__, __FILE__));
74  // this function simulates a user input of a command, e.g. using a cli or a gui
75  TGo4Command *com = new TGo4ComAction1();
76  return com;
77 }
void Print(Option_t *opt="") const override
Definition: TGo4Status.cxx:46
#define GO4TRACE(X)
Definition: TGo4Log.h:25
void DisplayLog(TGo4Status *)