GSI Object Oriented Online Offline (Go4)  GO4-5.3.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
TGo4Command.cxx
Go to the documentation of this file.
1 // $Id: TGo4Command.cxx 1033 2013-11-05 15:30:01Z 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 für 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 "Riostream.h"
17 
18 #include "TGo4Log.h"
19 #include "TGo4CommandReceiver.h"
20 
22  {"NOMODE","Observer","Controller","Administrator"};
23 
24 
25 TGo4Command::TGo4Command(const char* name, const char* description, Int_t id) :
26  TNamed(name, "This is a TGo4Command")
27 {
28  GO4TRACE((12,"TGo4Command::TGo4Command(const char* name, const char* description, Int_t id)", __LINE__, __FILE__));
29  SetDescription(description);
30  SetReceiverName("NoNameReceiver");
31  SetTaskName("NoNameTask");
32  fiCommandID = id;
33  fiVersion = 1;
34  fbIsSynchron = kFALSE;
35  fbIsEnabled = kTRUE;
36  fbIsExclusive = kFALSE;
37  fbIsLocal = kFALSE;
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 }
57 
59 {
60  GO4TRACE((12,"TGo4Command::~TGo4Command()", __LINE__, __FILE__));
61 }
62 
64 {
65  GO4TRACE((10,"Int_t TGo4Command::GetCommandID() const ", __LINE__, __FILE__));
66  return fiCommandID;
67 }
68 
70 {
71  GO4TRACE((10,"void TGo4Command::Help()", __LINE__, __FILE__));
72 }
73 
74 Bool_t TGo4Command::IsEnabled() const
75 {
76  GO4TRACE((10,"Bool_t TGo4Command::IsEnabled() const", __LINE__, __FILE__));
77  return fbIsEnabled;
78 }
79 
81 {
82  GO4TRACE((10,"Bool_t TGo4Command::IsExclusive() const", __LINE__, __FILE__));
83  return fbIsExclusive;
84 }
85 
86 const char* TGo4Command::GetReceiverName() const
87 {
88  GO4TRACE((10,"const char * TGo4Command::GetReceiverName()", __LINE__, __FILE__));
89  return fxReceiverName.Data();
90 }
91 
92 void TGo4Command::SetReceiverName(const char* name)
93 {
94  GO4TRACE((10,"void TGo4Command::SetReceiverName(const char*)", __LINE__, __FILE__));
95  fxReceiverName = name;
96 }
97 
98 const char* TGo4Command::GetTaskName() const
99 {
100  GO4TRACE((10,"const char * TGo4Command::GetTaskName()", __LINE__, __FILE__));
101  return fxTaskName.Data();
102 }
103 
104 void TGo4Command::SetTaskName(const char* name)
105 {
106  GO4TRACE((10,"void TGo4Command::SetTaskName(const char*)", __LINE__, __FILE__));
107  fxTaskName=name;
108 }
109 
110 void TGo4Command::SetDescription(const char* txt)
111 {
112  GO4TRACE((10,"void TGo4Command::SetDescription(const char*)", __LINE__, __FILE__));
113  fxDescription = txt;
114 }
115 const char* TGo4Command::What() const
116 {
117  GO4TRACE((10,"const char * TGo4Command::What()", __LINE__, __FILE__));
118  return fxDescription.Data();
119 }
120 
122 {
123  GO4TRACE((10,"Int_t TGo4Command::ExeCom()", __LINE__, __FILE__));
124  std::cout << What() << std::endl;
125  return 0;
126 }
127 
129 {
130  TGo4Log::Warn("Not allowed to execute %s in mode %d:%s",
131  GetName(), GetMode(), GetModeDescription(GetMode()));
132  return 0;
133 }
134 
135 Bool_t TGo4Command::Log(Int_t mode)
136 {
137  GO4TRACE((10,"Bool_t TGo4Command::Log(Int_t mode)", __LINE__, __FILE__));
138  switch (mode) {
139  case 0:
140  std::cout << What() << std::endl;
141  break;
142  default:
143  break;
144  }
145  return kTRUE;
146 }
147 
149 {
150  GO4TRACE((10,"Bool_t TGo4Command::IsSynchron() const", __LINE__, __FILE__));
151  return fbIsSynchron;
152 }
153 
154 Bool_t TGo4Command::IsLocal() const
155 {
156  return fbIsLocal;
157 }
158 
159 
161 {
162  GO4TRACE((12,"void TGo4Command::SetReceiver(TGo4CommandReceiver * rec)", __LINE__, __FILE__));
163  fxReceiverBase = rec;
164 }
165 
166 
168 {
169  if(mode<0 || mode>3) return 0;
170  return fgcMODEDESCRIPTION[mode];
171 }
172 
173 
175 {
176 // please override this function!
177 
178 }
virtual void Help()
Definition: TGo4Command.cxx:69
void SetReceiverName(const char *)
Definition: TGo4Command.cxx:92
virtual void Set(TGo4RemoteCommand *remcon)
Bool_t IsSynchron() const
Go4CommandMode_t fiProtection
Definition: TGo4Command.h:103
TGo4CommandReceiver * fxReceiverBase
Definition: TGo4Command.h:117
Bool_t fbIsLocal
Definition: TGo4Command.h:94
Go4CommandMode_t
Definition: TGo4Command.h:28
void SetTaskName(const char *)
Int_t GetCommandID() const
Definition: TGo4Command.cxx:63
Bool_t IsEnabled() const
Definition: TGo4Command.cxx:74
const char * GetTaskName() const
Definition: TGo4Command.cxx:98
const char * GetReceiverName() const
Definition: TGo4Command.cxx:86
static void Warn(const char *text,...)
Definition: TGo4Log.cxx:296
virtual Int_t ExeCom()
Bool_t IsExclusive() const
Definition: TGo4Command.cxx:80
virtual void SetReceiver(TGo4CommandReceiver *rec)
TString fxReceiverName
Definition: TGo4Command.h:113
Go4CommandMode_t fiMode
Definition: TGo4Command.h:100
Int_t fiVersion
Definition: TGo4Command.h:97
virtual Bool_t Log(Int_t mode=0)
TString fxDescription
Definition: TGo4Command.h:112
TString fxTaskName
Definition: TGo4Command.h:114
Int_t fiCommandID
Definition: TGo4Command.h:96
Bool_t fbIsSynchron
Definition: TGo4Command.h:93
virtual ~TGo4Command()
Definition: TGo4Command.cxx:58
void SetDescription(const char *)
#define GO4TRACE(X)
Definition: TGo4Log.h:26
Bool_t fbIsExclusive
Definition: TGo4Command.h:92
Bool_t fbIsEnabled
Definition: TGo4Command.h:91
Go4CommandMode_t GetMode()
Definition: TGo4Command.h:77
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:108