GSI Object Oriented Online Offline (Go4)  GO4-6.3.0
TGo4Command.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 "TGo4Command.h"
15 
16 #include <iostream>
17 
18 #include "TGo4Log.h"
19 
21  {"NOMODE","Observer","Controller","Administrator"};
22 
23 
24 TGo4Command::TGo4Command(const char *name, const char *description, Int_t id) :
25  TNamed(name, "This is a TGo4Command")
26 {
27  GO4TRACE((12,"TGo4Command::TGo4Command(const char *name, const char *description, Int_t id)", __LINE__, __FILE__));
28  SetDescription(description);
29  SetReceiverName("NoNameReceiver");
30  SetTaskName("NoNameTask");
31  fiCommandID = id;
32  fiVersion = 1;
33  fbIsSynchron = kFALSE;
34  fbIsEnabled = kTRUE;
35  fbIsExclusive = kFALSE;
36  fbIsLocal = kFALSE;
39  fxReceiverBase = nullptr;
40 }
41 
43 {
44  GO4TRACE((12,"TGo4Command::TGo4Command()", __LINE__, __FILE__));
45  SetDescription("Default command");
46  SetReceiverName("NoNameReceiver");
47  SetTaskName("NoNameTask");
48  fiCommandID = -1;
49  fiVersion = 1;
50  fbIsSynchron = kFALSE;
51  fbIsEnabled = kTRUE;
52  fbIsExclusive = kFALSE;
53  fbIsLocal = kFALSE;
56  fxReceiverBase = nullptr;
57 }
58 
60 {
61  GO4TRACE((12,"TGo4Command::~TGo4Command()", __LINE__, __FILE__));
62 }
63 
65 {
66  GO4TRACE((10,"Int_t TGo4Command::GetCommandID() const ", __LINE__, __FILE__));
67  return fiCommandID;
68 }
69 
71 {
72  GO4TRACE((10,"void TGo4Command::Help()", __LINE__, __FILE__));
73 }
74 
75 Bool_t TGo4Command::IsEnabled() const
76 {
77  GO4TRACE((10,"Bool_t TGo4Command::IsEnabled() const", __LINE__, __FILE__));
78  return fbIsEnabled;
79 }
80 
82 {
83  GO4TRACE((10,"Bool_t TGo4Command::IsExclusive() const", __LINE__, __FILE__));
84  return fbIsExclusive;
85 }
86 
87 const char *TGo4Command::GetReceiverName() const
88 {
89  GO4TRACE((10,"const char *TGo4Command::GetReceiverName()", __LINE__, __FILE__));
90  return fxReceiverName.Data();
91 }
92 
93 void TGo4Command::SetReceiverName(const char *name)
94 {
95  GO4TRACE((10,"void TGo4Command::SetReceiverName(const char *)", __LINE__, __FILE__));
96  fxReceiverName = name;
97 }
98 
99 const char *TGo4Command::GetTaskName() const
100 {
101  GO4TRACE((10,"const char *TGo4Command::GetTaskName()", __LINE__, __FILE__));
102  return fxTaskName.Data();
103 }
104 
105 void TGo4Command::SetTaskName(const char *name)
106 {
107  GO4TRACE((10,"void TGo4Command::SetTaskName(const char *)", __LINE__, __FILE__));
108  fxTaskName=name;
109 }
110 
111 void TGo4Command::SetDescription(const char *txt)
112 {
113  GO4TRACE((10,"void TGo4Command::SetDescription(const char *)", __LINE__, __FILE__));
114  fxDescription = txt;
115 }
116 
117 const char *TGo4Command::What() const
118 {
119  GO4TRACE((10,"const char *TGo4Command::What()", __LINE__, __FILE__));
120  return fxDescription.Data();
121 }
122 
124 {
125  GO4TRACE((10,"Int_t TGo4Command::ExeCom()", __LINE__, __FILE__));
126  std::cout << What() << std::endl;
127  return 0;
128 }
129 
131 {
132  TGo4Log::Warn("Not allowed to execute %s in mode %d:%s",
133  GetName(), GetMode(), GetModeDescription(GetMode()));
134  return 0;
135 }
136 
137 Bool_t TGo4Command::Log(Int_t mode)
138 {
139  GO4TRACE((10,"Bool_t TGo4Command::Log(Int_t mode)", __LINE__, __FILE__));
140  switch (mode) {
141  case 0:
142  std::cout << What() << std::endl;
143  break;
144  default:
145  break;
146  }
147  return kTRUE;
148 }
149 
151 {
152  GO4TRACE((10,"Bool_t TGo4Command::IsSynchron() const", __LINE__, __FILE__));
153  return fbIsSynchron;
154 }
155 
156 Bool_t TGo4Command::IsLocal() const
157 {
158  return fbIsLocal;
159 }
160 
161 
163 {
164  GO4TRACE((12,"void TGo4Command::SetReceiver(TGo4CommandReceiver *)", __LINE__, __FILE__));
165  fxReceiverBase = rec;
166 }
167 
168 
170 {
171  if(mode<0 || mode>3) return nullptr;
172  return fgcMODEDESCRIPTION[mode];
173 }
174 
175 
177 {
178 // please override this function!
179 
180 }
virtual void Help()
Definition: TGo4Command.cxx:70
void SetReceiverName(const char *)
Definition: TGo4Command.cxx:93
Bool_t IsLocal() const
virtual void Set(TGo4RemoteCommand *remcon)
Go4CommandMode_t fiProtection
Definition: TGo4Command.h:102
TGo4CommandReceiver * fxReceiverBase
Definition: TGo4Command.h:116
Bool_t fbIsLocal
Definition: TGo4Command.h:93
Go4CommandMode_t
Definition: TGo4Command.h:27
void SetTaskName(const char *)
const char * What() const
virtual Int_t ExeCom()
virtual void SetReceiver(TGo4CommandReceiver *rec)
Go4CommandMode_t GetMode() const
Definition: TGo4Command.h:76
TString fxReceiverName
Definition: TGo4Command.h:112
Bool_t IsExclusive() const
Definition: TGo4Command.cxx:81
Go4CommandMode_t fiMode
Definition: TGo4Command.h:99
Int_t fiVersion
Definition: TGo4Command.h:96
virtual Bool_t Log(Int_t mode=0)
TString fxDescription
Definition: TGo4Command.h:111
TString fxTaskName
Definition: TGo4Command.h:113
Int_t GetCommandID() const
Definition: TGo4Command.cxx:64
const char * GetTaskName() const
Definition: TGo4Command.cxx:99
Int_t fiCommandID
Definition: TGo4Command.h:95
Bool_t fbIsSynchron
Definition: TGo4Command.h:92
virtual ~TGo4Command()
Definition: TGo4Command.cxx:59
void SetDescription(const char *)
const char * GetReceiverName() const
Definition: TGo4Command.cxx:87
#define GO4TRACE(X)
Definition: TGo4Log.h:25
Bool_t fbIsExclusive
Definition: TGo4Command.h:91
Bool_t IsEnabled() const
Definition: TGo4Command.cxx:75
Bool_t fbIsEnabled
Definition: TGo4Command.h:90
Bool_t IsSynchron() const
static const char * GetModeDescription(Go4CommandMode_t mode)
virtual Int_t RefuseCom()
static void Warn(const char *text,...) GO4_PRINTF_ARGS
Definition: TGo4Log.cxx:307
static const char * fgcMODEDESCRIPTION[]
Definition: TGo4Command.h:107