DABC (Data Acquisition Backbone Core)  2.9.9
SocketDevice.h
Go to the documentation of this file.
1 // $Id: SocketDevice.h 4469 2020-04-15 12:53:59Z 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_SocketDevice
17 #define DABC_SocketDevice
18 
19 #ifndef DABC_Device
20 #include "dabc/Device.h"
21 #endif
22 
23 namespace dabc {
24 
25  class NewConnectRec;
26  class SocketProtocolAddon;
27 
33  class SocketDevice : public Device {
34 
35  friend class SocketProtocolAddon;
36  friend class SocketCommandChannel;
37 
38  protected:
39 
40  PointersVector fConnRecs; // list of connections recs
41  PointersVector fProtocols; // list of protocol start processors
43  std::string fBindHost; // host name used for socket binding
44  int fBindPort; // selected port number
45  std::string fCmdChannelId; // server id of command channel, which will redirect sockets
46 
47  virtual double ProcessTimeout(double last_diff);
48 
49  virtual int ExecuteCommand(Command cmd);
50 
51  bool CleanupRecs(double tmout);
52 
53  void AddRec(NewConnectRec* rec);
54 
55  void DestroyRec(NewConnectRec* rec, bool res);
56 
57  NewConnectRec* _FindRec(const char* connid);
58 
59  void ServerProtocolRequest(SocketProtocolAddon* proc, const char* inmsg, char* outmsg);
60 
61  bool ProtocolCompleted(SocketProtocolAddon* proc, const char* inmsg);
62 
63  void RemoveProtocolAddon(SocketProtocolAddon* proc, bool res);
64 
66 
67  std::string StartServerAddon();
68 
69  public:
70  enum {
71  headerConnect = 175404571, // 32-bit value used to identify connect request,
72  ProtocolMsgSize = 100 // total length of request buffer size
73  };
74 
75  virtual std::string RequiredThrdClass() const { return typeSocketThread; }
76  virtual const char* ClassName() const { return dabc::typeSocketDevice; }
77 
78  SocketDevice(const std::string &name, Command cmd);
79  virtual ~SocketDevice();
80 
81  };
82 
83 }
84 
85 #endif
Represents command with its arguments.
Definition: Command.h:99
Base class for device implementation.
Definition: Device.h:43
Specialized vector with pointers.
Definition: Queue.h:340
Provides command channel to the dabc process.
Device for establishing socket connections
Definition: SocketDevice.h:33
PointersVector fConnRecs
Definition: SocketDevice.h:40
void ServerProtocolRequest(SocketProtocolAddon *proc, const char *inmsg, char *outmsg)
bool ProtocolCompleted(SocketProtocolAddon *proc, const char *inmsg)
void DestroyRec(NewConnectRec *rec, bool res)
std::string StartServerAddon()
std::string fBindHost
Definition: SocketDevice.h:43
PointersVector fProtocols
Definition: SocketDevice.h:41
int HandleManagerConnectionRequest(Command cmd)
virtual int ExecuteCommand(Command cmd)
Main method where commands are executed.
virtual double ProcessTimeout(double last_diff)
virtual const char * ClassName() const
Returns class name of the object instance.
Definition: SocketDevice.h:76
bool CleanupRecs(double tmout)
void RemoveProtocolAddon(SocketProtocolAddon *proc, bool res)
SocketDevice(const std::string &name, Command cmd)
NewConnectRec * _FindRec(const char *connid)
std::string fCmdChannelId
Definition: SocketDevice.h:45
virtual std::string RequiredThrdClass() const
Method returns name of required thread class for processor.
Definition: SocketDevice.h:75
void AddRec(NewConnectRec *rec)
Event manipulation API.
Definition: api.h:23
const char * typeSocketThread
Definition: Object.cxx:80
const char * typeSocketDevice
Definition: Object.cxx:79