GSI Object Oriented Online Offline (Go4)  GO4-6.1.4
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4Command.cxx
Go to the documentation of this file.
1 // $Id: TGo4Command.cxx 2745 2020-04-16 08:55:15Z linev $
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 = 0;
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 = 0;
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 const char* TGo4Command::What() const
117 {
118  GO4TRACE((10,"const char * TGo4Command::What()", __LINE__, __FILE__));
119  return fxDescription.Data();
120 }
121 
123 {
124  GO4TRACE((10,"Int_t TGo4Command::ExeCom()", __LINE__, __FILE__));
125  std::cout << What() << std::endl;
126  return 0;
127 }
128 
130 {
131  TGo4Log::Warn("Not allowed to execute %s in mode %d:%s",
132  GetName(), GetMode(), GetModeDescription(GetMode()));
133  return 0;
134 }
135 
136 Bool_t TGo4Command::Log(Int_t mode)
137 {
138  GO4TRACE((10,"Bool_t TGo4Command::Log(Int_t mode)", __LINE__, __FILE__));
139  switch (mode) {
140  case 0:
141  std::cout << What() << std::endl;
142  break;
143  default:
144  break;
145  }
146  return kTRUE;
147 }
148 
150 {
151  GO4TRACE((10,"Bool_t TGo4Command::IsSynchron() const", __LINE__, __FILE__));
152  return fbIsSynchron;
153 }
154 
155 Bool_t TGo4Command::IsLocal() const
156 {
157  return fbIsLocal;
158 }
159 
160 
162 {
163  GO4TRACE((12,"void TGo4Command::SetReceiver(TGo4CommandReceiver * rec)", __LINE__, __FILE__));
164  fxReceiverBase = rec;
165 }
166 
167 
169 {
170  if(mode<0 || mode>3) return 0;
171  return fgcMODEDESCRIPTION[mode];
172 }
173 
174 
176 {
177 // please override this function!
178 
179 }
virtual void Help()
Definition: TGo4Command.cxx:70
void SetReceiverName(const char *)
Definition: TGo4Command.cxx:93
virtual void Set(TGo4RemoteCommand *remcon)
Bool_t IsSynchron() const
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 *)
Int_t GetCommandID() const
Definition: TGo4Command.cxx:64
Bool_t IsEnabled() const
Definition: TGo4Command.cxx:75
const char * GetTaskName() const
Definition: TGo4Command.cxx:99
const char * GetReceiverName() const
Definition: TGo4Command.cxx:87
static void Warn(const char *text,...)
Definition: TGo4Log.cxx:300
virtual Int_t ExeCom()
Bool_t IsExclusive() const
Definition: TGo4Command.cxx:81
virtual void SetReceiver(TGo4CommandReceiver *rec)
TString fxReceiverName
Definition: TGo4Command.h:112
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 fiCommandID
Definition: TGo4Command.h:95
Bool_t fbIsSynchron
Definition: TGo4Command.h:92
virtual ~TGo4Command()
Definition: TGo4Command.cxx:59
void SetDescription(const char *)
#define GO4TRACE(X)
Definition: TGo4Log.h:26
Bool_t fbIsExclusive
Definition: TGo4Command.h:91
Bool_t fbIsEnabled
Definition: TGo4Command.h:90
Go4CommandMode_t GetMode()
Definition: TGo4Command.h:76
const char * What() const
static const char * GetModeDescription(Go4CommandMode_t mode)
virtual Int_t RefuseCom()
Bool_t IsLocal() const
static const char * fgcMODEDESCRIPTION[]
Definition: TGo4Command.h:107