DABC (Data Acquisition Backbone Core)  2.9.9
Manager.h
Go to the documentation of this file.
1 // $Id: Manager.h 4471 2020-04-15 13:19:26Z linev $
2 
3 /************************************************************
4  * The Data Acquisition Backbone Core (DABC) *
5  ************************************************************
6  * Copyright (C) 2009 - *
7  * GSI Helmholtzzentrum fuer Schwerionenforschung GmbH *
8  * Planckstr. 1, 64291 Darmstadt, Germany *
9  * Contact: http://dabc.gsi.de *
10  ************************************************************
11  * This software can be used under the GPL license *
12  * agreements as stated in LICENSE.txt file *
13  * which is part of the distribution. *
14  ************************************************************/
15 
16 #ifndef DABC_Manager
17 #define DABC_Manager
18 
19 #ifndef DABC_Worker
20 #include "dabc/Worker.h"
21 #endif
22 
23 #ifndef DABC_Application
24 #include "dabc/Application.h"
25 #endif
26 
27 #ifndef DABC_Module
28 #include "dabc/Module.h"
29 #endif
30 
31 namespace dabc {
32 
33  class Mutex;
34  class Thread;
35  class Port;
36  class MemoryPool;
37  class Manager;
38  class ManagerRef;
39  class Device;
40  class Factory;
41  class FactoryPlugin;
42  class DependPairList;
43  class DataInput;
44  class InputTransport;
45  class DataOutput;
46  class Configuration;
47  class StdManagerFactory;
48  class ReferencesVector;
49  class Thread;
50  class ParamEventReceiverList;
51 
52  class CmdDeletePool : public Command {
53  public:
54  static const char* CmdName() { return "DeletePool"; }
55 
56  CmdDeletePool(const std::string &name) : Command(CmdName())
57  { SetStr("PoolName", name); }
58  };
59 
60 
61  class CmdModule : public Command {
62  public:
63  static const char* ModuleArg() { return "Module"; }
64 
65  CmdModule(const char* cmdname, const std::string &module) : Command(cmdname)
66  {
67  SetStr(ModuleArg(), module);
68  }
69  };
70 
71  class CmdCreateModule : public CmdModule {
72  public:
73  static const char* CmdName() { return "CreateModule"; }
74 
75  CmdCreateModule(const std::string &classname, const std::string &modulename, const std::string &thrdname = "") :
76  CmdModule(CmdName(), modulename)
77  {
78  SetStr(xmlClassAttr, classname);
79  if (!thrdname.empty()) SetStr(xmlThreadAttr, thrdname);
80  }
81  };
82 
83  class CmdStartModule : public CmdModule {
84  public:
85  static const char* CmdName() { return "StartModule"; }
86 
87  CmdStartModule(const std::string &modulename = "*") : CmdModule(CmdName(), modulename) {}
88  };
89 
90  class CmdStopModule : public CmdModule {
91  public:
92  static const char* CmdName() { return "StopModule"; }
93 
94  CmdStopModule(const std::string &modulename = "*") : CmdModule(CmdName(), modulename) {}
95  };
96 
97  class CmdDeleteModule : public CmdModule {
98  public:
99  static const char* CmdName() { return "DeleteModule"; }
100 
101  CmdDeleteModule(const std::string &modulename) : CmdModule(CmdName(), modulename) {}
102  };
103 
106  };
107 
108  class CmdCreateApplication : public Command {
109 
110  DABC_COMMAND(CmdCreateApplication, "CreateApplication");
111 
112  CmdCreateApplication(const std::string &appclass, const std::string &thrdname = "") :
113  Command(CmdName())
114  {
115  SetStr("AppClass", appclass);
116  if (!thrdname.empty()) SetStr(xmlThreadAttr, thrdname);
117  }
118  };
119 
120 
121  class CmdCreateDevice : public Command {
122  public:
123  static const char* CmdName() { return "CreateDevice"; }
124 
125  CmdCreateDevice(const std::string &devclass, const std::string &devname) :
126  Command(CmdName())
127  {
128  SetStr("DevClass", devclass);
129  SetStr("DevName", devname);
130  }
131  };
132 
133  class CmdDestroyDevice : public Command {
134  public:
135  static const char* CmdName() { return "DestroyDevice"; }
136 
137  CmdDestroyDevice(const std::string &devname) :
138  Command(CmdName())
139  {
140  SetStr("DevName", devname);
141  }
142  };
143 
144  class CmdCreateThread : public Command {
145  public:
146  static const char* CmdName() { return "CreateThread"; }
147 
148  static const char* ThrdNameArg() { return "ThrdName"; }
149 
150  CmdCreateThread(const std::string &thrdname, const std::string &thrdclass = "", const std::string &devname = "") :
151  Command(CmdName())
152  {
153  SetStr(ThrdNameArg(), thrdname);
154  SetStr("ThrdClass", thrdclass);
155  SetStr("ThrdDev", devname);
156  }
157 
158  std::string GetThrdName() const { return GetStr(ThrdNameArg()); }
159  };
160 
161  class CmdCreateObject : public Command {
162 
163  DABC_COMMAND(CmdCreateObject, "CreateObject");
164 
165  CmdCreateObject(const std::string &classname, const std::string &objname) :
166  Command(CmdName())
167  {
168  SetStr("ClassName", classname);
169  SetStr("ObjName", objname);
170  }
171  };
172 
173 
174  class CmdCreateDataInput : public Command {
175  DABC_COMMAND(CmdCreateDataInput, "CreateDataInput");
176  };
177 
178  class CmdCreateTransport : public Command {
179 
180  DABC_COMMAND(CmdCreateTransport, "CreateTransport");
181 
182  static const char* PortArg() { return "PortName"; }
183  static const char* KindArg() { return "TransportKind"; }
184 
185  CmdCreateTransport(const std::string &portname, const std::string &transportkind, const std::string &thrdname = "") :
186  Command(CmdName())
187  {
188  SetStr(PortArg(), portname);
189  SetStr(KindArg(), transportkind);
190  if (!thrdname.empty()) SetStr(xmlThreadAttr, thrdname);
191  }
192 
193  void SetPoolName(const std::string &name) { if (!name.empty()) SetStr(xmlPoolName, name); }
194 
195  std::string PortName() const { return GetStr(PortArg()); }
196  std::string TransportKind() const { return GetStr(KindArg()); }
197  std::string PoolName() const { return GetStr(xmlPoolName); }
198  };
199 
200  class CmdDestroyTransport : public Command {
201 
202  DABC_COMMAND(CmdDestroyTransport, "DestroyTransport");
203 
204  CmdDestroyTransport(const std::string &portname) :
205  Command(CmdName())
206  {
207  SetStr("PortName", portname);
208  }
209  };
210 
211  class CmdCreateAny : public Command {
212  DABC_COMMAND(CmdCreateAny, "CreateAny");
213  };
214 
215 
216  class CmdSetParameter : public Command {
217 
218  DABC_COMMAND(CmdSetParameter, "SetParameter");
219 
220  static const char* ParName() { return "ParName"; }
221  static const char* ParValue() { return "ParValue"; }
222 
223  CmdSetParameter(const std::string &parname) :
224  Command(CmdName())
225  {
226  SetStr(ParName(), parname);
227  }
228 
229  CmdSetParameter(const std::string &parname, const RecordField& v) :
230  Command(CmdName())
231  {
232  SetStr(ParName(), parname);
233  SetParValue(v);
234  }
235 
236  void SetParValue(const RecordField& v) { SetField(ParValue(), v); }
237 
238  std::string GetParName() { return GetStr(ParName()); }
240  };
241 
243  class CmdGetNodesState : public Command {
244 
245  DABC_COMMAND(CmdGetNodesState, "CmdGetNodesState")
246 
247  static const char* States() { return "States"; }
248  static const char* NodeId() { return "NodeId"; }
249 
250  static void SetState(std::string& sbuf, unsigned node, bool on)
251  {
252  while (sbuf.length() <= node) sbuf.append("x");
253  sbuf[node] = on ? 'x' : 'o';
254  }
255 
256  static bool GetState(const std::string &sbuf, unsigned node)
257  {
258  if (node>=sbuf.length()) return false;
259  return sbuf[node] == 'x';
260  }
261  };
262 
264  template<class T>
265  class CleanupEnvelope : public Object {
266  protected:
267  T* fObj;
268  public:
269  CleanupEnvelope(T* obj) : Object(0, "noname"), fObj(obj) {}
270  virtual ~CleanupEnvelope() { delete fObj; }
271  };
272 
273 
275  layoutMinimalistic, // minimal number of threads
276  layoutPerModule, // each module should use single thread, including all transports
277  layoutBalanced, // per each module three threads - for module, all input and all output transports
278  layoutMaximal // each entity will gets its own thread
279  };
280 
281 
282 
291  class Manager : public Worker {
292 
293  friend class Object;
294  friend class Factory;
295  friend class FactoryPlugin;
296  friend class ParameterContainer;
297  friend class StdManagerFactory;
298  friend class ManagerRef;
299 
300  private:
301 
302  enum { MagicInstanceId = 7654321 };
303 
304  // this method is used from Factory to register factory when it created
305  static void ProcessFactory(Factory* factory);
306 
307  static Manager* fInstance;
308  static int fInstanceId;
309  static Factory* fFirstFactories[10];
310  static int fFirstFactoriesId;
311 
312 
313  protected:
314 
316 
317  struct ParamRec {
319  int event;
320 
321  ParamRec() : par(), event(0) {}
322  ParamRec(Parameter p, int e) : par(p), event(e) {}
323  ParamRec(const ParamRec& src) : par(src.par), event(src.event) {}
324  ~ParamRec() { reset(); }
325 
327  {
328  par = src.par;
329  event = src.event;
330  return* this;
331  }
332 
333  void reset()
334  {
335  par.Release();
336  event = 0;
337  }
338  };
339 
342 
343  // FIXME: revise usage of manager mutex, it is not necessary everywhere
344  Mutex *fMgrMutex; // main mutex to protect manager queues
345 
347  // FIXME: use stl containers while RecordsQueue uses memcpy for struct with virtual table
349 
350  // TODO: timed parameters should be seen in the special manager folder ?
352 
356 
357  // TODO: dependency pairs should be seen in special manager folder
358  DependPairList *fDepend; // list of objects dependencies
359 
361  std::string fCfgHost;
362 
363  int fNodeId;
365 
369  std::string fLocalAddress;
370 
372 
373  std::string fLastCreatedDevName;
374 
377  Reference FindItem(const std::string &itemname, bool islocal = false);
378 
381  void FillItemName(const Object* ptr, std::string& itemname, bool compact = true);
382 
383  ThreadRef FindThread(const std::string &name, const std::string &required_class = "");
384 
386 
387  WorkerRef FindDevice(const std::string &name);
388 
389  Reference FindPool(const std::string &name);
390 
391  ModuleRef FindModule(const std::string &name);
392 
393  Reference FindPort(const std::string &name);
394 
396 
397  bool IsAnyModuleRunning();
398 
399  bool DoCreateMemoryPool(Command cmd);
400 
408  ThreadRef DoCreateThread(const std::string &thrdname, const std::string &classname = "", const std::string &devname = "", Command cmd = nullptr);
409 
410  WorkerRef DoCreateModule(const std::string &classname, const std::string &modulename, Command cmd);
411 
412  Reference DoCreateObject(const std::string &classname, const std::string &objname = "", Command cmd = nullptr);
413 
417 
423  Reference GetFactoriesFolder(bool force = false) { return GetFolder(FactoriesFolderName(), force); }
424 
430  Reference GetThreadsFolder(bool force = false) { return GetFolder(ThreadsFolderName(), force); }
431 
434  void Sleep(double tmout, const char* prefix = 0);
435 
436  std::string GetLastCreatedDevName();
437 
440  void RunManagerMainLoop(double runtime = 0.);
441 
443  void RunManagerCmdLoop(double runtime = 0., const std::string &remnode = "");
444 
445  bool DoCleanupApplication();
446 
447  // virtual methods from Worker
448 
449  virtual double ProcessTimeout(double last_diff);
450 
451  virtual int PreviewCommand(Command cmd);
452  virtual int ExecuteCommand(Command cmd);
453  virtual bool ReplyCommand(Command cmd);
454 
455  virtual void ProcessEvent(const EventId&);
456 
457  public:
458 
459  Manager(const std::string &managername, Configuration* cfg = 0);
460  virtual ~Manager();
461 
462  virtual const char* ClassName() const { return "Manager"; }
463 
464  // candidates for protected
465 
469  void HaltManager();
470 
471  // -------------- generic folder structure of manager
472 
473  static const char* FactoriesFolderName() { return "Factories"; }
474  static const char* ThreadsFolderName() { return "Threads"; }
475 
476  static const char* MgrThrdName() { return "ManagerThrd"; }
477  static const char* AppThrdName() { return "AppThrd"; }
478  static const char* ConnMgrName() { return "/ConnMgr"; }
479  static const char* CmdChlName() { return "/CommandChl"; }
480 
481 
483  int NodeId() const { return fNodeId; }
485  int NumNodes() { return fNumNodes; }
486 
488  std::string GetLocalAddress();
489 
491  std::string GetNodeAddress(int nodeid);
494  bool DecomposeAddress(const std::string &url, bool& islocal, std::string& server, std::string& itemtname);
496  std::string ComposeAddress(const std::string &server, const std::string &itemtname = "");
497 
499 
500  // -------------------------- misc functions ---------------
501 
502  Configuration* cfg() const { return fCfg; }
503 
505  virtual void Print(int lvl = 0);
506 
509  virtual bool DestroyObject(Reference ref);
510 
512  template<class T> bool DeleteAnyObject(T* obj)
513  {
514  return DestroyObject(Reference(new CleanupEnvelope<T>(obj)));
515  }
516 
527  bool RegisterDependency(Object* src, Object* tgt, bool bidirectional = false);
528 
532  bool UnregisterDependency(Object* src, Object* tgt, bool bidirectional = false);
533 
535  void ProcessCtrlCSignal();
536  void ProcessPipeSignal();
537 
538  virtual bool Find(ConfigIO &cfg);
539 
540  // ------------ access to factories method -------------
541 
543  static void SetAutoDestroy(bool on);
544 
545 
546  bool ProcessDestroyQueue();
547  bool ProcessParameterEvents();
548  void ProduceParameterEvent(ParameterContainer* par, int evid);
549  };
550 
560  class ManagerRef : public WorkerRef {
561 
563 
564  protected:
565 
566  friend class Manager;
567  friend class Worker;
568  friend class Port; // need to activate connection manager
569  friend class InputTransport; // need to create input object
570 
571  bool ParameterEventSubscription(Worker* ptr, bool subscribe, const std::string &mask, bool onlychangeevent = true);
572 
574  bool IsLocalItem(const std::string &name);
575 
577  DataInput* CreateDataInput(const std::string &kind);
578 
579  public:
580 
582 
587  bool CleanupApplication();
588 
589  int NodeId() const;
590 
591  int NumNodes() const;
592 
594  std::string GetLocalAddress()
595  { return null() ? std::string() : GetObject()->GetLocalAddress(); }
596 
597  std::string GetNodeAddress(int nodeid)
598  { return null() ? std::string() : GetObject()->GetNodeAddress(nodeid); }
599 
600  bool DecomposeAddress(const std::string &url, bool& islocal, std::string& server, std::string& itemtname)
601  { return null() ? false : GetObject()->DecomposeAddress(url, islocal, server, itemtname); }
602 
603  std::string ComposeAddress(const std::string &server, const std::string &itemname = "")
604  { return null() ? std::string() : GetObject()->ComposeAddress(server, itemname); }
605 
606  bool CreateApplication(const std::string &classname = "", const std::string &appthrd = "");
607 
608  ThreadRef CreateThread(const std::string &thrdname, const std::string &classname = "", const std::string &devname = "");
609 
614 
615  bool CreateDevice(const std::string &classname, const std::string &devname);
616  bool DeleteDevice(const std::string &devname);
617  WorkerRef FindDevice(const std::string &name);
618 
619  Reference CreateObject(const std::string &classname, const std::string &objname);
620 
627  bool CreateMemoryPool(const std::string &poolname,
628  unsigned buffersize = 0,
629  unsigned numbuffers = 0);
630 
631  bool DeletePool(const std::string &name);
632 
633  ModuleRef CreateModule(const std::string &classname, const std::string &modulename, const std::string &thrdname = "");
634  ModuleRef FindModule(const std::string &name);
635  void StartModule(const std::string &modulename);
636  void StopModule(const std::string &modulename);
637  bool StartAllModules();
638  bool StopAllModules();
639  bool DeleteModule(const std::string &name);
640 
641  bool CreateTransport(const std::string &portname, const std::string &transportkind = "", const std::string &thrdname = "");
642 
643  void* CreateAny(const std::string &classname, const std::string &objname = "");
644 
645  bool ActivateConnections(double tmout, bool sync = true);
646 
647  Reference FindItem(const std::string &name);
648 
649  Reference FindPort(const std::string &port);
650 
651  Parameter FindPar(const std::string &parname);
652 
653  Reference FindPool(const std::string &name);
654 
655  ThreadRef FindThread(const std::string &name, const std::string &required_class = "")
656  { return null() ? ThreadRef() : GetObject()->FindThread(name, required_class); }
657 
658  unsigned NumThreads() const
659  { return null() ? 0 : GetObject()->GetThreadsFolder().NumChilds(); }
660 
662  { return null() ? layoutBalanced : GetObject()->GetThreadsLayout(); }
663 
664  bool IsTerminated() const
665  { return null() ? true : !GetObject()->fMgrStoppedTime.null(); }
666 
673  ConnectionRequest Connect(const std::string &port1, const std::string &port2);
674 
675  void StopApplication();
676 
679  void Sleep(double tmout, const char* prefix = 0);
680 
683  void RunMainLoop(double runtime = 0.)
684  { if (GetObject()) GetObject()->RunManagerMainLoop(runtime); }
685 
687  void RunCmdLoop(double runtime = 0., const std::string &remnode = "")
688  { if (GetObject()) GetObject()->RunManagerCmdLoop(runtime, remnode); }
689 
691  { return GetObject() ? GetObject()->GetCommandChannel() : WorkerRef(); }
692 
696  bool CreateControl(bool withserver, int serv_port = 0, bool allow_clients = true);
697 
699  bool CreatePublisher();
700 
701  };
702 
703  extern ManagerRef mgr;
704 }
705 
706 #endif
#define DABC_COMMAND(cmd_class, cmd_name)
Definition: Command.h:282
#define DABC_REFERENCE(RefClass, ParentClass, T)
Definition: Reference.h:222
Reference on dabc::Application class
Definition: Application.h:178
Template to put any object, not derived from dabc::Object, into cleanup queue.
Definition: Manager.h:265
virtual ~CleanupEnvelope()
Definition: Manager.h:270
CleanupEnvelope(T *obj)
Definition: Manager.h:269
DABC_COMMAND(CmdCleanupApplication, "CleanupManager")
DABC_COMMAND(CmdCreateAny, "CreateAny")
CmdCreateApplication(const std::string &appclass, const std::string &thrdname="")
Definition: Manager.h:112
DABC_COMMAND(CmdCreateApplication, "CreateApplication")
DABC_COMMAND(CmdCreateDataInput, "CreateDataInput")
static const char * CmdName()
Definition: Manager.h:123
CmdCreateDevice(const std::string &devclass, const std::string &devname)
Definition: Manager.h:125
static const char * CmdName()
Definition: Manager.h:73
CmdCreateModule(const std::string &classname, const std::string &modulename, const std::string &thrdname="")
Definition: Manager.h:75
CmdCreateObject(const std::string &classname, const std::string &objname)
Definition: Manager.h:165
DABC_COMMAND(CmdCreateObject, "CreateObject")
static const char * ThrdNameArg()
Definition: Manager.h:148
std::string GetThrdName() const
Definition: Manager.h:158
static const char * CmdName()
Definition: Manager.h:146
CmdCreateThread(const std::string &thrdname, const std::string &thrdclass="", const std::string &devname="")
Definition: Manager.h:150
std::string PortName() const
Definition: Manager.h:195
void SetPoolName(const std::string &name)
Definition: Manager.h:193
CmdCreateTransport(const std::string &portname, const std::string &transportkind, const std::string &thrdname="")
Definition: Manager.h:185
std::string PoolName() const
Definition: Manager.h:197
static const char * KindArg()
Definition: Manager.h:183
static const char * PortArg()
Definition: Manager.h:182
std::string TransportKind() const
Definition: Manager.h:196
DABC_COMMAND(CmdCreateTransport, "CreateTransport")
static const char * CmdName()
Definition: Manager.h:99
CmdDeleteModule(const std::string &modulename)
Definition: Manager.h:101
CmdDeletePool(const std::string &name)
Definition: Manager.h:56
static const char * CmdName()
Definition: Manager.h:54
CmdDestroyDevice(const std::string &devname)
Definition: Manager.h:137
static const char * CmdName()
Definition: Manager.h:135
DABC_COMMAND(CmdDestroyTransport, "DestroyTransport")
CmdDestroyTransport(const std::string &portname)
Definition: Manager.h:204
Command to request current state of known nodes
Definition: Manager.h:243
static bool GetState(const std::string &sbuf, unsigned node)
Definition: Manager.h:256
static const char * States()
Definition: Manager.h:247
static void SetState(std::string &sbuf, unsigned node, bool on)
Definition: Manager.h:250
static const char * NodeId()
Definition: Manager.h:248
CmdModule(const char *cmdname, const std::string &module)
Definition: Manager.h:65
static const char * ModuleArg()
Definition: Manager.h:63
std::string GetParName()
Definition: Manager.h:238
RecordField GetParValue()
Definition: Manager.h:239
static const char * ParValue()
Definition: Manager.h:221
static const char * ParName()
Definition: Manager.h:220
DABC_COMMAND(CmdSetParameter, "SetParameter")
void SetParValue(const RecordField &v)
Definition: Manager.h:236
CmdSetParameter(const std::string &parname, const RecordField &v)
Definition: Manager.h:229
CmdSetParameter(const std::string &parname)
Definition: Manager.h:223
CmdStartModule(const std::string &modulename="*")
Definition: Manager.h:87
static const char * CmdName()
Definition: Manager.h:85
CmdStopModule(const std::string &modulename="*")
Definition: Manager.h:94
static const char * CmdName()
Definition: Manager.h:92
Represents command with its arguments.
Definition: Command.h:99
bool SetStr(const std::string &name, const char *value)
Definition: Command.h:134
std::string GetStr(const std::string &name, const std::string &dflt="") const
Definition: Command.h:136
Interface class between xml configuration and dabc objects.
Definition: ConfigIO.h:38
Full-functional class to reading configuration from xml files.
Definition: Configuration.h:34
Connection request.
Interface for implementing any kind of data input.
Definition: DataIO.h:61
Small helper class to correctly instantiate user-specific factories.
Definition: Factory.h:106
Factory for user-specific classes
Definition: Factory.h:47
Reference on manager object
Definition: Manager.h:560
WorkerRef FindDevice(const std::string &name)
Definition: Manager.cxx:2013
void StopModule(const std::string &modulename)
Definition: Manager.cxx:2028
bool ActivateConnections(double tmout, bool sync=true)
Definition: Manager.cxx:2197
ThreadRef CurrentThread()
Returns reference on the thread, which is now active.
Definition: Manager.cxx:1995
DataInput * CreateDataInput(const std::string &kind)
Create data input, using factories methods.
Definition: Manager.cxx:2260
void RunMainLoop(double runtime=0.)
Run manager main loop.
Definition: Manager.h:683
Reference FindPool(const std::string &name)
Definition: Manager.cxx:2064
void StopApplication()
Definition: Manager.cxx:2231
ThreadsLayout GetThreadsLayout() const
Definition: Manager.h:661
ApplicationRef app()
Definition: Manager.cxx:2074
ModuleRef CreateModule(const std::string &classname, const std::string &modulename, const std::string &thrdname="")
Definition: Manager.cxx:1981
bool CreateTransport(const std::string &portname, const std::string &transportkind="", const std::string &thrdname="")
Definition: Manager.cxx:2210
std::string GetLocalAddress()
Return identifier of local host, which can be used everywhere for node addressing.
Definition: Manager.h:594
bool IsTerminated() const
Definition: Manager.h:664
unsigned NumThreads() const
Definition: Manager.h:658
Reference CreateObject(const std::string &classname, const std::string &objname)
Definition: Manager.cxx:2251
Reference FindPort(const std::string &port)
Definition: Manager.cxx:2059
ConnectionRequest Connect(const std::string &port1, const std::string &port2)
Request connection between two ports.
Definition: Manager.cxx:2138
bool DeleteModule(const std::string &name)
Definition: Manager.cxx:2043
void Sleep(double tmout, const char *prefix=0)
Sleep for specified time, keep thread event loop running See Manager::Sleep() method for more details...
Definition: Manager.cxx:2269
void RunCmdLoop(double runtime=0., const std::string &remnode="")
Run manager command loop.
Definition: Manager.h:687
void StartModule(const std::string &modulename)
Definition: Manager.cxx:2023
Parameter FindPar(const std::string &parname)
Definition: Manager.cxx:2069
ThreadRef FindThread(const std::string &name, const std::string &required_class="")
Definition: Manager.h:655
bool DeletePool(const std::string &name)
Definition: Manager.cxx:2048
bool CleanupApplication()
Method safely deletes all object created for application - modules, devices, memory pools.
Definition: Manager.cxx:2079
Reference FindItem(const std::string &name)
Definition: Manager.cxx:2054
bool DeleteDevice(const std::string &devname)
Definition: Manager.cxx:2007
bool StartAllModules()
Definition: Manager.cxx:2033
bool ParameterEventSubscription(Worker *ptr, bool subscribe, const std::string &mask, bool onlychangeevent=true)
Definition: Manager.cxx:2096
std::string ComposeAddress(const std::string &server, const std::string &itemname="")
Definition: Manager.h:603
int NumNodes() const
Definition: Manager.cxx:2091
bool CreateApplication(const std::string &classname="", const std::string &appthrd="")
Definition: Manager.cxx:1975
std::string GetNodeAddress(int nodeid)
Definition: Manager.h:597
bool IsLocalItem(const std::string &name)
Returns true, if name of the item should specify name in local context or from remote node.
Definition: Manager.cxx:2131
bool CreateMemoryPool(const std::string &poolname, unsigned buffersize=0, unsigned numbuffers=0)
Generic method to create memory pool.
Definition: Manager.cxx:2239
bool DecomposeAddress(const std::string &url, bool &islocal, std::string &server, std::string &itemtname)
Definition: Manager.h:600
bool StopAllModules()
Definition: Manager.cxx:2038
WorkerRef GetCommandChannel()
Definition: Manager.h:690
void * CreateAny(const std::string &classname, const std::string &objname="")
Definition: Manager.cxx:2219
ModuleRef FindModule(const std::string &name)
Definition: Manager.cxx:2018
bool CreateDevice(const std::string &classname, const std::string &devname)
Definition: Manager.cxx:2001
bool CreatePublisher()
Create publisher, which manage all published hierarchies.
Definition: Manager.cxx:2315
bool CreateControl(bool withserver, int serv_port=0, bool allow_clients=true)
Create command channel Parameter withserver defines if server socket will be created,...
Definition: Manager.cxx:2277
ThreadRef CreateThread(const std::string &thrdname, const std::string &classname="", const std::string &devname="")
Definition: Manager.cxx:1988
int NodeId() const
Definition: Manager.cxx:2086
Manager of everything in DABC
Definition: Manager.h:291
int NodeId() const
Return nodes id of local node.
Definition: Manager.h:483
WorkerRef DoCreateModule(const std::string &classname, const std::string &modulename, Command cmd)
Definition: Manager.cxx:824
ModuleRef FindModule(const std::string &name)
Definition: Manager.cxx:713
static const char * ConnMgrName()
Definition: Manager.h:478
bool IsAnyModuleRunning()
Definition: Manager.cxx:684
virtual int PreviewCommand(Command cmd)
This method called before command will be executed.
Definition: Manager.cxx:756
std::string ComposeAddress(const std::string &server, const std::string &itemtname="")
Provides string, which can be used as receiver argument.
Definition: Manager.cxx:1439
void Sleep(double tmout, const char *prefix=0)
Perform sleeping with event loop running.
Definition: Manager.cxx:1375
void ProduceParameterEvent(ParameterContainer *par, int evid)
Definition: Manager.cxx:506
bool fAppFinished
when true, reply from application was received
Definition: Manager.h:341
std::string GetLastCreatedDevName()
Definition: Manager.cxx:1249
virtual void Print(int lvl=0)
Displays on std output list of running threads and modules.
Definition: Manager.cxx:1312
Reference DoCreateObject(const std::string &classname, const std::string &objname="", Command cmd=nullptr)
Definition: Manager.cxx:863
std::string fLastCreatedDevName
name of last created device, automatically used for connection establishing
Definition: Manager.h:373
static void ProcessFactory(Factory *factory)
Definition: Manager.cxx:1561
std::string fCfgHost
Definition: Manager.h:361
ThreadsLayout fThrLayout
defines distribution of threads
Definition: Manager.h:371
static Factory * fFirstFactories[10]
first factories, which are comming before manager is created
Definition: Manager.h:309
virtual bool Find(ConfigIO &cfg)
Method to locate object in xml file.
Definition: Manager.cxx:1880
WorkerRef FindDevice(const std::string &name)
Definition: Manager.cxx:734
bool DeleteAnyObject(T *obj)
Delete of any kind of object in manager thread.
Definition: Manager.h:512
bool UnregisterDependency(Object *src, Object *tgt, bool bidirectional=false)
Unregister dependency between objects.
Definition: Manager.cxx:1514
bool InstallSignalHandlers()
DependPairList * fDepend
Definition: Manager.h:358
static int fInstanceId
magic number which indicates that instance is initialized
Definition: Manager.h:308
ApplicationRef app()
Definition: Manager.cxx:741
Reference FindItem(const std::string &itemname, bool islocal=false)
Find object in manager hierarchy with specified itemname.
Definition: Manager.cxx:697
static const char * AppThrdName()
Definition: Manager.h:477
TimeStamp fMgrStoppedTime
indicate when manager mainloop was stopped
Definition: Manager.h:340
@ MagicInstanceId
Definition: Manager.h:302
void RunManagerCmdLoop(double runtime=0., const std::string &remnode="")
Runs manager command loop - when command shell is used.
Definition: Manager.cxx:1713
ReferencesVector * fDestroyQueue
Definition: Manager.h:346
int NumNodes()
Returns number of nodes in the cluster FIXME:probably must be removed.
Definition: Manager.h:485
virtual void ProcessEvent(const EventId &)
Definition: Manager.cxx:666
bool ProcessParameterEvents()
Definition: Manager.cxx:549
ThreadRef FindThread(const std::string &name, const std::string &required_class="")
Definition: Manager.cxx:1899
static const char * CmdChlName()
Definition: Manager.h:479
bool ProcessDestroyQueue()
Definition: Manager.cxx:425
Reference FindPort(const std::string &name)
Definition: Manager.cxx:719
virtual int ExecuteCommand(Command cmd)
Main method where commands are executed.
Definition: Manager.cxx:877
static void SetAutoDestroy(bool on)
Method set flag if manager instance should be destroyed when process finished.
Definition: Manager.cxx:239
virtual bool ReplyCommand(Command cmd)
Reimplement this method to react on command reply Return true if command can be destroyed by framewor...
Definition: Manager.cxx:1279
bool DoCleanupApplication()
Definition: Manager.cxx:1363
ParamEventReceiverList * fParEventsReceivers
list of workers, registered for receiving of parameter events Used only from manager thread,...
Definition: Manager.h:355
ReferencesVector * fTimedPars
Definition: Manager.h:351
static const char * MgrThrdName()
Definition: Manager.h:476
bool DoCreateMemoryPool(Command cmd)
Definition: Manager.cxx:1255
void ProcessPipeSignal()
Definition: Manager.cxx:1615
@ evntDestroyObj
Definition: Manager.h:315
@ evntManagerParam
Definition: Manager.h:315
bool RegisterDependency(Object *src, Object *tgt, bool bidirectional=false)
Register dependency between objects.
Definition: Manager.cxx:1493
static int fFirstFactoriesId
magic number which should be set when fFirstFactories initialized for the first time
Definition: Manager.h:310
RecordsQueue< ParamRec > fParsQueue
Definition: Manager.h:348
void ProcessCtrlCSignal()
Definition: Manager.cxx:1589
Reference GetThreadsFolder(bool force=false)
Return reference on folder with all registered threads.
Definition: Manager.h:430
Reference FindPool(const std::string &name)
Definition: Manager.cxx:727
WorkerRef GetCommandChannel()
Return reference on command channel.
Definition: Manager.h:416
void RunManagerMainLoop(double runtime=0.)
Runs manager mainloop.
Definition: Manager.cxx:1631
std::string GetNodeAddress(int nodeid)
Return address of the node to be able communicate with it.
Definition: Manager.cxx:1421
virtual double ProcessTimeout(double last_diff)
Definition: Manager.cxx:1541
std::string fLocalAddress
Identifier for the current application Only set when control instance is created Depending on configu...
Definition: Manager.h:369
Configuration * fCfg
Definition: Manager.h:360
ThreadRef CurrentThread()
Definition: Manager.cxx:1910
Mutex * fMgrMutex
Definition: Manager.h:344
static const char * FactoriesFolderName()
Definition: Manager.h:473
void HaltManager()
Delete all modules and stop manager thread.
Definition: Manager.cxx:371
virtual const char * ClassName() const
Returns class name of the object instance.
Definition: Manager.h:462
std::string GetLocalAddress()
Return address of current application.
Definition: Manager.cxx:1434
ThreadsLayout GetThreadsLayout() const
Definition: Manager.h:498
void FillItemName(const Object *ptr, std::string &itemname, bool compact=true)
Method should be used to produce name of object, which can be used as item name in different Find met...
Definition: Manager.cxx:746
virtual ~Manager()
Definition: Manager.cxx:320
Configuration * cfg() const
Definition: Manager.h:502
static const char * ThreadsFolderName()
Definition: Manager.h:474
ThreadRef DoCreateThread(const std::string &thrdname, const std::string &classname="", const std::string &devname="", Command cmd=nullptr)
Create thread with specified name and class name.
Definition: Manager.cxx:1923
static Manager * fInstance
pointer on current manager instance
Definition: Manager.h:307
bool DecomposeAddress(const std::string &url, bool &islocal, std::string &server, std::string &itemtname)
From address like dabc://nodeabc:988/item/subtim extracts server (with port) and itemname If server n...
Definition: Manager.cxx:1454
int fNumNodes
Definition: Manager.h:364
Reference GetFactoriesFolder(bool force=false)
Return reference on folder with factories.
Definition: Manager.h:423
virtual bool DestroyObject(Reference ref)
Delete derived from Object class object in manager thread.
Definition: Manager.cxx:1317
Reference on dabc::Module class
Definition: Module.h:275
posix pthread mutex
Definition: threads.h:61
Base class for most of the DABC classes.
Definition: Object.h:116
friend class Reference
Definition: Object.h:118
Reference GetFolder(const std::string &name, bool force=false)
Return folder of specified name, no special symbols allowed.
Definition: Object.cxx:814
friend class Manager
Definition: Object.h:117
unsigned NumChilds() const
returns number of child objects
Definition: Object.cxx:670
Container for parameter object.
Definition: Parameter.h:52
Parameter class
Definition: Parameter.h:163
Base class for input and output ports.
Definition: Port.h:47
RecordField GetField(const std::string &name) const
Definition: Record.h:510
bool SetField(const std::string &name, const RecordField &v)
Definition: Record.h:516
Template of queue with complex objects.
Definition: Queue.h:402
Reference on the arbitrary object
Definition: Reference.h:73
void Release()
Releases reference on the object.
Definition: Reference.cxx:138
Object * GetObject() const
Return pointer on the object.
Definition: Reference.h:129
Vector of dabc::Reference objects.
Reference on the dabc::Thread class
Definition: Thread.h:482
Reference on dabc::Worker
Definition: Worker.h:466
Active object, which is working inside dabc::Thread.
Definition: Worker.h:116
@ evntFirstSystem
Definition: Worker.h:202
Event manipulation API.
Definition: api.h:23
ThreadsLayout
Definition: Manager.h:274
@ layoutMaximal
Definition: Manager.h:278
@ layoutPerModule
Definition: Manager.h:276
@ layoutBalanced
Definition: Manager.h:277
@ layoutMinimalistic
Definition: Manager.h:275
ManagerRef mgr
Definition: Manager.cxx:42
const char * xmlThreadAttr
Definition: ConfigBase.cxx:38
const char * xmlPoolName
Definition: Object.cxx:45
const char * xmlClassAttr
Definition: ConfigBase.cxx:36
Event structure, exchanged between DABC threads.
Definition: Thread.h:70
ParamRec & operator=(const ParamRec &src)
Definition: Manager.h:326
Parameter par
reference on the parameter
Definition: Manager.h:318
ParamRec(const ParamRec &src)
Definition: Manager.h:323
ParamRec(Parameter p, int e)
Definition: Manager.h:322
Class for acquiring and holding timestamps.
Definition: timing.h:40