GammaWare  Head Version for release 0.9
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ALoadedActor.h
Go to the documentation of this file.
1 /***************************************************************************
2  * Copyright (C) 2004-2006 by Olivier Stezowski & Christian Finck *
3  * stezow(AT)ipnl.in2p3.fr, cfinck(AT)ires.in2p3.fr *
4  * *
5  * This program is free software; you can redistribute it and/or modify *
6  * it under the terms of the GNU General Public License as published by *
7  * the Free Software Foundation; either version 2 of the License, or *
8  * (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License *
16  * along with this program; if not, write to the *
17  * Free Software Foundation, Inc., *
18  * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. *
19  ***************************************************************************/
20 
23 #ifndef Gw_ALoadedActor
24 #define Gw_ALoadedActor
25 
26 // std headers
27 #include <string>
28 
29 // ADF headers
30 #include "NarvalInterface.h"
31 #include "DataHandling.h"
32 #include "AnActorConnection.h"
33 
35 typedef void (*ConfigFunction)(const Char_t *, UInt_t *);
36 
37 using namespace ADF;
38 namespace Gw {
39 
40 class ALoadedActor;
41 
44 {
45 protected:
47  UInt_t fError;
48 protected:
51 protected:
54 
55 public:
57  virtual ~AConfigurator()
58  {;}
59 
61  {
62  fConfigFunction = f;
63  }
65  virtual void SetError( UInt_t err = 0u )
66  {
67  fError = err;
68  }
69  virtual UInt_t GetError( ) const
70  {
71  return fError;
72  }
75  {
76  return 0x0;
77  }
79  virtual void Configure();
80 
81 };
82 
84 
89 {
90 public:
92  enum EType { kUnknown, kProducer, kFilter, kConsumer, kShunter };
93 public:
95 
107  enum EStatus { kUndefined, kConfigured, kLoaded, kInitialised, kDoRunning, kRunning, kHasRun, kStopped, kIdle, kFinished, kDead };
108 
109 protected:
111 protected:
113  std::string fName;
114 protected:
116  std::vector < ANamedItem * > fGlobals;
119 protected:
121 
126 protected:
128  std::vector < Gw::AnActorConnection * > fInputs;
130  std::vector < Gw::AnActorConnection * > fOutputs;
131 protected:
133  Int_t fDepth;
134 protected:
136 protected:
139 protected:
142 protected:
144  UInt_t fLastError;
145 
146 protected:
148 
150  void ProcessActorGeneration_2_1_0 (Short_t generation);
151 
152 public:
153  ALoadedActor(const Char_t *name);
155  virtual ~ALoadedActor()
156  {
157  if ( fActor ) delete fActor; // explicit call of process_reset ?
158  }
160  virtual NarvalInterface *GetActor() const
161  {
162  return fActor;
163  }
165  virtual EType GetActorType() const
166  {
167  return fActorType;
168  }
170  virtual EStatus GetStatus() const
171  {
172  return fActorStatus;
173  }
174  virtual void SetStatus(EStatus status)
175  {
176  fActorStatus = status;
177  }
179  virtual Int_t GetDepth() const
180  {
181  return fDepth;
182  }
183  virtual void SetDepth(Int_t depth)
184  {
185  fDepth = depth;
186  }
188  virtual UInt_t GetLastError() const
189  {
190  return fLastError;
191  }
193  virtual void SetLastError(UInt_t error)
194  {
195  fLastError = error;
196  }
198  virtual void SetGlobals( const std::vector < ANamedItem *> & );
200  virtual void SetGlobal( const ANamedItem & );
202  virtual Bool_t GetGlobal( ANamedItem & ) const;
203 
205  virtual AConfigurator *SetConfigurator(AConfigurator *);
206 
208  void ComputeDepth(Int_t &depth);
209 
211 
213  const std::string &GetName() const
214  {
215  return fName;
216  }
218  virtual Int_t GetNbInput() const
219  {
220  return fInputs.size();
221  }
223  virtual Int_t GetNbOutput() const
224  {
225  return fOutputs.size();
226  }
228  virtual ALoadedActor *GetInput(Int_t i) const
229  {
230  return fInputs[i]->GetProducer();
231  }
233  virtual ALoadedActor *GetOutput(Int_t i) const
234  {
235  return fOutputs[i]->GetConsumer();
236  }
238  Short_t IsLinked(ALoadedActor *, AnActorConnection *&) const;
239 
241 
243  virtual void AddOutput(AnActorConnection *);
245 
247  virtual void AddInput(AnActorConnection *);
249  virtual void ConfigureActor();
251  virtual void RegisterActor();
253  virtual void InitActor();
255 
257  virtual void ProcessActor ();
258 };
259 
260 template<typename Actor_T> class Configurator : public AConfigurator
261 {
262 public:
264  virtual ~Configurator() {;}
265 
268  {
269  return new Actor_T;
270  }
271 };
272 
273 } // end namespace
274 
275 #endif
void(* ConfigFunction)(const Char_t *, UInt_t *)
the function used to configure the underlying actor. Added to allow configuration by calling explicit...
Definition: ALoadedActor.h:35
LogMessage fLog
Definition: ALoadedActor.h:110
virtual NarvalInterface * Register()
creates an instance of the actor
Definition: ALoadedActor.h:74
std::vector< Gw::AnActorConnection * > fOutputs
link to actors for sending data ... not owned by this
Definition: ALoadedActor.h:130
virtual UInt_t GetError() const
Definition: ALoadedActor.h:69
virtual ~Configurator()
Definition: ALoadedActor.h:264
std::vector< ANamedItem * > fGlobals
Globals for this actor ... not owned by this.
Definition: ALoadedActor.h:116
virtual void SetStatus(EStatus status)
Definition: ALoadedActor.h:174
header file for AnActorConnection.cpp
AConfigurator * fConfigurator
used to configure the actor (config + load)
Definition: ALoadedActor.h:125
virtual ~ALoadedActor()
delete the embedded actor. Connections are owned by the emulator.
Definition: ALoadedActor.h:155
EStatus
current status
Definition: ALoadedActor.h:107
std::string fName
Actor's name.
Definition: ALoadedActor.h:113
LogMessage & error(LogMessage &)
EType fActorType
to know what kind of actor it is (done @ registration time, see RegisterActor) :
Definition: ALoadedActor.h:138
virtual UInt_t GetLastError() const
to get the last error code, whatever the action
Definition: ALoadedActor.h:188
Base class for a Log message.
Definition: GwLogMessage.h:94
void SetConfigMethod(ConfigFunction f)
Definition: ALoadedActor.h:60
EType
type of the loaded actor. Required since some interfaces are different for different type of actors...
Definition: ALoadedActor.h:92
EStatus fActorStatus
to know what kind of actor it is (done @ registration time, see RegisterActor) :
Definition: ALoadedActor.h:141
virtual NarvalInterface * Register()
creates an instance of the actor
Definition: ALoadedActor.h:267
UInt_t fError
last error
Definition: ALoadedActor.h:47
An actor looded in an emulator.
Definition: ALoadedActor.h:88
NamedItem< Short_t > * fGeneration
From the global it keeps the generation here for efficiency. Init @ SetGlobal.
Definition: ALoadedActor.h:118
virtual void SetLastError(UInt_t error)
to set the last error code
Definition: ALoadedActor.h:193
virtual NarvalInterface * GetActor() const
get loaded actor, should have the narval interface
Definition: ALoadedActor.h:160
ALoadedActor * fRefToLoadedActor
Ref to the loader using this in order to have access to the list of global (containing ConfDir) ...
Definition: ALoadedActor.h:50
virtual Int_t GetNbOutput() const
get number of ouput connected actors
Definition: ALoadedActor.h:223
virtual EType GetActorType() const
get loaded actor, should have the narval interface
Definition: ALoadedActor.h:165
virtual ALoadedActor * GetOutput(Int_t i) const
returns a given ouput of this
Definition: ALoadedActor.h:233
ConfigFunction fConfigFunction
real method to be used to configure the actor
Definition: ALoadedActor.h:53
ANamedItem.
Definition: DataHandling.h:188
virtual void SetError(UInt_t err=0u)
Reset error.
Definition: ALoadedActor.h:65
header file for DataHandling.cpp
virtual ~AConfigurator()
Definition: ALoadedActor.h:57
virtual Int_t GetNbInput() const
get number of input connected actors
Definition: ALoadedActor.h:218
Configurator(ALoadedActor *lactor, ConfigFunction f)
Definition: ALoadedActor.h:263
header file for NarvalInterface.cpp
NarvalInterface * fActor
Definition: ALoadedActor.h:135
virtual Int_t GetDepth() const
get dpeth of this in a topology: -1 if not connected
Definition: ALoadedActor.h:179
const std::string & GetName() const
get loaded actor's name
Definition: ALoadedActor.h:213
It defines the general interface needed to be a narval actor.
base class in charge of configurating, allocating the true actor loaded in a LoadedActor ...
Definition: ALoadedActor.h:43
UInt_t fLastError
to know what kind of actor it is (done @ registration time, see RegisterActor) :
Definition: ALoadedActor.h:144
Base class that connects two actors in a general topology.
virtual ALoadedActor * GetInput(Int_t i) const
returns a given input of this
Definition: ALoadedActor.h:228
virtual void SetDepth(Int_t depth)
Definition: ALoadedActor.h:183
virtual EStatus GetStatus() const
get dpeth of this in a topology: -1 if not connected
Definition: ALoadedActor.h:170
std::vector< Gw::AnActorConnection * > fInputs
link to actors providing data ... not owned by this
Definition: ALoadedActor.h:128
Int_t fDepth
depth in the toplogy in which this actor is active.
Definition: ALoadedActor.h:133